944 goto error;
945 }
946
947 if (!zfs_prop_valid_for_type(prop, type)) {
948 zfs_error_aux(hdl,
949 dgettext(TEXT_DOMAIN, "'%s' does not "
950 "apply to datasets of this type"), propname);
951 (void) zfs_error(hdl, EZFS_PROPTYPE, errbuf);
952 goto error;
953 }
954
955 if (zfs_prop_readonly(prop) &&
956 (!zfs_prop_setonce(prop) || zhp != NULL)) {
957 zfs_error_aux(hdl,
958 dgettext(TEXT_DOMAIN, "'%s' is readonly"),
959 propname);
960 (void) zfs_error(hdl, EZFS_PROPREADONLY, errbuf);
961 goto error;
962 }
963
964 if (zprop_parse_value(hdl, elem, prop, type, ret,
965 &strval, &intval, errbuf) != 0)
966 goto error;
967
968 /*
969 * Perform some additional checks for specific properties.
970 */
971 switch (prop) {
972 case ZFS_PROP_VERSION:
973 {
974 int version;
975
976 if (zhp == NULL)
977 break;
978 version = zfs_prop_get_int(zhp, ZFS_PROP_VERSION);
979 if (intval < version) {
980 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
981 "Can not downgrade; already at version %u"),
982 version);
983 (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
2198 return (-1);
2199
2200 /*
2201 * If quota or reservation is 0, we translate this into 'none'
2202 * (unless literal is set), and indicate that it's the default
2203 * value. Otherwise, we print the number nicely and indicate
2204 * that its set locally.
2205 */
2206 if (val == 0) {
2207 if (literal)
2208 (void) strlcpy(propbuf, "0", proplen);
2209 else
2210 (void) strlcpy(propbuf, "none", proplen);
2211 } else {
2212 if (literal)
2213 (void) snprintf(propbuf, proplen, "%llu",
2214 (u_longlong_t)val);
2215 else
2216 zfs_nicenum(val, propbuf, proplen);
2217 }
2218 break;
2219
2220 case ZFS_PROP_REFRATIO:
2221 case ZFS_PROP_COMPRESSRATIO:
2222 if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
2223 return (-1);
2224 (void) snprintf(propbuf, proplen, "%llu.%02llux",
2225 (u_longlong_t)(val / 100),
2226 (u_longlong_t)(val % 100));
2227 break;
2228
2229 case ZFS_PROP_TYPE:
2230 switch (zhp->zfs_type) {
2231 case ZFS_TYPE_FILESYSTEM:
2232 str = "filesystem";
2233 break;
2234 case ZFS_TYPE_VOLUME:
2235 str = "volume";
2236 break;
2237 case ZFS_TYPE_SNAPSHOT:
|
944 goto error;
945 }
946
947 if (!zfs_prop_valid_for_type(prop, type)) {
948 zfs_error_aux(hdl,
949 dgettext(TEXT_DOMAIN, "'%s' does not "
950 "apply to datasets of this type"), propname);
951 (void) zfs_error(hdl, EZFS_PROPTYPE, errbuf);
952 goto error;
953 }
954
955 if (zfs_prop_readonly(prop) &&
956 (!zfs_prop_setonce(prop) || zhp != NULL)) {
957 zfs_error_aux(hdl,
958 dgettext(TEXT_DOMAIN, "'%s' is readonly"),
959 propname);
960 (void) zfs_error(hdl, EZFS_PROPREADONLY, errbuf);
961 goto error;
962 }
963
964 /*
965 * Special handling for "xxx_limit=none". In this case its not
966 * 0 but MAXLIMIT.
967 */
968 if ((prop == ZFS_PROP_FILESYSTEM_LIMIT ||
969 prop == ZFS_PROP_SNAPSHOT_LIMIT) &&
970 nvpair_type(elem) == DATA_TYPE_STRING) {
971 (void) nvpair_value_string(elem, &strval);
972 if (strcmp(strval, "none") == 0) {
973 if (nvlist_add_uint64(ret, propname,
974 MAXLIMIT) != 0) {
975 (void) no_memory(hdl);
976 goto error;
977 }
978 continue;
979 }
980 }
981
982 if (zprop_parse_value(hdl, elem, prop, type, ret,
983 &strval, &intval, errbuf) != 0)
984 goto error;
985
986 /*
987 * Perform some additional checks for specific properties.
988 */
989 switch (prop) {
990 case ZFS_PROP_VERSION:
991 {
992 int version;
993
994 if (zhp == NULL)
995 break;
996 version = zfs_prop_get_int(zhp, ZFS_PROP_VERSION);
997 if (intval < version) {
998 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
999 "Can not downgrade; already at version %u"),
1000 version);
1001 (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
2216 return (-1);
2217
2218 /*
2219 * If quota or reservation is 0, we translate this into 'none'
2220 * (unless literal is set), and indicate that it's the default
2221 * value. Otherwise, we print the number nicely and indicate
2222 * that its set locally.
2223 */
2224 if (val == 0) {
2225 if (literal)
2226 (void) strlcpy(propbuf, "0", proplen);
2227 else
2228 (void) strlcpy(propbuf, "none", proplen);
2229 } else {
2230 if (literal)
2231 (void) snprintf(propbuf, proplen, "%llu",
2232 (u_longlong_t)val);
2233 else
2234 zfs_nicenum(val, propbuf, proplen);
2235 }
2236 break;
2237
2238 case ZFS_PROP_FILESYSTEM_LIMIT:
2239 case ZFS_PROP_SNAPSHOT_LIMIT:
2240
2241 if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
2242 return (-1);
2243
2244 /*
2245 * If limit is MAXLIMIT, we translate this into 'none' (unless
2246 * literal is set), and indicate that it's the default value.
2247 * Otherwise, we print the number nicely and indicate that its
2248 * set locally.
2249 */
2250 if (literal) {
2251 (void) snprintf(propbuf, proplen, "%llu",
2252 (u_longlong_t)val);
2253 } else if (val == MAXLIMIT) {
2254 (void) strlcpy(propbuf, "none", proplen);
2255 } else {
2256 zfs_nicenum(val, propbuf, proplen);
2257 }
2258 break;
2259
2260 case ZFS_PROP_REFRATIO:
2261 case ZFS_PROP_COMPRESSRATIO:
2262 if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
2263 return (-1);
2264 (void) snprintf(propbuf, proplen, "%llu.%02llux",
2265 (u_longlong_t)(val / 100),
2266 (u_longlong_t)(val % 100));
2267 break;
2268
2269 case ZFS_PROP_TYPE:
2270 switch (zhp->zfs_type) {
2271 case ZFS_TYPE_FILESYSTEM:
2272 str = "filesystem";
2273 break;
2274 case ZFS_TYPE_VOLUME:
2275 str = "volume";
2276 break;
2277 case ZFS_TYPE_SNAPSHOT:
|