daemon: If /proc/modules doesn't exist, linuxmodules optgroup is disabled.

It likely means the kernel was compiled without modules support.
This commit is contained in:
Richard W.M. Jones
2013-08-12 19:25:11 +01:00
parent 071d7fb6d7
commit 8ad634877c

View File

@@ -20,6 +20,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#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);