summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2010-12-16 15:47:40 -0800
committerBrian Behlendorf <[email protected]>2011-01-28 12:47:57 -0800
commitfeb46b92a7619a3bb67b925e24184fe70464d261 (patch)
tree10dc837c2e571a34d80d92133da79864b46f9621
parent95c4cae39fd77b5b00810eb976c9a6462d86ccd4 (diff)
Open up libzfs_run_process/libzfs_load_module
Recently helper functions were added to libzfs_util to load a kernel module or execute a process. Initially this functionality was limited to libzfs but it has become clear there will be other consumers. This change opens up the interface so it may be used where appropriate.
-rw-r--r--include/libzfs.h6
-rw-r--r--lib/libzfs/libzfs_util.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/include/libzfs.h b/include/libzfs.h
index 6752579e8..082b690e9 100644
--- a/include/libzfs.h
+++ b/include/libzfs.h
@@ -673,6 +673,12 @@ extern void zfs_nicenum(uint64_t, char *, size_t);
extern int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *);
/*
+ * Utility functions to run an external process.
+ */
+int libzfs_run_process(const char *, char **);
+int libzfs_load_module(const char *);
+
+/*
* Given a device or file, determine if it is part of a pool.
*/
extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **,
diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c
index 33c440c48..37dba8d39 100644
--- a/lib/libzfs/libzfs_util.c
+++ b/lib/libzfs/libzfs_util.c
@@ -631,7 +631,7 @@ libzfs_module_loaded(const char *module)
return result;
}
-static int
+int
libzfs_run_process(const char *path, char *argv[])
{
pid_t pid;
@@ -657,13 +657,14 @@ libzfs_run_process(const char *path, char *argv[])
return -1;
}
-static int
+int
libzfs_load_module(const char *module)
{
char *argv[4] = {"/sbin/modprobe", "-q", (char *)module, (char *)0};
if (libzfs_module_loaded(module))
return 0;
+
return libzfs_run_process("/sbin/modprobe", argv);
}