From 7c168d1ff80c2753e5187e90d34f53f3526afa1d Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Mon, 8 Dec 2008 15:28:49 +0100 Subject: [PATCH] blkis: fix detection of ext4dev as ext4 If only ext4 is available (as a module or in /proc/filesystems) blkid wasn't properly testing for it, because the time checks were backwards and always failed. This caused old ext4dev filesystems to fail to mount as ext4. With this patch it works fine. Also, don't try to check for modules on a non-Linux system. [kzak@redhat.com: port from e2fsprogs to util-linux-ng tree] Signed-off-by: Eric Sandeen Signed-off-by: Theodore Ts'o Signed-off-by: Karel Zak --- libs/blkid/src/probe.c | 1 - libs/blkid/src/probers/ext.c | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/blkid/src/probe.c b/libs/blkid/src/probe.c index 806938d7..e3c147df 100644 --- a/libs/blkid/src/probe.c +++ b/libs/blkid/src/probe.c @@ -20,7 +20,6 @@ #ifdef HAVE_SYS_MKDEV_H #include #endif -#include #ifdef HAVE_ERRNO_H #include #endif diff --git a/libs/blkid/src/probers/ext.c b/libs/blkid/src/probers/ext.c index 5adb9cb2..26cc679e 100644 --- a/libs/blkid/src/probers/ext.c +++ b/libs/blkid/src/probers/ext.c @@ -13,7 +13,9 @@ #include #include #include +#ifdef __linux__ #include +#endif #include #include "blkidP.h" @@ -341,6 +343,7 @@ static int fs_proc_check(const char *fs_name) */ static int check_for_modules(const char *fs_name) { +#ifdef __linux__ struct utsname uts; FILE *f; char buf[1024], *cp, *t; @@ -372,6 +375,7 @@ static int check_for_modules(const char *fs_name) return 1; } fclose(f); +#endif /* __linux__ */ return 0; } @@ -381,7 +385,7 @@ static int system_supports_ext4(void) static int ret = -1; time_t now = time(0); - if (ret != -1 || (last_check - now) < 5) + if (ret != -1 || (now - last_check) < 5) return ret; last_check = now; ret = (fs_proc_check("ext4") || check_for_modules("ext4")); @@ -394,7 +398,7 @@ static int system_supports_ext4dev(void) static int ret = -1; time_t now = time(0); - if (ret != -1 || (last_check - now) < 5) + if (ret != -1 || (now - last_check) < 5) return ret; last_check = now; ret = (fs_proc_check("ext4dev") || check_for_modules("ext4dev")); -- 2.39.5