]> git.ipfire.org Git - thirdparty/kmod.git/blobdiff - tools/modinfo.c
Move remaining functions from libkmod-util to shared
[thirdparty/kmod.git] / tools / modinfo.c
index 8cfe381ff1f5ee043c404d2a1b8683a6229f711f..74ec183410be1449839aa67060dc52be5ec25f1d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * kmod-modinfo - query kernel module information using libkmod.
  *
- * Copyright (C) 2011-2012  ProFUSION embedded systems
+ * Copyright (C) 2011-2013  ProFUSION embedded systems
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <errno.h>
+#include <getopt.h>
+#include <limits.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdbool.h>
-#include <getopt.h>
-#include <errno.h>
 #include <string.h>
-#include <limits.h>
-#include <sys/utsname.h>
 #include <sys/stat.h>
-#include "libkmod.h"
+#include <sys/utsname.h>
+
+#include <shared/util.h>
+
+#include <libkmod.h>
 
 #include "kmod.h"
 
@@ -341,23 +344,16 @@ static void help(void)
                "\t-b, --basedir=DIR           Use DIR as filesystem root for /lib/modules\n"
                "\t-V, --version               Show version\n"
                "\t-h, --help                  Show this help\n",
-               binname);
+               program_invocation_short_name);
 }
 
 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;
 }