[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1255477979-27721-1-git-send-email-y>
Date: Wed, 14 Oct 2009 01:52:59 +0200
From: y@...hat.com
To: linux-ext4@...r.kernel.org
Cc: "Theodore Ts'o" <tytso@....edu>, Karel Zak <kzak@...hat.com>
Subject: [PATCH] ismounted: handle <=linux-2.6.19 bug in /proc/swaps
From: Karel Zak <kzak@...hat.com>
Linux <= 2.6.19 contained a bug in the /proc/swaps code where the
header would not be displayed (the first line).
This issue has been reported by Mike Frysinger for swapon(8).
Signed-off-by: Karel Zak <kzak@...hat.com>
---
lib/ext2fs/ismounted.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c
index b7f17b8..704f6ff 100644
--- a/lib/ext2fs/ismounted.c
+++ b/lib/ext2fs/ismounted.c
@@ -253,8 +253,16 @@ static int is_swap_device(const char *file)
if (!(f = fopen("/proc/swaps", "r")))
return 0;
/* Skip the first line */
- if (fgets(buf, sizeof(buf), f))
+ if (!fgets(buf, sizeof(buf), f))
+ goto leave;
+ if (*buf && strncmp(buf, "Filename\t", 9))
+ /* Linux <=2.6.19 contained a bug in the /proc/swaps
+ * code where the header would not be displayed
+ */
+ goto valid_first_line;
+
while (fgets(buf, sizeof(buf), f)) {
+valid_first_line:
if ((cp = strchr(buf, ' ')) != NULL)
*cp = 0;
if ((cp = strchr(buf, '\t')) != NULL)
@@ -272,6 +280,8 @@ static int is_swap_device(const char *file)
}
#endif /* __GNU__ */
}
+
+leave:
fclose(f);
return ret;
}
--
1.6.2.5
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists