All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kaganovich <mahatma@bspu.by>
To: linux-modules@vger.kernel.org
Subject: modinfo must show real module info, not context if filename set
Date: Wed, 26 Feb 2020 04:53:45 +0200	[thread overview]
Message-ID: <dda23def071a8d087cca3538289de1e0@bspu.by> (raw)

After commit e7e2cb61fa9f1db3429d91ef6accff549500d268, even if real 
filename
passed - modinfo show info from context (so, I got built-in info from 
running
kernel, but asking for new kernel's external module). This behaviour 
unobvious
and incompatible with pre-v27. Simple use fake context for filename - 
IMHO
much less ugly then current results.

Signed-off-by: Dzianis Kahanovich <mahatma@eu.by>

--- a/tools/modinfo.c	2020-02-25 13:46:38.181693570 +0300
+++ b/tools/modinfo.c	2020-02-26 05:18:39.393790919 +0300
@@ -359,7 +359,7 @@ static bool is_module_filename(const cha

  static int do_modinfo(int argc, char *argv[])
  {
-	struct kmod_ctx *ctx;
+	struct kmod_ctx *ctx, *ctx0;
  	char dirname_buf[PATH_MAX];
  	const char *dirname = NULL;
  	const char *kversion = NULL;
@@ -437,7 +437,8 @@ static int do_modinfo(int argc, char *ar
  	}

  	ctx = kmod_new(dirname, &null_config);
-	if (!ctx) {
+	ctx0 = kmod_new("/dev/null", &null_config);
+	if (!ctx || !ctx0) {
  		ERR("kmod_new() failed!\n");
  		return EXIT_FAILURE;
  	}
@@ -448,7 +449,7 @@ static int do_modinfo(int argc, char *ar
  		int r;

  		if (is_module_filename(name))
-			r = modinfo_path_do(ctx, name);
+			r = modinfo_path_do(ctx0, name);
  		else
  			r = modinfo_alias_do(ctx, name);

@@ -456,6 +457,7 @@ static int do_modinfo(int argc, char *ar
  			err = r;
  	}

+	kmod_unref(ctx0);
  	kmod_unref(ctx);
  	return err >= 0 ? EXIT_SUCCESS : EXIT_FAILURE;
  }

             reply	other threads:[~2020-02-26  3:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26  2:53 Denis Kaganovich [this message]
2020-02-26 18:31 ` modinfo must show real module info, not context if filename set Alexey Gladkov
2020-02-26 19:36   ` Lucas De Marchi
2020-02-26 22:36     ` Alexey Gladkov

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=dda23def071a8d087cca3538289de1e0@bspu.by \
    --to=mahatma@bspu.by \
    --cc=linux-modules@vger.kernel.org \
    --cc=mahatma@eu.by \
    /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.