Changeset View
Changeset View
Standalone View
Standalone View
sbin/bectl/bectl.c
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | usage(bool explicit) | ||||
FILE *fp; | FILE *fp; | ||||
fp = explicit ? stdout : stderr; | fp = explicit ? stdout : stderr; | ||||
fprintf(fp, "%s", | fprintf(fp, "%s", | ||||
"Usage:\tbectl {-h | -? | subcommand [args...]}\n" | "Usage:\tbectl {-h | -? | subcommand [args...]}\n" | ||||
#if SOON | #if SOON | ||||
"\tbectl add (path)*\n" | "\tbectl add (path)*\n" | ||||
#endif | #endif | ||||
"\tbectl activate [-t] beName\n" | "\tbectl activate [-t] beName\n" | ||||
"\tbectl activate [-T]\n" | |||||
kevans: Let's bump -T to a new line, `bectl activate -T` | |||||
"\tbectl check\n" | "\tbectl check\n" | ||||
"\tbectl create [-r] [-e {nonActiveBe | beName@snapshot}] beName\n" | "\tbectl create [-r] [-e {nonActiveBe | beName@snapshot}] beName\n" | ||||
"\tbectl create [-r] beName@snapshot\n" | "\tbectl create [-r] beName@snapshot\n" | ||||
"\tbectl destroy [-F] {beName | beName@snapshot}\n" | "\tbectl destroy [-F] {beName | beName@snapshot}\n" | ||||
"\tbectl export sourceBe\n" | "\tbectl export sourceBe\n" | ||||
"\tbectl import targetBe\n" | "\tbectl import targetBe\n" | ||||
"\tbectl jail {-b | -U} [{-o key=value | -u key}]... " | "\tbectl jail {-b | -U} [{-o key=value | -u key}]... " | ||||
"{jailID | jailName}\n" | "{jailID | jailName}\n" | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | get_cmd_info(const char *cmd) | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
static int | static int | ||||
bectl_cmd_activate(int argc, char *argv[]) | bectl_cmd_activate(int argc, char *argv[]) | ||||
{ | { | ||||
int err, opt; | int err, opt; | ||||
bool temp; | bool temp, reset; | ||||
temp = false; | temp = false; | ||||
while ((opt = getopt(argc, argv, "t")) != -1) { | reset = false; | ||||
while ((opt = getopt(argc, argv, "tT")) != -1) { | |||||
switch (opt) { | switch (opt) { | ||||
case 't': | case 't': | ||||
if (reset) | |||||
return (usage(false)); | |||||
temp = true; | temp = true; | ||||
break; | break; | ||||
case 'T': | |||||
if (temp) | |||||
return (usage(false)); | |||||
reset = true; | |||||
break; | |||||
default: | default: | ||||
fprintf(stderr, "bectl activate: unknown option '-%c'\n", | fprintf(stderr, "bectl activate: unknown option '-%c'\n", | ||||
optopt); | optopt); | ||||
return (usage(false)); | return (usage(false)); | ||||
} | } | ||||
} | } | ||||
argc -= optind; | argc -= optind; | ||||
argv += optind; | argv += optind; | ||||
if (argc != 1) { | if (argc != 1 && (!reset || argc != 0) { | ||||
Done Inline Actionsand check here that argc != 1 && (!reset || argc != 0) kevans: and check here that `argc != 1 && (!reset || argc != 0)` | |||||
kevansUnsubmitted Done Inline ActionsMissing closing parenthesis here kevans: Missing closing parenthesis here | |||||
fprintf(stderr, "bectl activate: wrong number of arguments\n"); | fprintf(stderr, "bectl activate: wrong number of arguments\n"); | ||||
return (usage(false)); | return (usage(false)); | ||||
} | } | ||||
if (reset) { | |||||
if ((err = be_deactivate(be, NULL, reset)) == 0) | |||||
Done Inline Actionsthen just pass in NULL for be_deactivate, because ds is unused for this scenario and I think it's misleading to require an argument that we're not going to use. :-) kevans: then just pass in `NULL` for be_deactivate, because `ds` is unused for this scenario and I… | |||||
printf("Temporary activation removed\n"); | |||||
else | |||||
printf("Failed to remove temporary activation\n"); | |||||
return (err); | |||||
} | |||||
/* activate logic goes here */ | /* activate logic goes here */ | ||||
if ((err = be_activate(be, argv[0], temp)) != 0) | if ((err = be_activate(be, argv[0], temp)) != 0) | ||||
/* XXX TODO: more specific error msg based on err */ | /* XXX TODO: more specific error msg based on err */ | ||||
printf("Did not successfully activate boot environment %s\n", | printf("Did not successfully activate boot environment %s\n", | ||||
argv[0]); | argv[0]); | ||||
else | else | ||||
printf("Successfully activated boot environment %s\n", argv[0]); | printf("Successfully activated boot environment %s\n", argv[0]); | ||||
▲ Show 20 Lines • Show All 406 Lines • Show Last 20 Lines |
Let's bump -T to a new line, bectl activate -T