equal
deleted
inserted
replaced
20 */ |
20 */ |
21 |
21 |
22 /* |
22 /* |
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. |
24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. |
25 * Copyright (c) 2011 by Delphix. All rights reserved. |
25 * Copyright (c) 2012 by Delphix. All rights reserved. |
26 */ |
26 */ |
27 |
27 |
28 #include <ctype.h> |
28 #include <ctype.h> |
29 #include <errno.h> |
29 #include <errno.h> |
30 #include <devid.h> |
30 #include <devid.h> |
271 |
271 |
272 switch (prop) { |
272 switch (prop) { |
273 case ZPOOL_PROP_SIZE: |
273 case ZPOOL_PROP_SIZE: |
274 case ZPOOL_PROP_ALLOCATED: |
274 case ZPOOL_PROP_ALLOCATED: |
275 case ZPOOL_PROP_FREE: |
275 case ZPOOL_PROP_FREE: |
|
276 case ZPOOL_PROP_EXPANDSZ: |
276 (void) zfs_nicenum(intval, buf, len); |
277 (void) zfs_nicenum(intval, buf, len); |
277 break; |
278 break; |
278 |
279 |
279 case ZPOOL_PROP_CAPACITY: |
280 case ZPOOL_PROP_CAPACITY: |
280 (void) snprintf(buf, len, "%llu%%", |
281 (void) snprintf(buf, len, "%llu%%", |
358 return (B_TRUE); |
359 return (B_TRUE); |
359 } |
360 } |
360 return (B_FALSE); |
361 return (B_FALSE); |
361 } |
362 } |
362 |
363 |
363 static boolean_t |
364 boolean_t |
364 pool_is_bootable(zpool_handle_t *zhp) |
365 zpool_is_bootable(zpool_handle_t *zhp) |
365 { |
366 { |
366 char bootfs[ZPOOL_MAXNAMELEN]; |
367 char bootfs[ZPOOL_MAXNAMELEN]; |
367 |
368 |
368 return (zpool_get_prop(zhp, ZPOOL_PROP_BOOTFS, bootfs, |
369 return (zpool_get_prop(zhp, ZPOOL_PROP_BOOTFS, bootfs, |
369 sizeof (bootfs), NULL) == 0 && strncmp(bootfs, "-", |
370 sizeof (bootfs), NULL) == 0 && strncmp(bootfs, "-", |
1092 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool must be " |
1093 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool must be " |
1093 "upgraded to add hot spares")); |
1094 "upgraded to add hot spares")); |
1094 return (zfs_error(hdl, EZFS_BADVERSION, msg)); |
1095 return (zfs_error(hdl, EZFS_BADVERSION, msg)); |
1095 } |
1096 } |
1096 |
1097 |
1097 if (pool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot, |
1098 if (zpool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot, |
1098 ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0) { |
1099 ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0) { |
1099 uint64_t s; |
1100 uint64_t s; |
1100 |
1101 |
1101 for (s = 0; s < nspares; s++) { |
1102 for (s = 0; s < nspares; s++) { |
1102 char *path; |
1103 char *path; |
2376 char *newname; |
2377 char *newname; |
2377 nvlist_t **child; |
2378 nvlist_t **child; |
2378 uint_t children; |
2379 uint_t children; |
2379 nvlist_t *config_root; |
2380 nvlist_t *config_root; |
2380 libzfs_handle_t *hdl = zhp->zpool_hdl; |
2381 libzfs_handle_t *hdl = zhp->zpool_hdl; |
2381 boolean_t rootpool = pool_is_bootable(zhp); |
2382 boolean_t rootpool = zpool_is_bootable(zhp); |
2382 |
2383 |
2383 if (replacing) |
2384 if (replacing) |
2384 (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, |
2385 (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, |
2385 "cannot replace %s with %s"), old_disk, new_disk); |
2386 "cannot replace %s with %s"), old_disk, new_disk); |
2386 else |
2387 else |
3004 |
3005 |
3005 (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); |
3006 (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); |
3006 if (zfs_ioctl(hdl, ZFS_IOC_POOL_REGUID, &zc) == 0) |
3007 if (zfs_ioctl(hdl, ZFS_IOC_POOL_REGUID, &zc) == 0) |
3007 return (0); |
3008 return (0); |
3008 |
3009 |
|
3010 return (zpool_standard_error(hdl, errno, msg)); |
|
3011 } |
|
3012 |
|
3013 /* |
|
3014 * Reopen the pool. |
|
3015 */ |
|
3016 int |
|
3017 zpool_reopen(zpool_handle_t *zhp) |
|
3018 { |
|
3019 zfs_cmd_t zc = { 0 }; |
|
3020 char msg[1024]; |
|
3021 libzfs_handle_t *hdl = zhp->zpool_hdl; |
|
3022 |
|
3023 (void) snprintf(msg, sizeof (msg), |
|
3024 dgettext(TEXT_DOMAIN, "cannot reopen '%s'"), |
|
3025 zhp->zpool_name); |
|
3026 |
|
3027 (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); |
|
3028 if (zfs_ioctl(hdl, ZFS_IOC_POOL_REOPEN, &zc) == 0) |
|
3029 return (0); |
3009 return (zpool_standard_error(hdl, errno, msg)); |
3030 return (zpool_standard_error(hdl, errno, msg)); |
3010 } |
3031 } |
3011 |
3032 |
3012 /* |
3033 /* |
3013 * Convert from a devid string to a path. |
3034 * Convert from a devid string to a path. |
3640 dgettext(TEXT_DOMAIN, "cannot label '%s'"), name); |
3661 dgettext(TEXT_DOMAIN, "cannot label '%s'"), name); |
3641 |
3662 |
3642 if (zhp) { |
3663 if (zhp) { |
3643 nvlist_t *nvroot; |
3664 nvlist_t *nvroot; |
3644 |
3665 |
3645 if (pool_is_bootable(zhp)) { |
3666 if (zpool_is_bootable(zhp)) { |
3646 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, |
3667 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, |
3647 "EFI labeled devices are not supported on root " |
3668 "EFI labeled devices are not supported on root " |
3648 "pools.")); |
3669 "pools.")); |
3649 return (zfs_error(hdl, EZFS_POOL_NOTSUP, errbuf)); |
3670 return (zfs_error(hdl, EZFS_POOL_NOTSUP, errbuf)); |
3650 } |
3671 } |