From 0eeec8ac61bf1eaa31533b2be825cd75580829c9 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 12 Sep 2008 09:10:39 -0400 Subject: [PATCH] Fix compiling under diet libc Some recent changes had caused diet libc support to bitrot. Fix up missing header files and other portability fixups needed for dietlibc. (Many of these changes also improve general portability.) Signed-off-by: "Theodore Ts'o" --- e2fsck/Makefile.in | 2 +- e2fsck/crc32.c | 3 +++ e2fsck/ea_refcount.c | 3 +++ e2fsck/message.c | 8 +++++--- e2fsck/pass1.c | 2 ++ e2fsck/region.c | 3 +++ intl/dcigettext.c | 1 + intl/l10nflist.c | 1 + lib/ext2fs/crc16.c | 5 +++++ lib/ext2fs/crc16.h | 2 -- lib/ext2fs/csum.c | 4 ++++ lib/ext2fs/tst_csum.c | 4 ++++ tests/test_config | 2 +- 13 files changed, 33 insertions(+), 7 deletions(-) diff --git a/e2fsck/Makefile.in b/e2fsck/Makefile.in index fe0fab52..77300d18 100644 --- a/e2fsck/Makefile.in +++ b/e2fsck/Makefile.in @@ -141,7 +141,7 @@ tst_crc32: $(srcdir)/crc32.c $(LIBEXT2FS) tst_refcount: ea_refcount.c @echo " LD $@" @$(CC) -o tst_refcount $(srcdir)/ea_refcount.c \ - $(ALL_CFLAGS) -DTEST_PROGRAM $(LIBCOM_ERR) + $(ALL_CFLAGS) -DTEST_PROGRAM $(LIBCOM_ERR) $(LIBEXT2FS) tst_region: region.c @echo " LD $@" diff --git a/e2fsck/crc32.c b/e2fsck/crc32.c index f46295e1..f092c03a 100644 --- a/e2fsck/crc32.c +++ b/e2fsck/crc32.c @@ -36,6 +36,9 @@ #include #include +#ifdef UNITTEST +#undef ENABLE_NLS +#endif #include "e2fsck.h" #include "crc32defs.h" diff --git a/e2fsck/ea_refcount.c b/e2fsck/ea_refcount.c index daaedc4b..39f2db7f 100644 --- a/e2fsck/ea_refcount.c +++ b/e2fsck/ea_refcount.c @@ -11,6 +11,9 @@ #include #include +#ifdef TEST_PROGRAM +#undef ENABLE_NLS +#endif #include "e2fsck.h" /* diff --git a/e2fsck/message.c b/e2fsck/message.c index f79b73c4..5158ed64 100644 --- a/e2fsck/message.c +++ b/e2fsck/message.c @@ -246,7 +246,7 @@ static _INLINE_ void expand_inode_expression(char ch, struct ext2_inode_large *large_inode; const char * time_str; time_t t; - int do_gmt = -1; + static int do_gmt = -1; if (!ctx || !ctx->inode) goto no_inode; @@ -289,15 +289,17 @@ static _INLINE_ void expand_inode_expression(char ch, printf("0%o", inode->i_mode); break; case 'M': +#ifdef __dietlibc__ /* The diet libc doesn't respect the TZ environemnt variable */ if (do_gmt == -1) { time_str = getenv("TZ"); if (!time_str) time_str = ""; - do_gmt = !strcmp(time_str, "GMT"); + do_gmt = !strcmp(time_str, "GMT0"); } +#endif t = inode->i_mtime; - time_str = asctime(do_gmt ? gmtime(&t) : localtime(&t)); + time_str = asctime((do_gmt > 0) ? gmtime(&t) : localtime(&t)); printf("%.24s", time_str); break; case 'F': diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 8bbf7feb..8ad08715 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1206,6 +1206,8 @@ static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b) ib_b->inode.i_block[EXT2_IND_BLOCK]); if (ret == 0) ret = ib_a->inode.i_file_acl - ib_b->inode.i_file_acl; + if (ret == 0) + ret = ib_a->ino - ib_b->ino; return ret; } diff --git a/e2fsck/region.c b/e2fsck/region.c index 0cec6a92..e50c8a44 100644 --- a/e2fsck/region.c +++ b/e2fsck/region.c @@ -14,6 +14,9 @@ #endif #include +#ifdef TEST_PROGRAM +#undef ENABLE_NLS +#endif #include "e2fsck.h" struct region_el { diff --git a/intl/dcigettext.c b/intl/dcigettext.c index a4452f7a..79678cf8 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -155,6 +155,7 @@ char *getcwd (); # endif # endif # ifndef HAVE_STPCPY +#define stpcpy(dest, src) my_stpcpy(dest, src) static char *stpcpy (char *dest, const char *src); # endif # ifndef HAVE_MEMPCPY diff --git a/intl/l10nflist.c b/intl/l10nflist.c index 40b0249b..3393ecb5 100644 --- a/intl/l10nflist.c +++ b/intl/l10nflist.c @@ -58,6 +58,7 @@ # endif #else # ifndef HAVE_STPCPY +#define stpcpy(dest, src) my_stpcpy(dest, src) static char *stpcpy (char *dest, const char *src); # endif #endif diff --git a/lib/ext2fs/crc16.c b/lib/ext2fs/crc16.c index 86091a41..026f040b 100644 --- a/lib/ext2fs/crc16.c +++ b/lib/ext2fs/crc16.c @@ -5,6 +5,11 @@ * Version 2. See the file COPYING for more details. */ +#if HAVE_SYS_TYPES_H +#include +#endif +#include + #include "crc16.h" /** CRC table for the CRC-16. The poly is 0x8005 (x16 + x15 + x2 + 1) */ diff --git a/lib/ext2fs/crc16.h b/lib/ext2fs/crc16.h index e3d8b4a5..322e68dd 100644 --- a/lib/ext2fs/crc16.h +++ b/lib/ext2fs/crc16.h @@ -15,8 +15,6 @@ #ifndef __CRC16_H #define __CRC16_H -#include - /* for an unknown reason, PPC treats __u16 as signed and keeps doing sign * extension on the value. Instead, use only the low 16 bits of an * unsigned int for holding the CRC value to avoid this. diff --git a/lib/ext2fs/csum.c b/lib/ext2fs/csum.c index 459c3c08..0f01919c 100644 --- a/lib/ext2fs/csum.c +++ b/lib/ext2fs/csum.c @@ -9,6 +9,10 @@ * %End-Header% */ +#if HAVE_SYS_TYPES_H +#include +#endif + #include "ext2_fs.h" #include "ext2fs.h" #include "crc16.h" diff --git a/lib/ext2fs/tst_csum.c b/lib/ext2fs/tst_csum.c index 7a91b194..d8816b30 100644 --- a/lib/ext2fs/tst_csum.c +++ b/lib/ext2fs/tst_csum.c @@ -9,6 +9,10 @@ * %End-Header% */ +#if HAVE_SYS_TYPES_H +#include +#endif + #include "ext2fs/ext2_fs.h" #include "ext2fs/ext2fs.h" #include "ext2fs/crc16.h" diff --git a/tests/test_config b/tests/test_config index 3710d56d..45130bad 100644 --- a/tests/test_config +++ b/tests/test_config @@ -21,7 +21,7 @@ DYLD_LIBRARY_PATH=../lib:../lib/ext2fs:../lib/e2p:../lib/et:../lib/ss TMPFILE=./test.img export LD_LIBRARY_PATH export DYLD_LIBRARY_PATH -TZ=GMT +TZ=GMT0 export TZ LC_ALL=C export LC_ALL