Changeset View
Changeset View
Standalone View
Standalone View
sbin/bectl/bectl.c
Show First 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | bectl_cmd_create(int argc, char *argv[]) | ||||
if (argc != 1) { | if (argc != 1) { | ||||
fprintf(stderr, "bectl create: wrong number of arguments\n"); | fprintf(stderr, "bectl create: wrong number of arguments\n"); | ||||
return (usage(false)); | return (usage(false)); | ||||
} | } | ||||
bootenv = *argv; | bootenv = *argv; | ||||
err = BE_ERR_SUCCESS; | err = BE_ERR_SUCCESS; | ||||
if ((atpos = strchr(bootenv, '@')) != NULL) { | if (strchr(bootenv, ' ') != NULL) | ||||
/* BE datasets with spaces are not bootable */ | |||||
err = BE_ERR_INVALIDNAME; | |||||
else if ((atpos = strchr(bootenv, '@')) != NULL) { | |||||
/* | /* | ||||
* This is the "create a snapshot variant". No new boot | * This is the "create a snapshot variant". No new boot | ||||
* environment is to be created here. | * environment is to be created here. | ||||
*/ | */ | ||||
*atpos++ = '\0'; | *atpos++ = '\0'; | ||||
err = be_snapshot(be, bootenv, atpos, recursive, NULL); | err = be_snapshot(be, bootenv, atpos, recursive, NULL); | ||||
} else { | } else { | ||||
if (snapname == NULL) | if (snapname == NULL) | ||||
Show All 10 Lines | else if ((atpos = strchr(bootenv, '@')) != NULL) { | ||||
if (err == BE_ERR_SUCCESS) | if (err == BE_ERR_SUCCESS) | ||||
err = be_create_depth(be, bootenv, snapshot, | err = be_create_depth(be, bootenv, snapshot, | ||||
recursive == true ? -1 : 0); | recursive == true ? -1 : 0); | ||||
} | } | ||||
switch (err) { | switch (err) { | ||||
case BE_ERR_SUCCESS: | case BE_ERR_SUCCESS: | ||||
break; | |||||
case BE_ERR_INVALIDNAME: | |||||
fprintf(stderr, | |||||
"bectl create: boot environment name must not contain spaces\n"); | |||||
break; | break; | ||||
default: | default: | ||||
if (atpos != NULL) | if (atpos != NULL) | ||||
fprintf(stderr, | fprintf(stderr, | ||||
"Failed to create a snapshot '%s' of '%s'\n", | "Failed to create a snapshot '%s' of '%s'\n", | ||||
atpos, bootenv); | atpos, bootenv); | ||||
else if (snapname == NULL) | else if (snapname == NULL) | ||||
fprintf(stderr, | fprintf(stderr, | ||||
▲ Show 20 Lines • Show All 327 Lines • Show Last 20 Lines |