Add -u option to 'zfs create' that prevents file system from being
automatically mounted. This is similar to the 'zfs receive -u'. MFC after: 1 week
This commit is contained in:
parent
de63b4d2d5
commit
7aa828debf
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=234654
@ -35,7 +35,7 @@
|
||||
.Op Fl \&?
|
||||
.Nm
|
||||
.Cm create
|
||||
.Op Fl p
|
||||
.Op Fl pu
|
||||
.Op Fl o Ar property Ns = Ns Ar value
|
||||
.Ar ... filesystem
|
||||
.Nm
|
||||
@ -1354,7 +1354,7 @@ Displays a help message.
|
||||
.It Xo
|
||||
.Nm
|
||||
.Cm create
|
||||
.Op Fl p
|
||||
.Op Fl pu
|
||||
.Op Fl o Ar property Ns = Ns Ar value
|
||||
.Ar ... filesystem
|
||||
.Xc
|
||||
@ -1374,6 +1374,8 @@ line using the
|
||||
.Fl o
|
||||
option is ignored. If the target filesystem already exists, the operation
|
||||
completes successfully.
|
||||
.It Fl u
|
||||
Newly created file system is not mounted.
|
||||
.It Fl o Ar property Ns = Ns Ar value
|
||||
Sets the specified property as if the command
|
||||
.Qq Nm Cm set Ar property Ns = Ns Ar value
|
||||
|
@ -217,7 +217,7 @@ get_usage(zfs_help_t idx)
|
||||
return (gettext("\tclone [-p] [-o property=value] ... "
|
||||
"<snapshot> <filesystem|volume>\n"));
|
||||
case HELP_CREATE:
|
||||
return (gettext("\tcreate [-p] [-o property=value] ... "
|
||||
return (gettext("\tcreate [-pu] [-o property=value] ... "
|
||||
"<filesystem>\n"
|
||||
"\tcreate [-ps] [-b blocksize] [-o property=value] ... "
|
||||
"-V <size> <volume>\n"));
|
||||
@ -681,7 +681,7 @@ zfs_do_clone(int argc, char **argv)
|
||||
}
|
||||
|
||||
/*
|
||||
* zfs create [-p] [-o prop=value] ... fs
|
||||
* zfs create [-pu] [-o prop=value] ... fs
|
||||
* zfs create [-ps] [-b blocksize] [-o prop=value] ... -V vol size
|
||||
*
|
||||
* Create a new dataset. This command can be used to create filesystems
|
||||
@ -694,6 +694,8 @@ zfs_do_clone(int argc, char **argv)
|
||||
* SPA_VERSION_REFRESERVATION, we set a refreservation instead.
|
||||
*
|
||||
* The '-p' flag creates all the non-existing ancestors of the target first.
|
||||
*
|
||||
* The '-u' flag prevents mounting of newly created file system.
|
||||
*/
|
||||
static int
|
||||
zfs_do_create(int argc, char **argv)
|
||||
@ -705,6 +707,7 @@ zfs_do_create(int argc, char **argv)
|
||||
boolean_t noreserve = B_FALSE;
|
||||
boolean_t bflag = B_FALSE;
|
||||
boolean_t parents = B_FALSE;
|
||||
boolean_t nomount = B_FALSE;
|
||||
int ret = 1;
|
||||
nvlist_t *props;
|
||||
uint64_t intval;
|
||||
@ -714,7 +717,7 @@ zfs_do_create(int argc, char **argv)
|
||||
nomem();
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt(argc, argv, ":V:b:so:p")) != -1) {
|
||||
while ((c = getopt(argc, argv, ":V:b:so:pu")) != -1) {
|
||||
switch (c) {
|
||||
case 'V':
|
||||
type = ZFS_TYPE_VOLUME;
|
||||
@ -754,6 +757,9 @@ zfs_do_create(int argc, char **argv)
|
||||
case 's':
|
||||
noreserve = B_TRUE;
|
||||
break;
|
||||
case 'u':
|
||||
nomount = B_TRUE;
|
||||
break;
|
||||
case ':':
|
||||
(void) fprintf(stderr, gettext("missing size "
|
||||
"argument\n"));
|
||||
@ -771,6 +777,11 @@ zfs_do_create(int argc, char **argv)
|
||||
"used when creating a volume\n"));
|
||||
goto badusage;
|
||||
}
|
||||
if (nomount && type != ZFS_TYPE_FILESYSTEM) {
|
||||
(void) fprintf(stderr, gettext("'-u' can only be "
|
||||
"used when creating a file system\n"));
|
||||
goto badusage;
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
@ -853,7 +864,7 @@ zfs_do_create(int argc, char **argv)
|
||||
* verbose error message to let the user know that their filesystem was
|
||||
* in fact created, even if we failed to mount or share it.
|
||||
*/
|
||||
if (canmount == ZFS_CANMOUNT_ON) {
|
||||
if (!nomount && canmount == ZFS_CANMOUNT_ON) {
|
||||
if (zfs_mount(zhp, NULL, 0) != 0) {
|
||||
(void) fprintf(stderr, gettext("filesystem "
|
||||
"successfully created, but not mounted\n"));
|
||||
|
Loading…
Reference in New Issue
Block a user