libzfs_util.c (332547) | libzfs_util.c (339103) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 7 unchanged lines hidden (view full) --- 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 7 unchanged lines hidden (view full) --- 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
24 * Copyright (c) 2013, Joyent, Inc. All rights reserved. | 24 * Copyright (c) 2018 Joyent, Inc. |
25 * Copyright (c) 2011, 2017 by Delphix. All rights reserved. 26 * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com> 27 * Copyright (c) 2017 Datto Inc. 28 */ 29 30/* 31 * Internal utility routines for the ZFS library. 32 */ --- 1189 unchanged lines hidden (view full) --- 1222 zfs_type_t type, nvlist_t *ret, char **svalp, uint64_t *ivalp, 1223 const char *errbuf) 1224{ 1225 data_type_t datatype = nvpair_type(elem); 1226 zprop_type_t proptype; 1227 const char *propname; 1228 char *value; 1229 boolean_t isnone = B_FALSE; | 25 * Copyright (c) 2011, 2017 by Delphix. All rights reserved. 26 * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com> 27 * Copyright (c) 2017 Datto Inc. 28 */ 29 30/* 31 * Internal utility routines for the ZFS library. 32 */ --- 1189 unchanged lines hidden (view full) --- 1222 zfs_type_t type, nvlist_t *ret, char **svalp, uint64_t *ivalp, 1223 const char *errbuf) 1224{ 1225 data_type_t datatype = nvpair_type(elem); 1226 zprop_type_t proptype; 1227 const char *propname; 1228 char *value; 1229 boolean_t isnone = B_FALSE; |
1230 boolean_t isauto = B_FALSE; |
|
1230 1231 if (type == ZFS_TYPE_POOL) { 1232 proptype = zpool_prop_get_type(prop); 1233 propname = zpool_prop_to_name(prop); 1234 } else { 1235 proptype = zfs_prop_get_type(prop); 1236 propname = zfs_prop_to_name(prop); 1237 } --- 19 unchanged lines hidden (view full) --- 1257 } 1258 break; 1259 1260 case PROP_TYPE_NUMBER: 1261 if (datatype == DATA_TYPE_STRING) { 1262 (void) nvpair_value_string(elem, &value); 1263 if (strcmp(value, "none") == 0) { 1264 isnone = B_TRUE; | 1231 1232 if (type == ZFS_TYPE_POOL) { 1233 proptype = zpool_prop_get_type(prop); 1234 propname = zpool_prop_to_name(prop); 1235 } else { 1236 proptype = zfs_prop_get_type(prop); 1237 propname = zfs_prop_to_name(prop); 1238 } --- 19 unchanged lines hidden (view full) --- 1258 } 1259 break; 1260 1261 case PROP_TYPE_NUMBER: 1262 if (datatype == DATA_TYPE_STRING) { 1263 (void) nvpair_value_string(elem, &value); 1264 if (strcmp(value, "none") == 0) { 1265 isnone = B_TRUE; |
1265 } else if (zfs_nicestrtonum(hdl, value, ivalp) 1266 != 0) { | 1266 } else if (strcmp(value, "auto") == 0) { 1267 isauto = B_TRUE; 1268 } else if (zfs_nicestrtonum(hdl, value, ivalp) != 0) { |
1267 goto error; 1268 } 1269 } else if (datatype == DATA_TYPE_UINT64) { 1270 (void) nvpair_value_uint64(elem, ivalp); 1271 } else { 1272 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 1273 "'%s' must be a number"), nvpair_name(elem)); 1274 goto error; --- 13 unchanged lines hidden (view full) --- 1288 * Special handling for "*_limit=none". In this case it's not 1289 * 0 but UINT64_MAX. 1290 */ 1291 if ((type & ZFS_TYPE_DATASET) && isnone && 1292 (prop == ZFS_PROP_FILESYSTEM_LIMIT || 1293 prop == ZFS_PROP_SNAPSHOT_LIMIT)) { 1294 *ivalp = UINT64_MAX; 1295 } | 1269 goto error; 1270 } 1271 } else if (datatype == DATA_TYPE_UINT64) { 1272 (void) nvpair_value_uint64(elem, ivalp); 1273 } else { 1274 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 1275 "'%s' must be a number"), nvpair_name(elem)); 1276 goto error; --- 13 unchanged lines hidden (view full) --- 1290 * Special handling for "*_limit=none". In this case it's not 1291 * 0 but UINT64_MAX. 1292 */ 1293 if ((type & ZFS_TYPE_DATASET) && isnone && 1294 (prop == ZFS_PROP_FILESYSTEM_LIMIT || 1295 prop == ZFS_PROP_SNAPSHOT_LIMIT)) { 1296 *ivalp = UINT64_MAX; 1297 } |
1298 1299 /* 1300 * Special handling for setting 'refreservation' to 'auto'. Use 1301 * UINT64_MAX to tell the caller to use zfs_fix_auto_resv(). 1302 * 'auto' is only allowed on volumes. 1303 */ 1304 if (isauto) { 1305 switch (prop) { 1306 case ZFS_PROP_REFRESERVATION: 1307 if ((type & ZFS_TYPE_VOLUME) == 0) { 1308 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 1309 "'%s=auto' only allowed on " 1310 "volumes"), nvpair_name(elem)); 1311 goto error; 1312 } 1313 *ivalp = UINT64_MAX; 1314 break; 1315 default: 1316 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 1317 "'auto' is invalid value for '%s'"), 1318 nvpair_name(elem)); 1319 goto error; 1320 } 1321 } 1322 |
|
1296 break; 1297 1298 case PROP_TYPE_INDEX: 1299 if (datatype != DATA_TYPE_STRING) { 1300 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 1301 "'%s' must be a string"), nvpair_name(elem)); 1302 goto error; 1303 } --- 257 unchanged lines hidden --- | 1323 break; 1324 1325 case PROP_TYPE_INDEX: 1326 if (datatype != DATA_TYPE_STRING) { 1327 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 1328 "'%s' must be a string"), nvpair_name(elem)); 1329 goto error; 1330 } --- 257 unchanged lines hidden --- |