diff options
author | Dan McDonald <danmcd@joyent.com> | 2021-01-20 10:46:23 -0500 |
---|---|---|
committer | Dan McDonald <danmcd@joyent.com> | 2021-01-20 10:46:23 -0500 |
commit | c85996c970d16f2bbde7e025b3f18fdaef5a2e71 (patch) | |
tree | 935eea5cba80972827e1fd528ab3d3cec4e7295d /usr/src/lib/libbe/common/be_rename.c | |
parent | 4b15627ff0a1429ed6b071009361c2ec6cc3de5d (diff) | |
parent | 0b35c8bcd86de836ba2ab241e3b4ac7955c4148c (diff) | |
download | illumos-joyent-c85996c970d16f2bbde7e025b3f18fdaef5a2e71.tar.gz |
[illumos-gate merge]
commit 0b35c8bcd86de836ba2ab241e3b4ac7955c4148c
13424 unix: multiply-defined symbols
commit f976337ad91e7232287bf3bc0e038987a11a8949
13451 beadm needs to do more with temporary BE activation
commit ee6e522102d701504922a982938c5873c599b3ff
13422 ufs: symbol 'iuniqtime' is multiply-defined
Diffstat (limited to 'usr/src/lib/libbe/common/be_rename.c')
-rw-r--r-- | usr/src/lib/libbe/common/be_rename.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/usr/src/lib/libbe/common/be_rename.c b/usr/src/lib/libbe/common/be_rename.c index 64c26943bf..f0cd781b22 100644 --- a/usr/src/lib/libbe/common/be_rename.c +++ b/usr/src/lib/libbe/common/be_rename.c @@ -22,6 +22,7 @@ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. */ #include <assert.h> @@ -37,6 +38,7 @@ #include <libbe.h> #include <libbe_priv.h> +#include <libzfsbootenv.h> /* ******************************************************************** */ /* Public Functions */ @@ -185,13 +187,48 @@ be_rename(nvlist_t *be_attrs) goto done; } + /* Change the nextboot property on the pool if necessary */ + if (getzoneid() == GLOBAL_ZONEID) { + char *nextboot = NULL; + int rv = 0; + + if (lzbe_get_boot_device(bt.obe_zpool, &nextboot) == 0 && + nextboot != NULL && strcmp(nextboot, bt.obe_root_ds) == 0) { + if ((rv = lzbe_set_boot_device(bt.obe_zpool, + lzbe_add, "")) != 0) { + be_print_err(gettext("be_rename: failed to " + "remove temporary activation for " + "dataset %s on pool %s\n"), + bt.obe_root_ds, bt.obe_zpool); + } + if (rv == 0 && (rv = lzbe_set_boot_device(bt.nbe_zpool, + lzbe_add, bt.nbe_root_ds)) != 0) { + be_print_err(gettext("be_rename: failed to " + "enable temporary activation for " + "dataset %s on pool %s\n"), + bt.nbe_root_ds, bt.nbe_zpool); + } + } + free(nextboot); + switch (rv) { + case 0: + break; + case ENOMEM: + ret = BE_ERR_NOMEM; + goto done; + default: + ret = BE_ERR_UNKNOWN; + goto done; + } + } + /* Refresh handle to BE's root dataset after the rename */ ZFS_CLOSE(zhp); if ((zhp = zfs_open(g_zfs, bt.nbe_root_ds, ZFS_TYPE_FILESYSTEM)) == NULL) { be_print_err(gettext("be_rename: failed to " "open BE root dataset (%s): %s\n"), - bt.obe_root_ds, libzfs_error_description(g_zfs)); + bt.nbe_root_ds, libzfs_error_description(g_zfs)); ret = zfs_err_to_be_err(g_zfs); goto done; } |