aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2018-03-24 22:26:24 -0400
committerTheodore Ts'o <tytso@mit.edu>2018-03-24 22:27:51 -0400
commit51ed02bec92431d032d3e5eb0b4b234eef97abc6 (patch)
tree2fad86d4196bdf110f1a6760a59db4bf21967d51
parent46cf3712b39bc83bb5dbd6bd19ecc21af80d6ac1 (diff)
downloade2fsprogs-51ed02bec92431d032d3e5eb0b4b234eef97abc6.tar.gz
libext2fs: support operating systems that don't have strnlen()
Someone was trying to build e2fsprogs on MacOS 10.6.8, and ran into build problems because MacOS didn't have strnlen() support until seven years ago. Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reported-by: Jens Bauer <jens@plustv.dk>
-rw-r--r--lib/ext2fs/symlink.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/ext2fs/symlink.c b/lib/ext2fs/symlink.c
index 13bca6e99..7f78c5f75 100644
--- a/lib/ext2fs/symlink.c
+++ b/lib/ext2fs/symlink.c
@@ -28,6 +28,22 @@
#include "ext2_fs.h"
#include "ext2fs.h"
+#ifndef HAVE_STRNLEN
+/*
+ * Incredibly, libc5 doesn't appear to have strnlen. So we have to
+ * provide our own.
+ */
+static int my_strnlen(const char * s, int count)
+{
+ const char *cp = s;
+
+ while (count-- && *cp)
+ cp++;
+ return cp - s;
+}
+#define strnlen(str, x) my_strnlen((str),(x))
+#endif
+
errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino,
const char *name, const char *target)
{