summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libzfs.h5
-rw-r--r--lib/libzfs/libzfs_mount.c10
-rw-r--r--lib/libzfs/libzfs_util.c12
3 files changed, 18 insertions, 9 deletions
diff --git a/include/libzfs.h b/include/libzfs.h
index 082b690e9..e0c695043 100644
--- a/include/libzfs.h
+++ b/include/libzfs.h
@@ -675,7 +675,10 @@ 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 **);
+#define STDOUT_VERBOSE 0x01
+#define STDERR_VERBOSE 0x02
+
+int libzfs_run_process(const char *, char **, int flags);
int libzfs_load_module(const char *);
/*
diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c
index a1faf49d1..1dc58f924 100644
--- a/lib/libzfs/libzfs_mount.c
+++ b/lib/libzfs/libzfs_mount.c
@@ -269,7 +269,7 @@ do_mount(const char *src, const char *mntpt, char *opts)
int rc;
/* Return only the most critical mount error */
- rc = libzfs_run_process(argv[0], argv);
+ rc = libzfs_run_process(argv[0], argv, STDOUT_VERBOSE|STDERR_VERBOSE);
if (rc) {
if (rc & MOUNT_FILEIO)
return EIO;
@@ -310,7 +310,7 @@ do_unmount(const char *mntpt, int flags)
}
argv[count] = (char *)mntpt;
- rc = libzfs_run_process(argv[0], argv);
+ rc = libzfs_run_process(argv[0], argv, STDOUT_VERBOSE|STDERR_VERBOSE);
return (rc ? EINVAL : 0);
}
@@ -414,8 +414,10 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
static int
unmount_one(libzfs_handle_t *hdl, const char *mountpoint, int flags)
{
- if (do_unmount(mountpoint, flags) != 0) {
- zfs_error_aux(hdl, strerror(errno));
+ int error;
+
+ error = do_unmount(mountpoint, flags);
+ if (error != 0) {
return (zfs_error_fmt(hdl, EZFS_UMOUNTFAILED,
dgettext(TEXT_DOMAIN, "cannot unmount '%s'"),
mountpoint));
diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c
index 163cd1671..da1b9bcdd 100644
--- a/lib/libzfs/libzfs_util.c
+++ b/lib/libzfs/libzfs_util.c
@@ -632,15 +632,19 @@ libzfs_module_loaded(const char *module)
}
int
-libzfs_run_process(const char *path, char *argv[])
+libzfs_run_process(const char *path, char *argv[], int flags)
{
pid_t pid;
int rc;
pid = vfork();
if (pid == 0) {
- close(1);
- close(2);
+ if (!(flags & STDOUT_VERBOSE))
+ close(STDOUT_FILENO);
+
+ if (!(flags & STDERR_VERBOSE))
+ close(STDERR_FILENO);
+
(void) execvp(path, argv);
_exit(-1);
} else if (pid > 0) {
@@ -665,7 +669,7 @@ libzfs_load_module(const char *module)
if (libzfs_module_loaded(module))
return 0;
- return libzfs_run_process("/sbin/modprobe", argv);
+ return libzfs_run_process("/sbin/modprobe", argv, 0);
}
libzfs_handle_t *