#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;
f = fopen(buf, "r");
if (!f)
return 0;
+
+ namesz = strlen(fs_name);
+
while (!feof(f)) {
if (!fgets(buf, sizeof(buf), f))
break;
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;
}