[RFC 1/2] libkmod: avoid failure when the builtin file cannot be loaded

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This file should always exist for any healthy kernel install, but
lacking it should not cause kmod_load_resources to fail. Add an
attribute for the indicies indicating whether or not failures should be
treated as fatal.
---
 libkmod/libkmod.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index f898438..08b0099 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -51,11 +51,28 @@
 static struct _index_files {
 	const char *fn;
 	const char *prefix;
+	bool fatal;
 } index_files[] = {
-	[KMOD_INDEX_MODULES_DEP] = { .fn = "modules.dep", .prefix = "" },
-	[KMOD_INDEX_MODULES_ALIAS] = { .fn = "modules.alias", .prefix = "alias " },
-	[KMOD_INDEX_MODULES_SYMBOL] = { .fn = "modules.symbols", .prefix = "alias "},
-	[KMOD_INDEX_MODULES_BUILTIN] = { .fn = "modules.builtin", .prefix = ""},
+	[KMOD_INDEX_MODULES_DEP] = {
+		.fn = "modules.dep",
+		.prefix = "",
+		.fatal = true,
+	},
+	[KMOD_INDEX_MODULES_ALIAS] = {
+		.fn = "modules.alias",
+		.prefix = "alias ",
+		.fatal = true,
+	},
+	[KMOD_INDEX_MODULES_SYMBOL] = {
+		.fn = "modules.symbols",
+		.prefix = "alias ",
+		.fatal = false,
+	},
+	[KMOD_INDEX_MODULES_BUILTIN] = {
+		.fn = "modules.builtin",
+		.prefix = "",
+		.fatal = false,
+	},
 };
 
 static const char *default_config_paths[] = {
@@ -808,7 +825,7 @@ KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx)
 							index_files[i].fn);
 		ctx->indexes[i] = index_mm_open(ctx, path,
 						&ctx->indexes_stamp[i]);
-		if (ctx->indexes[i] == NULL)
+		if (ctx->indexes[i] == NULL && index_files[i].fatal)
 			goto fail;
 	}
 
-- 
1.8.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux