From 89d19e002086cf26431426fe713cfef456067882 Mon Sep 17 00:00:00 2001 From: Alexander Eremin Date: Mon, 9 Apr 2012 13:29:54 +0400 Subject: 2451 beadm umount should report if there is nothing to unmount 2450 beadm umount should support mountpoint name Reviewed by: Dan Kruchinin Reviewed by: Michael Schuster Reviewed by: Gary Mills Approved by: Gordon Ross --- usr/src/lib/libbe/common/be_mount.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'usr/src/lib/libbe/common/be_mount.c') diff --git a/usr/src/lib/libbe/common/be_mount.c b/usr/src/lib/libbe/common/be_mount.c index bacb5d4ab4..6c631da67d 100644 --- a/usr/src/lib/libbe/common/be_mount.c +++ b/usr/src/lib/libbe/common/be_mount.c @@ -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 @@ int 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 @@ be_unmount(nvlist_t *be_attrs) 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 @@ _be_unmount(char *be_name, int flags) } ZFS_CLOSE(zhp); - return (BE_SUCCESS); + return (BE_ERR_NOTMOUNTED); } /* -- cgit v1.2.3