diff --git a/lib/libbe/be.h b/lib/libbe/be.h --- a/lib/libbe/be.h +++ b/lib/libbe/be.h @@ -78,7 +78,7 @@ int be_prop_list_alloc(nvlist_t **be_list); void be_prop_list_free(nvlist_t *be_list); -int be_activate(libbe_handle_t *, const char *, bool); +int be_activate(libbe_handle_t *, const char *, bool, bool); int be_deactivate(libbe_handle_t *, const char *, bool); bool be_is_auto_snapshot_name(libbe_handle_t *, const char *); diff --git a/lib/libbe/be.c b/lib/libbe/be.c --- a/lib/libbe/be.c +++ b/lib/libbe/be.c @@ -1306,7 +1306,7 @@ } int -be_activate(libbe_handle_t *lbh, const char *bootenv, bool temporary) +be_activate(libbe_handle_t *lbh, const char *bootenv, bool temporary, bool promote) { char be_path[BE_MAXPATHLEN]; zfs_handle_t *zhp; @@ -1332,18 +1332,20 @@ if (err) return (-1); - for (;;) { - zhp = zfs_open(lbh->lzh, be_path, ZFS_TYPE_FILESYSTEM); - if (zhp == NULL) - return (-1); + if (promote) { + for (;;) { + zhp = zfs_open(lbh->lzh, be_path, ZFS_TYPE_FILESYSTEM); + if (zhp == NULL) + return (-1); - err = be_zfs_promote(zhp, &found_origin); + err = be_zfs_promote(zhp, &found_origin); - zfs_close(zhp); - if (!found_origin) - break; - if (err) - return (err); + zfs_close(zhp); + if (!found_origin) + break; + if (err) + return (err); + } } if (err) diff --git a/sbin/bectl/bectl.8 b/sbin/bectl/bectl.8 --- a/sbin/bectl/bectl.8 +++ b/sbin/bectl/bectl.8 @@ -25,7 +25,7 @@ .Nm .Op Fl r Ar beroot .Cm activate -.Op Fl t | Fl T +.Op Fl t | Fl T | Fl n .Ar beName .Nm .Op Fl r Ar beroot @@ -120,7 +120,7 @@ Print usage information and exit. .It Xo .Cm activate -.Op Fl t | Fl T +.Op Fl t | Fl T | Fl n .Ar beName .Xc Activate the given @@ -136,6 +136,14 @@ in boot pool .Ar bootfs property. +.Pp +If +.Ar beName +is a clone of another's dataset snapshot, it will be automatically and +recursively promoted. +If the +.Fl n +flag is given, no promotion operation is performed. .It Xo .Cm check .Xc diff --git a/sbin/bectl/bectl.c b/sbin/bectl/bectl.c --- a/sbin/bectl/bectl.c +++ b/sbin/bectl/bectl.c @@ -137,11 +137,11 @@ bectl_cmd_activate(int argc, char *argv[]) { int err, opt; - bool temp, reset; + bool temp, reset, promote = true; temp = false; reset = false; - while ((opt = getopt(argc, argv, "tT")) != -1) { + while ((opt = getopt(argc, argv, "tTn")) != -1) { switch (opt) { case 't': if (reset) @@ -153,6 +153,9 @@ return (usage(false)); reset = true; break; + case 'n': + promote = false; + break; default: fprintf(stderr, "bectl activate: unknown option '-%c'\n", optopt); @@ -177,7 +180,7 @@ } /* activate logic goes here */ - if ((err = be_activate(be, argv[0], temp)) != 0) + if ((err = be_activate(be, argv[0], temp, promote)) != 0) /* XXX TODO: more specific error msg based on err */ printf("Did not successfully activate boot environment %s\n", argv[0]);