diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2019-10-16 14:55:56 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2019-10-16 14:55:56 +0000 |
commit | 8338f584dc6e4b8bc6257bcce210d068f8280e3c (patch) | |
tree | 1ed440ecfdb65b98e8712a17b54063112ea83b3b /sbin | |
parent | bc37ac7ea8dd10039688d7cd2cef1d079fd025ac (diff) | |
download | src-8338f584dc6e4b8bc6257bcce210d068f8280e3c.tar.gz src-8338f584dc6e4b8bc6257bcce210d068f8280e3c.zip |
bectl(8): destroy: use BE_DESTROY_AUTOORIGIN if -o is not specified
-o will force the origin to be destroyed unconditionally.
BE_DESTROY_AUTOORIGIN, on the other hand, will only destroy the origin if it
matches the format used by be_snapshot. This lets us clean up the snapshots
that are clearly not user-managed (because we're creating them) while
leaving user-created snapshots in place and warning that they're still
around when the BE created goes away.
Notes
Notes:
svn path=/head/; revision=353646
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/bectl/bectl.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sbin/bectl/bectl.c b/sbin/bectl/bectl.c index 57fef71b4521..38716de70687 100644 --- a/sbin/bectl/bectl.c +++ b/sbin/bectl/bectl.c @@ -376,6 +376,7 @@ bectl_cmd_destroy(int argc, char *argv[]) /* We'll emit a notice if there's an origin to be cleaned up */ if ((flags & BE_DESTROY_ORIGIN) == 0 && strchr(target, '@') == NULL) { + flags |= BE_DESTROY_AUTOORIGIN; if (be_root_concat(be, target, targetds) != 0) goto destroy; if (be_prop_list_alloc(&props) != 0) @@ -384,7 +385,8 @@ bectl_cmd_destroy(int argc, char *argv[]) be_prop_list_free(props); goto destroy; } - if (nvlist_lookup_string(props, "origin", &origin) == 0) + if (nvlist_lookup_string(props, "origin", &origin) == 0 && + !be_is_auto_snapshot_name(be, origin)) fprintf(stderr, "bectl destroy: leaving origin '%s' intact\n", origin); be_prop_list_free(props); |