linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* modinfo must show real module info, not context if filename set
@ 2020-02-26  2:53 Denis Kaganovich
  2020-02-26 18:31 ` Alexey Gladkov
  0 siblings, 1 reply; 4+ messages in thread
From: Denis Kaganovich @ 2020-02-26  2:53 UTC (permalink / raw)
  To: linux-modules

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;
  }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-26 22:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-26  2:53 modinfo must show real module info, not context if filename set Denis Kaganovich
2020-02-26 18:31 ` Alexey Gladkov
2020-02-26 19:36   ` Lucas De Marchi
2020-02-26 22:36     ` Alexey Gladkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).