]> granicus.if.org Git - zfs/commitdiff
Enforce PROP_ONETIME on zpool properties
authorChunwei Chen <david.chen@osnexus.com>
Mon, 14 Aug 2017 21:28:43 +0000 (14:28 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 28 Jun 2018 21:49:17 +0000 (14:49 -0700)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes #7661

include/sys/fs/zfs.h
lib/libzfs/libzfs_pool.c
module/zcommon/zpool_prop.c

index 0ee9b00bd98d93fbd348aad888bdd03b0a90bbd0..76e61eb0762084c328eef5c4ffab92429b9054b7 100644 (file)
@@ -320,6 +320,7 @@ const char *zpool_prop_to_name(zpool_prop_t);
 const char *zpool_prop_default_string(zpool_prop_t);
 uint64_t zpool_prop_default_numeric(zpool_prop_t);
 boolean_t zpool_prop_readonly(zpool_prop_t);
+boolean_t zpool_prop_setonce(zpool_prop_t);
 boolean_t zpool_prop_feature(const char *);
 boolean_t zpool_prop_unsupported(const char *);
 int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
index e8c0cdfe4e386f4114bf5a4ab6a64385db7ad6e2..8f2eedec8003dd790a8900cc7b264bf7a828c002 100644 (file)
@@ -549,6 +549,14 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
                        goto error;
                }
 
+               if (!flags.create && zpool_prop_setonce(prop)) {
+                       zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+                           "property '%s' can only be set at "
+                           "creation time"), propname);
+                       (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
+                       goto error;
+               }
+
                if (zprop_parse_value(hdl, elem, prop, ZFS_TYPE_POOL, retprops,
                    &strval, &intval, errbuf) != 0)
                        goto error;
@@ -704,15 +712,6 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
                                goto error;
                        }
                        break;
-               case ZPOOL_PROP_TNAME:
-                       if (!flags.create) {
-                               zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
-                                   "property '%s' can only be set at "
-                                   "creation time"), propname);
-                               (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
-                               goto error;
-                       }
-                       break;
                case ZPOOL_PROP_MULTIHOST:
                        if (get_system_hostid() == 0) {
                                zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
index dc0bb59bc8da193d4c965e7037f3221d4445c952..263d043cc6157e1e63d282cb09b7202b786b2a3a 100644 (file)
@@ -171,6 +171,12 @@ zpool_prop_readonly(zpool_prop_t prop)
        return (zpool_prop_table[prop].pd_attr == PROP_READONLY);
 }
 
+boolean_t
+zpool_prop_setonce(zpool_prop_t prop)
+{
+       return (zpool_prop_table[prop].pd_attr == PROP_ONETIME);
+}
+
 const char *
 zpool_prop_default_string(zpool_prop_t prop)
 {