Author: kevans
Date: Wed Oct 16 14:55:56 2019
New Revision: 353646
URL: https://svnweb.freebsd.org/changeset/base/353646

Log:
  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.

Modified:
  head/sbin/bectl/bectl.c

Modified: head/sbin/bectl/bectl.c
==============================================================================
--- head/sbin/bectl/bectl.c     Wed Oct 16 14:46:04 2019        (r353645)
+++ head/sbin/bectl/bectl.c     Wed Oct 16 14:55:56 2019        (r353646)
@@ -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);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to