From 8ad634877cf315288497a8580fb4afc7658deae9 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 12 Aug 2013 19:25:11 +0100 Subject: [PATCH] daemon: If /proc/modules doesn't exist, linuxmodules optgroup is disabled. It likely means the kernel was compiled without modules support. --- daemon/modprobe.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/daemon/modprobe.c b/daemon/modprobe.c index 24d2a5b71..0b7896ae7 100644 --- a/daemon/modprobe.c +++ b/daemon/modprobe.c @@ -20,6 +20,8 @@ #include #include +#include +#include #include "daemon.h" #include "actions.h" @@ -30,6 +32,13 @@ GUESTFSD_EXT_CMD(str_modprobe, modprobe); int optgroup_linuxmodules_available (void) { + /* If /proc/modules doesn't exist, then the appliance kernel + * probably has modules support compiled out. This means modprobe + * is not supported. + */ + if (access ("/proc/modules", R_OK) == -1 && errno == ENOENT) + return 0; + return prog_exists (str_modprobe); } @@ -37,7 +46,9 @@ int do_modprobe (const char *module) { CLEANUP_FREE char *err = NULL; - int r = command (NULL, &err, str_modprobe, module, NULL); + int r; + + r = command (NULL, &err, str_modprobe, module, NULL); if (r == -1) { reply_with_error ("%s", err);