Re: fix is_module_filename()

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

 



Hi Aleksey,

On Fri, Nov 23, 2012 at 1:50 PM, Aleksey Makarov <amakarov@xxxxxxxxxxxxx> wrote:
> 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>

we don't use s-o-b

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

I don't like the strstr loop above. We could either

1) check the extensions similarly to what  depmod does
2) rely on user passing "--" for module names. This was my preferred
from the beginning but this could break current users.

I think (1) could be very simple.

thanks
Lucas De Marchi
--
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