aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAleksey Makarov <amakarov@dev.rtsoft.ru>2012-11-28 10:44:00 +0700
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2012-11-28 11:22:00 -0200
commit6f02b6fa7ac435017b8f63dc9a1c8ce62bba008b (patch)
tree80fdc1500dea5b7be6907d3a39015ffd978175a2 /tools
parenta4578669ca25ef6ede96bf4262821bcb07c8065c (diff)
downloadkmod-6f02b6fa7ac435017b8f63dc9a1c8ce62bba008b.tar.gz
fix is_module_filename()
modinfo fails if there is a ".ko" substring in the path to the module
Diffstat (limited to 'tools')
-rw-r--r--tools/depmod.c40
-rw-r--r--tools/modinfo.c10
2 files changed, 4 insertions, 46 deletions
diff --git a/tools/depmod.c b/tools/depmod.c
index 7bbdcd3..de77391 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -40,22 +40,6 @@
#define DEFAULT_VERBOSE LOG_WARNING
static int verbose = DEFAULT_VERBOSE;
-#define KMOD_EXT_UNC 0
-
-static const struct kmod_ext {
- const char *ext;
- size_t len;
-} kmod_exts[] = {
- {".ko", sizeof(".ko") - 1},
-#ifdef ENABLE_ZLIB
- {".ko.gz", sizeof(".ko.gz") - 1},
-#endif
-#ifdef ENABLE_XZ
- {".ko.xz", sizeof(".ko.xz") - 1},
-#endif
- {NULL, 0},
-};
-
static const char CFG_BUILTIN_KEY[] = "built-in";
static const char *default_cfg_paths[] = {
"/run/depmod.d",
@@ -1204,20 +1188,10 @@ static int depmod_modules_search_file(struct depmod *depmod, size_t baselen, siz
struct mod *mod;
const char *relpath;
char modname[PATH_MAX];
- const struct kmod_ext *eitr;
size_t modnamelen;
- uint8_t matches = 0;
int err;
- for (eitr = kmod_exts; eitr->ext != NULL; eitr++) {
- if (namelen <= eitr->len)
- continue;
- if (streq(path + baselen + namelen - eitr->len, eitr->ext)) {
- matches = 1;
- break;
- }
- }
- if (!matches)
+ if (!path_ends_with_kmod_ext(path, baselen + namelen))
return 0;
if (path_to_modname(path, modname, &modnamelen) == NULL) {
@@ -2413,17 +2387,7 @@ static int depfile_up_to_date_dir(DIR *d, time_t mtime, size_t baselen, char *pa
path);
closedir(subdir);
} else if (S_ISREG(st.st_mode)) {
- const struct kmod_ext *eitr;
- uint8_t matches = 0;
- for (eitr = kmod_exts; eitr->ext != NULL; eitr++) {
- if (namelen <= eitr->len)
- continue;
- if (streq(name + namelen - eitr->len, eitr->ext)) {
- matches = 1;
- break;
- }
- }
- if (!matches)
+ if (!path_ends_with_kmod_ext(path, namelen))
continue;
memcpy(path + baselen, name, namelen + 1);
err = st.st_mtime <= mtime;
diff --git a/tools/modinfo.c b/tools/modinfo.c
index aec2608..17ed50d 100644
--- a/tools/modinfo.c
+++ b/tools/modinfo.c
@@ -27,6 +27,7 @@
#include <sys/utsname.h>
#include <sys/stat.h>
#include "libkmod.h"
+#include "libkmod-util.h"
#include "kmod.h"
@@ -347,17 +348,10 @@ static void help(void)
static bool is_module_filename(const char *name)
{
struct stat st;
- const char *ptr;
if (stat(name, &st) == 0 && S_ISREG(st.st_mode) &&
- (ptr = strstr(name, ".ko")) != NULL) {
- /*
- * We screened for .ko; make sure this is either at the end of
- * the name or followed by another '.' (e.g. gz or xz modules)
- */
- if(ptr[3] == '\0' || ptr[3] == '.')
+ path_ends_with_kmod_ext(name, strlen(name)))
return true;
- }
return false;
}