Changeset View
Changeset View
Standalone View
Standalone View
head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
Show First 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | return (gettext("\treceive|recv [-vnsFu] <filesystem|volume|" | ||||
"\treceive|recv [-vnsFu] [-o origin=<snapshot>] [-d | -e] " | "\treceive|recv [-vnsFu] [-o origin=<snapshot>] [-d | -e] " | ||||
"<filesystem>\n" | "<filesystem>\n" | ||||
"\treceive|recv -A <filesystem|volume>\n")); | "\treceive|recv -A <filesystem|volume>\n")); | ||||
case HELP_RENAME: | case HELP_RENAME: | ||||
return (gettext("\trename [-f] <filesystem|volume|snapshot> " | return (gettext("\trename [-f] <filesystem|volume|snapshot> " | ||||
"<filesystem|volume|snapshot>\n" | "<filesystem|volume|snapshot>\n" | ||||
"\trename [-f] -p <filesystem|volume> <filesystem|volume>\n" | "\trename [-f] -p <filesystem|volume> <filesystem|volume>\n" | ||||
"\trename -r <snapshot> <snapshot>\n" | "\trename -r <snapshot> <snapshot>\n" | ||||
"\trename <bookmark> <bookmark>\n" | |||||
"\trename -u [-p] <filesystem> <filesystem>")); | "\trename -u [-p] <filesystem> <filesystem>")); | ||||
case HELP_ROLLBACK: | case HELP_ROLLBACK: | ||||
return (gettext("\trollback [-rRf] <snapshot>\n")); | return (gettext("\trollback [-rRf] <snapshot>\n")); | ||||
case HELP_SEND: | case HELP_SEND: | ||||
return (gettext("\tsend [-DnPpRvLec] [-[iI] snapshot] " | return (gettext("\tsend [-DnPpRvLec] [-[iI] snapshot] " | ||||
"<snapshot>\n" | "<snapshot>\n" | ||||
"\tsend [-LPcenv] [-i snapshot|bookmark] " | "\tsend [-LPcenv] [-i snapshot|bookmark] " | ||||
"<filesystem|volume|snapshot>\n" | "<filesystem|volume|snapshot>\n" | ||||
▲ Show 20 Lines • Show All 2,954 Lines • ▼ Show 20 Lines | zfs_do_list(int argc, char **argv) | ||||
return (ret); | return (ret); | ||||
} | } | ||||
/* | /* | ||||
* zfs rename [-f] <fs | snap | vol> <fs | snap | vol> | * zfs rename [-f] <fs | snap | vol> <fs | snap | vol> | ||||
* zfs rename [-f] -p <fs | vol> <fs | vol> | * zfs rename [-f] -p <fs | vol> <fs | vol> | ||||
* zfs rename -r <snap> <snap> | * zfs rename -r <snap> <snap> | ||||
* zfs rename <bmark> <bmark> | |||||
* zfs rename -u [-p] <fs> <fs> | * zfs rename -u [-p] <fs> <fs> | ||||
* | * | ||||
* Renames the given dataset to another of the same type. | * Renames the given dataset to another of the same type. | ||||
* | * | ||||
* The '-p' flag creates all the non-existing ancestors of the target first. | * The '-p' flag creates all the non-existing ancestors of the target first. | ||||
*/ | */ | ||||
/* ARGSUSED */ | /* ARGSUSED */ | ||||
static int | static int | ||||
zfs_do_rename(int argc, char **argv) | zfs_do_rename(int argc, char **argv) | ||||
{ | { | ||||
zfs_handle_t *zhp; | zfs_handle_t *zhp; | ||||
renameflags_t flags = { 0 }; | renameflags_t flags = { 0 }; | ||||
int c; | int c; | ||||
int ret = 0; | int ret = 0; | ||||
int types; | int types; | ||||
boolean_t parents = B_FALSE; | boolean_t parents = B_FALSE; | ||||
boolean_t bookmarks = B_FALSE; | |||||
char *snapshot = NULL; | char *snapshot = NULL; | ||||
/* check options */ | /* check options */ | ||||
while ((c = getopt(argc, argv, "fpru")) != -1) { | while ((c = getopt(argc, argv, "fpru")) != -1) { | ||||
switch (c) { | switch (c) { | ||||
case 'p': | case 'p': | ||||
parents = B_TRUE; | parents = B_TRUE; | ||||
break; | break; | ||||
Show All 34 Lines | zfs_do_rename(int argc, char **argv) | ||||
} | } | ||||
if (flags.recurse && parents) { | if (flags.recurse && parents) { | ||||
(void) fprintf(stderr, gettext("-p and -r options are mutually " | (void) fprintf(stderr, gettext("-p and -r options are mutually " | ||||
"exclusive\n")); | "exclusive\n")); | ||||
usage(B_FALSE); | usage(B_FALSE); | ||||
} | } | ||||
if (flags.recurse && strchr(argv[0], '@') == 0) { | if (flags.recurse && strchr(argv[0], '@') == NULL) { | ||||
(void) fprintf(stderr, gettext("source dataset for recursive " | (void) fprintf(stderr, gettext("source dataset for recursive " | ||||
"rename must be a snapshot\n")); | "rename must be a snapshot\n")); | ||||
usage(B_FALSE); | usage(B_FALSE); | ||||
} | } | ||||
if (flags.nounmount && parents) { | if (flags.nounmount && parents) { | ||||
(void) fprintf(stderr, gettext("-u and -p options are mutually " | (void) fprintf(stderr, gettext("-u and -p options are mutually " | ||||
"exclusive\n")); | "exclusive\n")); | ||||
usage(B_FALSE); | usage(B_FALSE); | ||||
} | } | ||||
if (strchr(argv[0], '#') != NULL) | |||||
bookmarks = B_TRUE; | |||||
if (bookmarks && (flags.nounmount || flags.recurse || | |||||
flags.forceunmount || parents)) { | |||||
(void) fprintf(stderr, gettext("options are not supported " | |||||
"for renaming bookmarks\n")); | |||||
usage(B_FALSE); | |||||
} | |||||
if (flags.nounmount) | if (flags.nounmount) | ||||
types = ZFS_TYPE_FILESYSTEM; | types = ZFS_TYPE_FILESYSTEM; | ||||
else if (parents) | else if (parents) | ||||
types = ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME; | types = ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME; | ||||
else if (bookmarks) | |||||
types = ZFS_TYPE_BOOKMARK; | |||||
else | else | ||||
types = ZFS_TYPE_DATASET; | types = ZFS_TYPE_DATASET; | ||||
if (flags.recurse) { | if (flags.recurse) { | ||||
/* | /* | ||||
* When we do recursive rename we are fine when the given | * When we do recursive rename we are fine when the given | ||||
* snapshot for the given dataset doesn't exist - it can | * snapshot for the given dataset doesn't exist - it can | ||||
* still exists below. | * still exists below. | ||||
▲ Show 20 Lines • Show All 4,191 Lines • Show Last 20 Lines |