]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
blkid: support .ko.gz in modules.dep parser
authorKarel Zak <kzak@redhat.com>
Sun, 23 Aug 2009 19:13:56 +0000 (21:13 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 28 Aug 2009 00:58:54 +0000 (20:58 -0400)
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>
lib/blkid/probe.c

index 8f6cfa6a3dcb5ec812206c835320458c55b24bc3..6b75732e51a000068709f9b9e95f7cbe741c3a41 100644 (file)
@@ -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);
                }