diff options
author | LOLi <[email protected]> | 2018-09-13 22:37:42 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-09-13 13:37:42 -0700 |
commit | 5140a58f3b2a25ce24ff9ae2b01277cd6c64f5ad (patch) | |
tree | f4155d286765913db500544c93eca05fcec030f6 /cmd | |
parent | 92b432139da587c85648ac96dc31ed8c4b5d7b97 (diff) |
zpool should detect invalid fs property on create
This change improve the handling of invalid filesystem properties when
specified at pool creation: this is useful when 'zpool create -n'
(dry run) is executed to detect invalid fs-level options (-O) before
the actual command is run.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: loli10K <[email protected]>
Closes #7620
Closes #7878
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zpool/zpool_main.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 37124566e..818b665ae 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -536,7 +536,6 @@ add_prop_list(const char *propname, char *propval, nvlist_t **props, boolean_t poolprop) { zpool_prop_t prop = ZPOOL_PROP_INVAL; - zfs_prop_t fprop; nvlist_t *proplist; const char *normnm; char *strval; @@ -580,10 +579,18 @@ add_prop_list(const char *propname, char *propval, nvlist_t **props, else normnm = zpool_prop_to_name(prop); } else { - if ((fprop = zfs_name_to_prop(propname)) != ZPROP_INVAL) { - normnm = zfs_prop_to_name(fprop); - } else { + zfs_prop_t fsprop = zfs_name_to_prop(propname); + + if (zfs_prop_valid_for_type(fsprop, ZFS_TYPE_FILESYSTEM, + B_FALSE)) { + normnm = zfs_prop_to_name(fsprop); + } else if (zfs_prop_user(propname) || + zfs_prop_userquota(propname)) { normnm = propname; + } else { + (void) fprintf(stderr, gettext("property '%s' is " + "not a valid filesystem property\n"), propname); + return (2); } } |