All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ahelenia Ziemiańska" <nabijaczleweli@nabijaczleweli.xyz>
To: linux-modules@vger.kernel.org
Subject: [PATCH kmod 2/3] Add KMOD_NEW_IGNORE_CMDLINE
Date: Tue, 5 Dec 2023 16:55:22 +0100	[thread overview]
Message-ID: <b666b75fa732407e7e390ba27ebacaf663e93f7d.1701791668.git.nabijaczleweli@nabijaczleweli.xyz> (raw)
In-Reply-To: <d15ca533d7f50ffd27a11fc2fdbec8aa07659b70.1701791668.git.nabijaczleweli@nabijaczleweli.xyz>

[-- Attachment #1: Type: text/plain, Size: 2423 bytes --]

This can be passed to kmod_new_flags() to disable loading configuration
from /proc/cmdline

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 libkmod/libkmod-config.c   | 3 ++-
 libkmod/libkmod-internal.h | 2 +-
 libkmod/libkmod.c          | 2 +-
 libkmod/libkmod.h          | 4 +++-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c
index e24dab1..600d666 100644
--- a/libkmod/libkmod-config.c
+++ b/libkmod/libkmod-config.c
@@ -949,7 +949,8 @@ int kmod_config_new(struct kmod_ctx *ctx, struct kmod_config **p_config,
 		free(cf);
 	}
 
-	kmod_config_parse_kcmdline(config);
+	if (!(options & KMOD_NEW_IGNORE_CMDLINE))
+		kmod_config_parse_kcmdline(config);
 
 	return 0;
 
diff --git a/libkmod/libkmod-internal.h b/libkmod/libkmod-internal.h
index 26a7e28..1d0bd92 100644
--- a/libkmod/libkmod-internal.h
+++ b/libkmod/libkmod-internal.h
@@ -132,7 +132,7 @@ struct kmod_config {
 	struct kmod_list *paths;
 };
 
-int kmod_config_new(struct kmod_ctx *ctx, struct kmod_config **config, const char * const *config_paths) __attribute__((nonnull(1, 2,3)));
+int kmod_config_new(struct kmod_ctx *ctx, struct kmod_config **config, const char * const *config_paths, enum kmod_new_flags options) __attribute__((nonnull(1, 2,3)));
 void kmod_config_free(struct kmod_config *config) __attribute__((nonnull(1)));
 const char *kmod_blacklist_get_modname(const struct kmod_list *l) __attribute__((nonnull(1)));
 const char *kmod_alias_get_name(const struct kmod_list *l) __attribute__((nonnull(1)));
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 279b35d..126a66c 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -317,7 +317,7 @@ KMOD_EXPORT struct kmod_ctx *kmod_new_flags(const char *dirname,
 
 	if (config_paths == NULL)
 		config_paths = default_config_paths;
-	err = kmod_config_new(ctx, &ctx->config, config_paths);
+	err = kmod_config_new(ctx, &ctx->config, config_paths, options);
 	if (err < 0) {
 		ERR(ctx, "could not create config\n");
 		goto fail;
diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
index 72cd7a2..29637dd 100644
--- a/libkmod/libkmod.h
+++ b/libkmod/libkmod.h
@@ -30,7 +30,9 @@
 extern "C" {
 #endif
 
-enum kmod_new_flags {};
+enum kmod_new_flags {
+	KMOD_NEW_IGNORE_CMDLINE = 0x00001,
+};
 
 /*
  * kmod_ctx
-- 
2.39.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-12-05 15:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05 15:55 [PATCH kmod 1/3] Add kmod_new_flags() variant of kmod_new(), with abiver 32 Ahelenia Ziemiańska
2023-12-05 15:55 ` Ahelenia Ziemiańska [this message]
2023-12-06 15:14   ` [PATCH kmod 2/3] Add KMOD_NEW_IGNORE_CMDLINE Lucas De Marchi
2023-12-06 20:37     ` Ahelenia Ziemiańska
2024-02-07  6:06       ` Lucas De Marchi
2023-12-05 15:55 ` [PATCH kmod 3/3] Add modprobe -I/--ignore-cmdline Ahelenia Ziemiańska

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=b666b75fa732407e7e390ba27ebacaf663e93f7d.1701791668.git.nabijaczleweli@nabijaczleweli.xyz \
    --to=nabijaczleweli@nabijaczleweli.xyz \
    --cc=linux-modules@vger.kernel.org \
    /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.