fix is_module_filename()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From c0c67f24481faa7a450e5fbc8aebaf9f01867139 Mon Sep 17 00:00:00 2001
From: Aleksey Makarov <amakarov@xxxxxxxxxxxxx>
Date: Fri, 23 Nov 2012 20:49:39 +0700
Subject: [PATCH] fix is_module_filename()

modinfo fails if there is a ".ko" substring in the path to the module

Signed-off-by: Aleksey Makarov <amakarov@xxxxxxxxxxxxx>
---
 tools/modinfo.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/tools/modinfo.c b/tools/modinfo.c
index aec2608..99b607f 100644
--- a/tools/modinfo.c
+++ b/tools/modinfo.c
@@ -347,10 +347,22 @@ static void help(void)
 static bool is_module_filename(const char *name)
 {
        struct stat st;
-       const char *ptr;
+       const char *ptr, *ptr1 = NULL;
+
+       if (stat(name, &st) == 0 && S_ISREG(st.st_mode)) {
+
+               /*
+                * find the last ".ko" substring
+                */
+               ptr1 = strstr(name, ".ko");
+               if (ptr1 == NULL)
+                       return false;
+
+               while (ptr1 != NULL) {
+                       ptr = ptr1;
+                       ptr1 = strstr(ptr1 + 1, ".ko");
+               }

-       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)
--
1.8.0

~
--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux