summaryrefslogtreecommitdiff
path: root/usr/src/cmd/boot/bootadm
diff options
context:
space:
mode:
authorAlexander Eremin <a.eremin@nexenta.com>2011-06-14 14:58:56 -0400
committerAlexander Eremin <a.eremin@nexenta.com>2011-06-14 14:58:56 -0400
commit6debd3f5159c9e489474b719498ab00cd81fd232 (patch)
tree26c4b40ad2d9c275dfe344d75f696c9c8b93f853 /usr/src/cmd/boot/bootadm
parent187d6ac08adc31ea6868bde0cfbbb288826254e8 (diff)
downloadillumos-gate-6debd3f5159c9e489474b719498ab00cd81fd232.tar.gz
923 bootadm tries to rebuild archives which it shouldn't
Reviewed by: Garrett D'Amore <garrett@nexenta.com> Reviewed by: Dan McDonald <danmcd@nexenta.com> Approved by: Albert Lee <trisk@nexenta.com>
Diffstat (limited to 'usr/src/cmd/boot/bootadm')
-rw-r--r--usr/src/cmd/boot/bootadm/Makefile4
-rw-r--r--usr/src/cmd/boot/bootadm/bootadm.c61
2 files changed, 64 insertions, 1 deletions
diff --git a/usr/src/cmd/boot/bootadm/Makefile b/usr/src/cmd/boot/bootadm/Makefile
index 53ecff1357..2b0d2cb358 100644
--- a/usr/src/cmd/boot/bootadm/Makefile
+++ b/usr/src/cmd/boot/bootadm/Makefile
@@ -22,6 +22,8 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+#
PROG= bootadm
@@ -36,7 +38,7 @@ include ../Makefile.com
.KEEP_STATE:
LDLIBS_i386= -lfdisk
-LDLIBS += -lnvpair -lgen -ladm -lefi -lscf -lz $(LDLIBS_$(MACH))
+LDLIBS += -lnvpair -lgen -ladm -lefi -lscf -lz -lbe -lzfs $(LDLIBS_$(MACH))
# Writing into string literals is incorrect. We need to match gcc's
# behavior, which causes us to take SIGSEGV on such a write.
diff --git a/usr/src/cmd/boot/bootadm/bootadm.c b/usr/src/cmd/boot/bootadm/bootadm.c
index 277834e0d4..e86ff541f8 100644
--- a/usr/src/cmd/boot/bootadm/bootadm.c
+++ b/usr/src/cmd/boot/bootadm/bootadm.c
@@ -23,6 +23,10 @@
*/
/*
+ * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ */
+
+/*
* bootadm(1M) is a new utility for managing bootability of
* Solaris *Newboot* environments. It has two primary tasks:
* - Allow end users to manage bootability of Newboot Solaris instances
@@ -62,6 +66,7 @@
#include <zlib.h>
#include <sys/lockfs.h>
#include <sys/filio.h>
+#include <libbe.h>
#ifdef i386
#include <libfdisk.h>
#endif
@@ -2920,6 +2925,57 @@ check_archive(char *dest)
return (BAM_SUCCESS);
}
+static boolean_t
+is_be(char *root)
+{
+ zfs_handle_t *zhp;
+ libzfs_handle_t *hdl;
+ be_node_list_t *be_nodes = NULL;
+ be_node_list_t *cur_be;
+ boolean_t be_exist = B_FALSE;
+ char ds_path[ZFS_MAXNAMELEN];
+
+ if (!is_zfs(root))
+ return (B_FALSE);
+ /*
+ * Get dataset for mountpoint
+ */
+ if ((hdl = libzfs_init()) == NULL)
+ return (B_FALSE);
+
+ if ((zhp = zfs_path_to_zhandle(hdl, root,
+ ZFS_TYPE_FILESYSTEM)) == NULL) {
+ libzfs_fini(hdl);
+ return (B_FALSE);
+ }
+
+ (void) strlcpy(ds_path, zfs_get_name(zhp), sizeof (ds_path));
+
+ /*
+ * Check if the current dataset is BE
+ */
+ if (be_list(NULL, &be_nodes) == BE_SUCCESS) {
+ for (cur_be = be_nodes; cur_be != NULL;
+ cur_be = cur_be->be_next_node) {
+
+ /*
+ * Because we guarantee that cur_be->be_root_ds
+ * is null-terminated by internal data structure,
+ * we can safely use strcmp()
+ */
+ if (strcmp(ds_path, cur_be->be_root_ds) == 0) {
+ be_exist = B_TRUE;
+ break;
+ }
+ }
+ be_free_list(be_nodes);
+ }
+ zfs_close(zhp);
+ libzfs_fini(hdl);
+
+ return (be_exist);
+}
+
/*
* Returns 1 if mkiso is in the expected PATH, 0 otherwise
*/
@@ -3588,6 +3644,11 @@ update_archive(char *root, char *opt)
(void) umask(022);
/*
+ * Never update non-BE root in update_all
+ */
+ if (!is_be(root) && bam_update_all)
+ return (BAM_SUCCESS);
+ /*
* root must belong to a boot archive based OS,
*/
if (!is_boot_archive(root)) {