summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2009-08-23 21:13:56 +0200
committerTheodore Ts'o <tytso@mit.edu>2009-08-27 20:58:54 -0400
commit249c962ad8f2daabc403577d0c994e4c986c8f9a (patch)
tree20a3545c3e185571988466b01e9614f205360899 /lib
parent8bafedbf4a6889b20e119a667fc243909d283f85 (diff)
downloade2fsprogs-249c962ad8f2daabc403577d0c994e4c986c8f9a.tar.gz
blkid: support .ko.gz in modules.dep parser
The Linux kernel modules could be compressed, it means modules.dep parser in libblid has to support .ko.gz extension too. (Note, I've talked about this problem with Jon Masters and his suggestion is to exec(/sbin/modinfo) rather than directly parse modules.dep. BTW, the modules.dep file is deprecated.) Address-Red-Hat-Bug: #518572 Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'lib')
-rw-r--r--lib/blkid/probe.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index 8f6cfa6a..6b75732e 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -208,8 +208,8 @@ static int check_for_modules(const char *fs_name)
#ifdef __linux__
struct utsname uts;
FILE *f;
- char buf[1024], *cp, *t;
- int i;
+ char buf[1024], *cp;
+ int namesz;
if (uname(&uts))
return (0);
@@ -218,6 +218,9 @@ static int check_for_modules(const char *fs_name)
f = fopen(buf, "r");
if (!f)
return (0);
+
+ namesz = strlen(fs_name);
+
while (!feof(f)) {
if (!fgets(buf, sizeof(buf), f))
break;
@@ -229,13 +232,9 @@ static int check_for_modules(const char *fs_name)
cp++;
else
cp = buf;
- i = strlen(cp);
- if (i > 3) {
- t = cp + i - 3;
- if (!strcmp(t, ".ko"))
- *t = 0;
- }
- if (!strcmp(cp, fs_name)) {
+ if (!strncmp(cp, fs_name, namesz) &&
+ (!strcmp(cp + namesz, ".ko") ||
+ !strcmp(cp + namesz, ".ko.gz"))) {
fclose(f);
return (1);
}