[LEDE-DEV] [PATCH ubox] kmodloader: support '-q' quiet option
Kevin Darbyshire-Bryant
kevin at darbyshire-bryant.me.uk
Fri Jan 27 02:38:12 PST 2017
On 27/01/17 10:36, John Crispin wrote:
>
>
> On 27/01/2017 11:33, Kevin Darbyshire-Bryant wrote:
>> The kernel opportunistically attempts to load modules in advanced with
>> 'predicted' module names. Often these modules don't exist and hence
>> kmodloader produces lots of logfile noise. The kernel commandline to
>> modprobe from kworker proceses is '-q -- modulename' where '-q' means
>> quiet.
>>
>> Signed-off-by: Kevin Darbyshire-Bryant <kevin at darbyshire-bryant.me.uk>
>> ---
>> kmodloader.c | 35 +++++++++++++++++++++++++----------
>> 1 file changed, 25 insertions(+), 10 deletions(-)
>>
>> diff --git a/kmodloader.c b/kmodloader.c
>> index 729027a..52a745f 100644
>> --- a/kmodloader.c
>> +++ b/kmodloader.c
>> @@ -660,6 +660,13 @@ static int print_insmod_usage(void)
>> return -1;
>> }
>>
>> +static int print_modprobe_usage(void)
>> +{
>> + ULOG_INFO("Usage:\n\tmodprobe [-q] filename\n");
>> +
>> + return -1;
>> +}
>> +
>> static int print_usage(char *arg)
>> {
>> ULOG_INFO("Usage:\n\t%s module\n", arg);
>> @@ -824,15 +831,23 @@ static int main_modprobe(int argc, char **argv)
>> struct module *m;
>> char *name;
>> char *mod = NULL;
>> - int i;
>> + int opt;
>> + bool quiet = false;
>> +
>> + while ((opt = getopt(argc, argv, "q")) != -1 ) {
>> + switch (opt) {
>> + case 'q': /* shhhh! */
>> + quiet = true;
>> + break;
>> + default: /* '?' */
>> + return print_modprobe_usage();
>> + break;
>> + }
>> + }
>>
>> - for (i = 1; i < argc; i++)
>> - if (argv[i][0] != '-') {
>> - mod = argv[i];
>> - break;
>> - }
>> - if (!mod)
>> - return print_usage("modprobe");
>> + if (optind >= argc) return print_modprobe_usage(); /* expected module after options */
>> +
>> + mod = argv[optind];
>>
>> if (scan_module_folders())
>> return -1;
>> @@ -843,10 +858,10 @@ static int main_modprobe(int argc, char **argv)
>> name = get_module_name(mod);
>> m = find_module(name);
>> if (m && m->state == LOADED) {
>> - ULOG_ERR("%s is already loaded\n", name);
>> + if (!quiet) ULOG_ERR("%s is already loaded\n", name);
>> return -1;
>
> i can see why we would want to silence this one
>
>> } else if (!m) {
>> - ULOG_ERR("failed to find a module named %s\n", name);
>> + if (!quiet) ULOG_ERR("failed to find a module named %s\n", name);
>
> but do we really want to silence this error ?
From the manpage
-q, --quiet
With this flag, modprobe won't print an error message if you
try to remove or insert a module it can't find (and
isn't an alias or install/remove command). However, it will
still return with a non-zero exit status. The kernel uses
this to opportunistically probe for modules which might
exist using request_module.
>
>> } else {
>> int fail;
>>
>>
More information about the Lede-dev
mailing list