diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2019-02-11 04:00:01 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2019-02-11 04:00:01 +0000 |
commit | 77b4126ce6f389b135bbad48574923a1264e31fa (patch) | |
tree | 0f58df764a00cb67815f8acf43a3ca94456ccf20 /sbin | |
parent | 39f37df26e1c6aabf7d47dcdc79fc780e43b4039 (diff) | |
download | src-test2-77b4126ce6f389b135bbad48574923a1264e31fa.tar.gz src-test2-77b4126ce6f389b135bbad48574923a1264e31fa.zip |
Notes
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/bectl/bectl.8 | 14 | ||||
-rw-r--r-- | sbin/bectl/bectl.c | 34 |
2 files changed, 38 insertions, 10 deletions
diff --git a/sbin/bectl/bectl.8 b/sbin/bectl/bectl.8 index daff7306b0dd..fce3d606b366 100644 --- a/sbin/bectl/bectl.8 +++ b/sbin/bectl/bectl.8 @@ -18,7 +18,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 25, 2018 +.Dd February 10, 2019 .Dt BECTL 8 .Os .Sh NAME @@ -40,7 +40,7 @@ .Ar beName@snapshot .Nm .Cm destroy -.Op Fl F +.Op Fl \&Fo .Brq Ar beName | beName@snapshot .Nm .Cm export @@ -124,7 +124,7 @@ If the flag is given, a recursive boot environment will be made. .It Xo .Cm destroy -.Op Fl F +.Op Fl \&Fo .Brq Ar beName | beName@snapshot .Xc Destroys the given @@ -136,6 +136,14 @@ snapshot without confirmation, unlike in Specifying .Fl F will automatically unmount without confirmation. +.Pp +By default, +.Nm +will warn that it is not destroying the origin of +.Ar beName . +The +.Fl o +flag may be specified to destroy the origin as well. .It Cm export Ar sourceBe Export .Ar sourceBe diff --git a/sbin/bectl/bectl.c b/sbin/bectl/bectl.c index 06e64cdda9d0..366fa048a893 100644 --- a/sbin/bectl/bectl.c +++ b/sbin/bectl/bectl.c @@ -341,15 +341,18 @@ bectl_cmd_add(int argc, char *argv[]) static int bectl_cmd_destroy(int argc, char *argv[]) { - char *target; - int opt, err; - bool force; + nvlist_t *props; + char *origin, *target, targetds[BE_MAXPATHLEN]; + int err, flags, opt; - force = false; - while ((opt = getopt(argc, argv, "F")) != -1) { + flags = 0; + while ((opt = getopt(argc, argv, "Fo")) != -1) { switch (opt) { case 'F': - force = true; + flags |= BE_DESTROY_FORCE; + break; + case 'o': + flags |= BE_DESTROY_ORIGIN; break; default: fprintf(stderr, "bectl destroy: unknown option '-%c'\n", @@ -368,7 +371,24 @@ bectl_cmd_destroy(int argc, char *argv[]) target = argv[0]; - err = be_destroy(be, target, force); + /* We'll emit a notice if there's an origin to be cleaned up */ + if ((flags & BE_DESTROY_ORIGIN) == 0 && strchr(target, '@') == NULL) { + if (be_root_concat(be, target, targetds) != 0) + goto destroy; + if (be_prop_list_alloc(&props) != 0) + goto destroy; + if (be_get_dataset_props(be, targetds, props) != 0) { + be_prop_list_free(props); + goto destroy; + } + if (nvlist_lookup_string(props, "origin", &origin) == 0) + fprintf(stderr, "bectl destroy: leaving origin '%s' intact\n", + origin); + be_prop_list_free(props); + } + +destroy: + err = be_destroy(be, target, flags); return (err); } |