]> err.no Git - util-linux/commitdiff
libblkid: add *.ko.gz support to modules.dep parser
authorKarel Zak <kzak@redhat.com>
Sun, 23 Aug 2009 18:33:10 +0000 (20:33 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 7 Sep 2009 07:27:18 +0000 (09:27 +0200)
Address-Red-Hat-Bug: #518572
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/probers/ext.c

index a4d35d1232446a5fb704a5ee095812873a2243e0..c27411d2425da72f1b211ee73b72ace7b08a6767 100644 (file)
@@ -224,8 +224,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;
@@ -234,6 +234,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;
@@ -244,13 +247,10 @@ static int check_for_modules(const char *fs_name)
                if ((cp = strrchr(buf, '/')) == NULL)
                        continue;
                cp++;
-               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;
                }