]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: support operating systems that don't have strnlen()
authorTheodore Ts'o <tytso@mit.edu>
Sun, 25 Mar 2018 02:26:24 +0000 (22:26 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 25 Mar 2018 02:27:51 +0000 (22:27 -0400)
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>
lib/ext2fs/symlink.c

index 13bca6e99efed797d89dc4430423ac1d5c88c236..7f78c5f75549001135a83f0167ad977e038a2bd1 100644 (file)
 #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)
 {