1358 free(top); |
1358 free(top); |
1359 |
1359 |
1360 return (nvroot); |
1360 return (nvroot); |
1361 } |
1361 } |
1362 |
1362 |
|
1363 nvlist_t * |
|
1364 split_mirror_vdev(zpool_handle_t *zhp, char *newname, nvlist_t *props, |
|
1365 splitflags_t flags, int argc, char **argv) |
|
1366 { |
|
1367 nvlist_t *newroot = NULL, **child; |
|
1368 uint_t c, children; |
|
1369 |
|
1370 if (argc > 0) { |
|
1371 if ((newroot = construct_spec(argc, argv)) == NULL) { |
|
1372 (void) fprintf(stderr, gettext("Unable to build a " |
|
1373 "pool from the specified devices\n")); |
|
1374 return (NULL); |
|
1375 } |
|
1376 |
|
1377 if (!flags.dryrun && make_disks(zhp, newroot) != 0) { |
|
1378 nvlist_free(newroot); |
|
1379 return (NULL); |
|
1380 } |
|
1381 |
|
1382 /* avoid any tricks in the spec */ |
|
1383 verify(nvlist_lookup_nvlist_array(newroot, |
|
1384 ZPOOL_CONFIG_CHILDREN, &child, &children) == 0); |
|
1385 for (c = 0; c < children; c++) { |
|
1386 char *path; |
|
1387 const char *type; |
|
1388 int min, max; |
|
1389 |
|
1390 verify(nvlist_lookup_string(child[c], |
|
1391 ZPOOL_CONFIG_PATH, &path) == 0); |
|
1392 if ((type = is_grouping(path, &min, &max)) != NULL) { |
|
1393 (void) fprintf(stderr, gettext("Cannot use " |
|
1394 "'%s' as a device for splitting\n"), type); |
|
1395 nvlist_free(newroot); |
|
1396 return (NULL); |
|
1397 } |
|
1398 } |
|
1399 } |
|
1400 |
|
1401 if (zpool_vdev_split(zhp, newname, &newroot, props, flags) != 0) { |
|
1402 if (newroot != NULL) |
|
1403 nvlist_free(newroot); |
|
1404 return (NULL); |
|
1405 } |
|
1406 |
|
1407 return (newroot); |
|
1408 } |
1363 |
1409 |
1364 /* |
1410 /* |
1365 * Get and validate the contents of the given vdev specification. This ensures |
1411 * Get and validate the contents of the given vdev specification. This ensures |
1366 * that the nvlist returned is well-formed, that all the devices exist, and that |
1412 * that the nvlist returned is well-formed, that all the devices exist, and that |
1367 * they are not currently in use by any other known consumer. The 'poolconfig' |
1413 * they are not currently in use by any other known consumer. The 'poolconfig' |