]> granicus.if.org Git - zfs/commitdiff
Open up libzfs_run_process/libzfs_load_module
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 16 Dec 2010 23:47:40 +0000 (15:47 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 28 Jan 2011 20:47:57 +0000 (12:47 -0800)
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.

include/libzfs.h
lib/libzfs/libzfs_util.c

index 6752579e8c61ec4b6329c750d70a7bc04dc5c6e2..082b690e92492639c1df3546802131f678a23faa 100644 (file)
@@ -672,6 +672,12 @@ extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *,
 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.
  */
index 33c440c4805694f284cf585b23989a740b76286b..37dba8d392e5aa66a838b1f421be9cd2f8a7b09c 100644 (file)
@@ -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);
 }