summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/lib/libbe/common/be_create.c13
-rw-r--r--usr/src/lib/libbe/common/be_rename.c13
-rw-r--r--usr/src/lib/libbe/common/be_utils.c31
-rw-r--r--usr/src/lib/libbe/common/libbe_priv.h3
4 files changed, 54 insertions, 6 deletions
diff --git a/usr/src/lib/libbe/common/be_create.c b/usr/src/lib/libbe/common/be_create.c
index 791d678302..4c69ac38f6 100644
--- a/usr/src/lib/libbe/common/be_create.c
+++ b/usr/src/lib/libbe/common/be_create.c
@@ -24,6 +24,7 @@
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2014, 2015 by Delphix. All rights reserved.
* Copyright (c) 2016 Martin Matuska. All rights reserved.
+ * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
*/
/*
@@ -611,6 +612,8 @@ be_copy(nvlist_t *be_attrs)
uuid_t parent_uu = { 0 };
char obe_root_ds[MAXPATHLEN];
char nbe_root_ds[MAXPATHLEN];
+ char obe_root_container[MAXPATHLEN];
+ char nbe_root_container[MAXPATHLEN];
char ss[MAXPATHLEN];
char *new_mp = NULL;
char *obe_name = NULL;
@@ -1095,8 +1098,14 @@ be_copy(nvlist_t *be_attrs)
/*
* Update new BE's vfstab.
*/
- if ((ret = be_update_vfstab(bt.nbe_name, bt.obe_zpool, bt.nbe_zpool,
- &fld, new_mp)) != BE_SUCCESS) {
+
+ be_make_root_container_ds(bt.obe_zpool, obe_root_container,
+ sizeof (obe_root_container));
+ be_make_root_container_ds(bt.nbe_zpool, nbe_root_container,
+ sizeof (nbe_root_container));
+
+ if ((ret = be_update_vfstab(bt.nbe_name, obe_root_container,
+ nbe_root_container, &fld, new_mp)) != BE_SUCCESS) {
be_print_err(gettext("be_copy: failed to "
"update new BE's vfstab (%s)\n"), bt.nbe_name);
goto done;
diff --git a/usr/src/lib/libbe/common/be_rename.c b/usr/src/lib/libbe/common/be_rename.c
index dee131834c..64c26943bf 100644
--- a/usr/src/lib/libbe/common/be_rename.c
+++ b/usr/src/lib/libbe/common/be_rename.c
@@ -69,6 +69,7 @@ be_rename(nvlist_t *be_attrs)
be_fs_list_data_t fld = { 0 };
zfs_handle_t *zhp = NULL;
char root_ds[MAXPATHLEN];
+ char be_root_container[MAXPATHLEN];
char *mp = NULL;
int zret = 0, ret = BE_SUCCESS;
@@ -205,8 +206,16 @@ be_rename(nvlist_t *be_attrs)
}
/* Update BE's vfstab */
- if ((ret = be_update_vfstab(bt.nbe_name, bt.obe_zpool, bt.nbe_zpool,
- &fld, mp)) != BE_SUCCESS) {
+
+ /*
+ * Since the new and old BEs reside in the same pool (see above),
+ * the same variable can be used for the container for both.
+ */
+ be_make_root_container_ds(bt.obe_zpool, be_root_container,
+ sizeof (be_root_container));
+
+ if ((ret = be_update_vfstab(bt.nbe_name, be_root_container,
+ be_root_container, &fld, mp)) != BE_SUCCESS) {
be_print_err(gettext("be_rename: "
"failed to update new BE's vfstab (%s)\n"), bt.nbe_name);
goto done;
diff --git a/usr/src/lib/libbe/common/be_utils.c b/usr/src/lib/libbe/common/be_utils.c
index 72b41b3315..f748ad978f 100644
--- a/usr/src/lib/libbe/common/be_utils.c
+++ b/usr/src/lib/libbe/common/be_utils.c
@@ -24,7 +24,7 @@
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright 2016 Toomas Soome <tsoome@me.com>
* Copyright (c) 2015 by Delphix. All rights reserved.
- * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+ * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
* Copyright (c) 2018, Joyent, Inc.
*/
@@ -517,6 +517,35 @@ be_make_container_ds(const char *zpool, char *container_ds,
}
/*
+ * Function: be_make_root_container_ds
+ * Description: Generate string for the BE root container dataset given a pool
+ * name.
+ * Parameters:
+ * zpool - pointer zpool name.
+ * container_ds - pointer to buffer in which to return result
+ * container_ds_size - size of container_ds
+ * Returns:
+ * None
+ * Scope:
+ * Semi-private (library wide use only)
+ */
+void
+be_make_root_container_ds(const char *zpool, char *container_ds,
+ int container_ds_size)
+{
+ char *root;
+
+ be_make_container_ds(zpool, container_ds, container_ds_size);
+
+ /* If the container DS ends with /ROOT, remove it. */
+
+ if ((root = strrchr(container_ds, '/')) != NULL &&
+ strcmp(root + 1, BE_CONTAINER_DS_NAME) == 0) {
+ *root = '\0';
+ }
+}
+
+/*
* Function: be_make_name_from_ds
* Description: This function takes a dataset name and strips off the
* BE container dataset portion from the beginning. The
diff --git a/usr/src/lib/libbe/common/libbe_priv.h b/usr/src/lib/libbe/common/libbe_priv.h
index cbd382242b..f2960c4f17 100644
--- a/usr/src/lib/libbe/common/libbe_priv.h
+++ b/usr/src/lib/libbe/common/libbe_priv.h
@@ -24,7 +24,7 @@
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright 2016 Toomas Soome <tsoome@me.com>
* Copyright (c) 2015 by Delphix. All rights reserved.
- * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+ * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
*/
#ifndef _LIBBE_PRIV_H
@@ -175,6 +175,7 @@ boolean_t be_zfs_init(void);
void be_zfs_fini(void);
void be_make_root_ds(const char *, const char *, char *, int);
void be_make_container_ds(const char *, char *, int);
+void be_make_root_container_ds(const char *, char *, int);
char *be_make_name_from_ds(const char *, char *);
int be_append_menu(char *, char *, char *, char *, char *);
int be_remove_menu(char *, char *, char *);