Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Nov 2017 16:17:46 GMT
From:      allanjude@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r329243 - soc2017/kneitinger/libbe-head/sbin/be
Message-ID:  <201711091617.vA9GHkld071540@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: allanjude
Date: Thu Nov  9 16:17:46 2017
New Revision: 329243
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=329243

Log:
  Chase be_snapshot changes on the consumer side
  
  Deal with the incomplete case 'be create newbe@non-existing-snapshot'
  It will now create the snapshot on the active BE, then close it ot create 'newbe'
  

Modified:
  soc2017/kneitinger/libbe-head/sbin/be/be.c

Modified: soc2017/kneitinger/libbe-head/sbin/be/be.c
==============================================================================
--- soc2017/kneitinger/libbe-head/sbin/be/be.c	Thu Nov  9 16:10:17 2017	(r329242)
+++ soc2017/kneitinger/libbe-head/sbin/be/be.c	Thu Nov  9 16:17:46 2017	(r329243)
@@ -174,14 +174,14 @@
 be_cmd_create(int argc, char *argv[])
 {
 	int err, opt;
-	char *existing;
+	char *snapname;
 	char *bootenv;
 
-	existing = NULL;
+	snapname = NULL;
 	while ((opt = getopt(argc, argv, "e:")) != -1) {
 		switch (opt) {
 		case 'e':
-			existing = optarg;
+			snapname = optarg;
 			break;
 		default:
 			fprintf(stderr, "be create: unknown option '-%c'\n",
@@ -201,22 +201,22 @@
 	bootenv = *argv;
 
 
-	if (existing != NULL) {
-		if (strchr(existing, '@') != NULL) {
-			err =
-			    be_create_from_existing_snap(be, bootenv, existing);
+	if (snapname != NULL) {
+		if (strchr(snapname, '@') != NULL) {
+			err = be_create_from_existing_snap(be, bootenv,
+			    snapname);
 		} else {
-			err = be_create_from_existing(be, bootenv, existing);
+			err = be_create_from_existing(be, bootenv, snapname);
 		}
 	} else {
-		/* char *existing, is unused in this case, so it can be
-		 * safely repurposed as snap name */
-		if ((existing = strchr(bootenv, '@')) != NULL) {
-			*(existing++) = '\0';
-			if ((err = be_snapshot(be, bootenv, existing, NULL))
+		if ((snapname = strchr(bootenv, '@')) != NULL) {
+			*(snapname++) = '\0';
+			if ((err = be_snapshot(be, bootenv, snapname, true, NULL))
 			    != BE_ERR_SUCCESS) {
 				fprintf(stderr, "failed to create snapshot\n");
 			}
+			err = be_create_from_existing_snap(be, bootenv,
+			    snapname);
 			return (err);
 		} else {
 			err = be_create(be, bootenv);
@@ -227,13 +227,13 @@
 	case BE_ERR_SUCCESS:
 		break;
 	default:
-		if (existing == NULL) {
+		if (snapname == NULL) {
 			fprintf(stderr,
 			    "failed to create bootenv %s\n", bootenv);
 		} else {
 			fprintf(stderr,
 			    "failed to create bootenv %s from snapshot %s\n",
-			    bootenv, existing);
+			    bootenv, snapname);
 		}
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711091617.vA9GHkld071540>