changeset 13663:a64c8d17c8f4

2451 beadm umount should report if there is nothing to unmount 2450 beadm umount should support mountpoint name Reviewed by: Dan Kruchinin <dkruchinin@acm.org> Reviewed by: Michael Schuster <michaelsprivate@gmail.com> Reviewed by: Gary Mills <gary_mills@fastmail.fm> Approved by: Gordon Ross <gwr@nexenta.com>
author Alexander Eremin <a.eremin@nexenta.com>
date Mon, 09 Apr 2012 13:29:54 +0400
parents f850d57a9b6e
children 739954258cbb
files usr/src/cmd/beadm/beadm.c usr/src/lib/libbe/common/be_mount.c usr/src/man/man1m/beadm.1m
diffstat 3 files changed, 27 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/beadm/beadm.c	Fri Apr 06 18:41:42 2012 -0500
+++ b/usr/src/cmd/beadm/beadm.c	Mon Apr 09 13:29:54 2012 +0400
@@ -133,8 +133,8 @@
 	    "\tbeadm destroy [-F] beName@snapshot \n"
 	    "\tbeadm list [[-a] | [-d] [-s]] [-H] [beName]\n"
 	    "\tbeadm mount [-s ro|rw] beName [mountpoint]\n"
-	    "\tbeadm unmount [-f] beName\n"
-	    "\tbeadm umount [-f] beName\n"
+	    "\tbeadm unmount [-f] beName | mountpoint\n"
+	    "\tbeadm umount [-f] beName | mountpoint\n"
 	    "\tbeadm rename origBeName newBeName\n"
 	    "\tbeadm rollback beName snapshot\n"
 	    "\tbeadm rollback beName@snapshot\n"));
--- a/usr/src/lib/libbe/common/be_mount.c	Fri Apr 06 18:41:42 2012 -0500
+++ b/usr/src/lib/libbe/common/be_mount.c	Mon Apr 09 13:29:54 2012 +0400
@@ -22,6 +22,9 @@
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  */
+/*
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ */
 
 /*
  * System includes
@@ -167,6 +170,8 @@
 be_unmount(nvlist_t *be_attrs)
 {
 	char		*be_name = NULL;
+	char		*be_name_mnt = NULL;
+	char		*ds = NULL;
 	uint16_t	flags = 0;
 	int		ret = BE_SUCCESS;
 
@@ -182,6 +187,20 @@
 		return (BE_ERR_INVAL);
 	}
 
+	/* Check if we have mountpoint argument instead of BE name */
+	if (be_name[0] == '/') {
+		if ((ds = be_get_ds_from_dir(be_name)) != NULL) {
+			if ((be_name_mnt = strrchr(ds, '/')) != NULL) {
+				free(be_name);
+				be_name = be_name_mnt + 1;
+			}
+		} else {
+			be_print_err(gettext("be_unmount: no datasets mounted "
+			    "at '%s'\n"), be_name);
+			return (BE_ERR_INVAL);
+		}
+	}
+
 	/* Validate original BE name */
 	if (!be_valid_be_name(be_name)) {
 		be_print_err(gettext("be_unmount: invalid BE name %s\n"),
@@ -449,7 +468,7 @@
 		}
 
 		ZFS_CLOSE(zhp);
-		return (BE_SUCCESS);
+		return (BE_ERR_NOTMOUNTED);
 	}
 
 	/*
--- a/usr/src/man/man1m/beadm.1m	Fri Apr 06 18:41:42 2012 -0500
+++ b/usr/src/man/man1m/beadm.1m	Mon Apr 09 13:29:54 2012 +0400
@@ -1,5 +1,5 @@
 '\" te
-.\" Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+.\" Copyright 2012 Nexenta Systems, Inc. All rights reserved.
 .TH BEADM 1M "Feb 26, 2011"
 .SH NAME
 beadm \- utility for managing zfs boot environments
@@ -33,7 +33,7 @@
 
 .LP
 .nf
-\fBbeadm\fR \fBunmount\fR [\fB-f\fR] \fIbeName\fR
+\fBbeadm\fR \fBunmount\fR [\fB-f\fR] \fIbeName\fR | \fImountpoint\fR
 .fi
 
 .LP
@@ -374,11 +374,12 @@
 .sp
 .ne 2
 .na
-\fBbeadm\fR \fBunmount\fR [\fB-f\fR] \fIbeName\fR
+\fBbeadm\fR \fBunmount\fR [\fB-f\fR] \fIbeName\fR | \fImountpoint\fR
 .ad
 .sp .6
 .RS 4n
-Unmounts the boot environment named beName.
+Unmounts the boot environment named beName. The command can also be given a path to a
+beName mount point on the system.
 .sp
 .ne 2
 .na