FreeBSD/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
/*
 * Validate a device, passing the bulk of the work off to libdiskmgt.
 */
Validate a device, passing the bulk of the work off to libdiskmgt.
Validate a device passing the bulk of the work off to libdiskmgt .
static int
check_slice(const char *path, int force, boolean_t wholedisk, boolean_t isspare)
{
	char *msg;
	int error = 0;
	dm_who_type_t who;
	if (force)
		who = DM_WHO_ZPOOL_FORCE;
	else if (isspare)
		who = DM_WHO_ZPOOL_SPARE;
	else
		who = DM_WHO_ZPOOL;
	if (dm_inuse((char *)path, &msg, who, &error) || error) {
		if (error != 0) {
			libdiskmgt_error(error);
			return (0);
		} else {
			vdev_error("%s", msg);
			free(msg);
			return (-1);
		}
	}
	error = 0;
	if (!wholedisk && !force &&
	    (dm_isoverlapping((char *)path, &msg, &error) || error)) {
		if (error == 0) {
			vdev_error(gettext("%s overlaps with %s\n"), path, msg);
			free(msg);
			return (-1);
		} else if (error != ENODEV) {
			libdiskmgt_error(error);
			return (0);
		}
	}
	return (0);
}
static int check_slice ( const char * path , int force , boolean_t wholedisk , boolean_t isspare ) { char * msg ; int error = 0 ; dm_who_type_t who ; if ( force ) who = DM_WHO_ZPOOL_FORCE ; else if ( isspare ) who = DM_WHO_ZPOOL_SPARE ; else who = DM_WHO_ZPOOL ; if ( dm_inuse ( ( char * ) path , & msg , who , & error ) || error ) { if ( error != 0 ) { libdiskmgt_error ( error ) ; return ( 0 ) ; } else { vdev_error ( " " , msg ) ; free ( msg ) ; return ( -1 ) ; } } error = 0 ; if ( ! wholedisk && ! force && ( dm_isoverlapping ( ( char * ) path , & msg , & error ) || error ) ) { if ( error == 0 ) { vdev_error ( gettext ( " \n " ) , path , msg ) ; free ( msg ) ; return ( -1 ) ; } else if ( error != ENODEV ) { libdiskmgt_error ( error ) ; return ( 0 ) ; } } return ( 0 ) ; }
Validate a device, passing the bulk of the work off to libdiskmgt.
Validate a device passing the bulk of the work off to libdiskmgt .
/*
	 * If we're given a whole disk, ignore overlapping slices since we're
	 * about to label it anyway.
	 */ /* dm_isoverlapping returned -1 */ /* libdiskmgt's devcache only handles physical drives */