usr/src/cmd/zpool/zpool_vdev.c
changeset 11422 42768837421d
parent 10105 17811c723fb4
child 12296 7cf402a7f374
equal deleted inserted replaced
11421:fa146423142c 11422:42768837421d
    18  *
    18  *
    19  * CDDL HEADER END
    19  * CDDL HEADER END
    20  */
    20  */
    21 
    21 
    22 /*
    22 /*
    23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
    23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
    24  * Use is subject to license terms.
    24  * Use is subject to license terms.
    25  */
    25  */
    26 
    26 
    27 /*
    27 /*
    28  * Functions to convert between a list of vdevs and an nvlist representing the
    28  * Functions to convert between a list of vdevs and an nvlist representing the
  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'