From: Theodore Ts'o Date: Wed, 18 Dec 2002 23:28:10 +0000 (-0500) Subject: pass2.c (strnlen): Provide strnlen if libc doesn't. X-Git-Tag: E2FSPROGS-1_33-WIP-0306~31 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=e34bf43aff93b6e8a90b8e93d52f0e2376baf213;p=tools%2Fe2fsprogs.git pass2.c (strnlen): Provide strnlen if libc doesn't. --- diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index c2ba5c3..ec07282 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -4,6 +4,10 @@ twice, and abort with an error if this is the case. (Address IBM Bugzilla bug #1226) +2002-12-18 Theodore Ts'o + + * pass2.c (strnlen): Provide strnlen if libc doesn't. + 2003-11-19 Theodore Ts'o * unix.c (PRS): Print an error if more than one of the -p/-a, -n diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index 8703a01..4813d88 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -80,6 +80,21 @@ struct check_dir_struct { e2fsck_t ctx; }; +#ifndef HAVE_STRNLEN +/* + * Incredibly, libc5 doesn't appear to have strnlen. So we have to + * provide our own. + */ +static int strnlen(const char * s, int count) +{ + const char *cp = s; + + while (count-- && *cp) + cp++; + return cp - s; +} +#endif + void e2fsck_pass2(e2fsck_t ctx) { struct ext2_super_block *sb = ctx->fs->super;