All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.de.marchi@gmail.com>
To: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Cc: linux-modules <linux-modules@vger.kernel.org>,
	aris@redhat.com, Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH RFC 1/3] depmod: create depmod dir independent search function
Date: Mon, 8 May 2017 23:56:42 -0700	[thread overview]
Message-ID: <CAKi4VAKesTLCAo2KRJEA0RBEd4ayEjO7_4Xp07j=GjnuyptKgQ@mail.gmail.com> (raw)
In-Reply-To: <20161123152339.27531-2-yauheni.kaliuta@redhat.com>

On Wed, Nov 23, 2016 at 7:23 AM, Yauheni Kaliuta
<yauheni.kaliuta@redhat.com> wrote:
> Prepare to implement external directories support.
>
> The patch splits depmod_modules_search() function to two
> functions: depmod_modules_search(), called by the high level with
> intention to search all possible modules, and
> depmod_module_search_path(), which takes path as a parameter and
> scans modules under the path only. Initially it is used to scan
> the same depmod->cfg->dirname path only.
>
> Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
> ---
>  tools/depmod.c | 31 ++++++++++++++++++++++---------
>  1 file changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/tools/depmod.c b/tools/depmod.c
> index f2b370f146bb..a96501d1cbfb 100644
> --- a/tools/depmod.c
> +++ b/tools/depmod.c
> @@ -1186,29 +1186,42 @@ static int depmod_modules_search_dir(struct depmod *depmod, DIR *d, size_t basel
>         return err;
>  }
>
> -static int depmod_modules_search(struct depmod *depmod)
> +static int depmod_modules_search_path(struct depmod *depmod,
> +                                     const char *path)
>  {
> -       char path[PATH_MAX];
> -       DIR *d = opendir(depmod->cfg->dirname);
> +       char path_buf[PATH_MAX];

not required for this, but since now the path can be anywhere, this is
more prone to failures and could be a good candidate to use
scratchbuf.


> +       DIR *d;
>         size_t baselen;
>         int err;
> +
> +       d = opendir(path);
>         if (d == NULL) {
>                 err = -errno;
> -               ERR("could not open directory %s: %m\n", depmod->cfg->dirname);
> +               ERR("could not open directory %s: %m\n", path);
>                 return err;
>         }
>
> -       baselen = depmod->cfg->dirnamelen;
> -       memcpy(path, depmod->cfg->dirname, baselen);
> -       path[baselen] = '/';
> +       baselen = strlen(path);
> +       memcpy(path_buf, path, baselen);
> +       path_buf[baselen] = '/';
>         baselen++;
> -       path[baselen] = '\0';
> +       path_buf[baselen] = '\0';
>
> -       err = depmod_modules_search_dir(depmod, d, baselen, path);
> +       err = depmod_modules_search_dir(depmod, d, baselen, path_buf);
>         closedir(d);
>         return err;
>  }
>
> +static int depmod_modules_search(struct depmod *depmod)
> +{
> +       int err;
> +
> +       err = depmod_modules_search_path(depmod, depmod->cfg->dirname);
> +       if (err < 0)
> +               return err;
> +       return 0;
> +}

LGTM


Lucas De Marchi

  reply	other threads:[~2017-05-09  6:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-23 15:23 [PATCH RFC 0/3] depmod: implement external directories support Yauheni Kaliuta
2016-11-23 15:23 ` [PATCH RFC 1/3] depmod: create depmod dir independent search function Yauheni Kaliuta
2017-05-09  6:56   ` Lucas De Marchi [this message]
2016-11-23 15:23 ` [PATCH RFC 2/3] depmod: search key: move builtin detection under the add function Yauheni Kaliuta
2017-05-09  7:04   ` Lucas De Marchi
2016-11-23 15:23 ` [PATCH RFC 3/3] depmod: implement external directories support Yauheni Kaliuta
2017-03-18 21:46 ` [PATCH RFC 0/3] " Yauheni Kaliuta
2017-05-09  7:51   ` Lucas De Marchi
2017-05-09  8:50     ` Yauheni Kaliuta
2017-05-09 19:09     ` [PATCHv2 0/4] " Yauheni Kaliuta
2017-05-09 19:09       ` [PATCHv2 1/4] depmod: create depmod dir independent search function Yauheni Kaliuta
2017-06-02  2:18         ` Lucas De Marchi
2017-05-09 19:09       ` [PATCHv2 2/4] depmod: rewrite depmod modules search with scratchbuf Yauheni Kaliuta
2017-06-02  3:23         ` Lucas De Marchi
2017-05-09 19:09       ` [PATCHv2 3/4] depmod: implement external directories support Yauheni Kaliuta
2017-06-02  3:30         ` Lucas De Marchi
2017-05-09 19:09       ` [PATCHv2 4/4] testsuite: add tests for external directory support Yauheni Kaliuta
2017-06-02  4:03         ` Lucas De Marchi
2017-06-02  4:05       ` [PATCHv2 0/4] depmod: implement external directories support Lucas De Marchi
2017-06-20  9:11       ` Yauheni Kaliuta
2017-07-19 18:07         ` Lucas De Marchi
2017-07-19 18:57           ` Yauheni Kaliuta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKi4VAKesTLCAo2KRJEA0RBEd4ayEjO7_4Xp07j=GjnuyptKgQ@mail.gmail.com' \
    --to=lucas.de.marchi@gmail.com \
    --cc=aris@redhat.com \
    --cc=linux-modules@vger.kernel.org \
    --cc=lucas.demarchi@intel.com \
    --cc=yauheni.kaliuta@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.