From 9c07dc00b8ea175aa1446868b5cca5a21b41aecf Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 29 May 2006 11:06:16 -0400 Subject: [PATCH] Add missing backwards compatibility for ancient Linux systems This fixes some (but not all) of the compatibility bugs which prevented e2fsprogs from being compiled on a Linux 2.0.35 system. There are still some unprotected use of long long's, and apparently some type problems with the uuid library, but these can be fixed up later. Signed-off-by: "Theodore Ts'o" --- debugfs/ChangeLog | 7 +++++++ debugfs/util.c | 4 ++-- e2fsck/ChangeLog | 4 ++++ e2fsck/pass1b.c | 2 +- misc/ChangeLog | 5 +++++ misc/filefrag.c | 14 +++++++++++++- 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog index faca4a5..3373908 100644 --- a/debugfs/ChangeLog +++ b/debugfs/ChangeLog @@ -1,3 +1,10 @@ +2006-05-29 Theodore Tso + + * util.c (reset_getopt): In order to support ancient Linux header + files that don't define __GLIBC__ (but which were using + glibc anyway), assume that any system that defines + __linux__ should use the glibc method of resetting getopt(). + 2006-05-28 Theodore Tso * unused.c (do_dump_unused): Use EXT2_MAX_BLOCK_SIZE instead of a diff --git a/debugfs/util.c b/debugfs/util.c index cbbc99b..c6096ab 100644 --- a/debugfs/util.c +++ b/debugfs/util.c @@ -37,7 +37,7 @@ extern int optreset; /* defined by BSD, but not others */ * optind be set zero to reset its state. So the unfortunate state of * affairs is that BSD-derived versions of getopt() misbehave if * optind is set to 0 in order to reset getopt(), and glibc's getopt() - * will core ump if optind is set 1 in order to reset getopt(). + * will core dump if optind is set 1 in order to reset getopt(). * * More modern versions of BSD require that optreset be set to 1 in * order to reset getopt(). Sigh. Standards, anyone? @@ -46,7 +46,7 @@ extern int optreset; /* defined by BSD, but not others */ */ void reset_getopt(void) { -#ifdef __GLIBC__ +#if defined(__GLIBC__) || defined(__linux__) optind = 0; #else optind = 1; diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 6f21380..6f2a735 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,7 @@ +2006-05-29 Theodore Tso + + * pass1b.c: Add missing semicolon when HAVE_INTPTR_T is not defined + 2006-05-22 Theodore Tso * e2fsck.8.in: Fixed spelling mistake. (Addresses Debian Bug: diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c index 2b02b47..a9640ff 100644 --- a/e2fsck/pass1b.c +++ b/e2fsck/pass1b.c @@ -37,7 +37,7 @@ #endif #ifndef HAVE_INTPTR_T -typedef long intptr_t +typedef long intptr_t; #endif /* Needed for architectures where sizeof(int) != sizeof(void *) */ diff --git a/misc/ChangeLog b/misc/ChangeLog index 7e34cd4..a3fdf5b 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,3 +1,8 @@ +2006-05-29 Theodore Tso + + * filefrag.c: Add support for ancient Linux systems that do not + support the LFS api. + 2006-05-28 Theodore Tso * mke2fs.8.in (types): Clarify -T option description. diff --git a/misc/filefrag.c b/misc/filefrag.c index 0a8b29d..5d144ff 100644 --- a/misc/filefrag.c +++ b/misc/filefrag.c @@ -69,7 +69,11 @@ static unsigned long get_bmap(int fd, unsigned long block) static void frag_report(const char *filename) { struct statfs fsinfo; +#ifdef HAVE_FSTAT64 struct stat64 fileinfo; +#else + struct stat fileinfo; +#endif int bs; long i, fd; unsigned long block, last_block = 0, numblocks; @@ -83,7 +87,11 @@ static void frag_report(const char *filename) perror("statfs"); return; } +#ifdef HAVE_FSTAT64 if (stat64(filename, &fileinfo) < 0) { +#else + if (stat(filename, &fileinfo) < 0) { +#endif perror("stat"); return; } @@ -102,7 +110,11 @@ static void frag_report(const char *filename) printf("Filesystem cylinder groups is approximately %ld\n", cylgroups); } - fd = open(filename, O_RDONLY | O_LARGEFILE); +#ifdef HAVE_OPEN64 + fd = open64(filename, O_RDONLY); +#else + fd = open(filename, O_RDONLY); +#endif if (fd < 0) { perror("open"); return; -- 1.8.3.1