From patchwork Tue Dec 5 15:55:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13480355 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nabijaczleweli.xyz header.i=@nabijaczleweli.xyz header.b="qjtHBDnj" Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2892D3 for ; Tue, 5 Dec 2023 07:55:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1701791722; bh=y2v9m4Gb+hGL9frbSGaWeV/RxhbFLyoAK8ncAevPAx8=; h=Date:From:To:Subject:References:In-Reply-To:From; b=qjtHBDnjwez4ckKIr+HzFpbzVszBJpdPg4RwsRnfyRLXaUX75XUv9+FwAwWQeDOIX MnI8rkXq1xWkK8Vql7gYPhi9xB+wW6oIBHZpiVQC8Qg7pPxeXcKnzZ70QQOqjHVl8E ON0PJ0eDgZEteayuzjbJ1xfHlPKtVCd0IfAyxrOmTIAFImYiUzPtlPPH25Hh7LPmko obaVMkCV65ZwkT10KApbIarBBGhFlS1smEGiqmX5X/EeOhehXWpYJQQ5fopKU2tRME sCesPzEdF7eNEQWlBWklI/PbMTle2gRYWnOO7qcHxZbCaKBUuIRjdB2wH3sFi66nJy YHdk6slwpzANg== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 98CE812D96 for ; Tue, 5 Dec 2023 16:55:22 +0100 (CET) Date: Tue, 5 Dec 2023 16:55:22 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= To: linux-modules@vger.kernel.org Subject: [PATCH kmod 2/3] Add KMOD_NEW_IGNORE_CMDLINE Message-ID: References: Precedence: bulk X-Mailing-List: linux-modules@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20231103 This can be passed to kmod_new_flags() to disable loading configuration from /proc/cmdline Signed-off-by: Ahelenia Ziemiańska Signed-off-by: Ahelenia Ziemiańska --- 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