FreeBSD/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
/*
 * Add a property pair (name, string-value) into a property nvlist.
 */
Add a property pair (name, string-value) into a property nvlist.
Add a property pair ( name string - value ) into a property nvlist .
static int
add_prop_list(const char *propname, char *propval, nvlist_t **props,
    boolean_t poolprop)
{
	zpool_prop_t prop = ZPROP_INVAL;
	zfs_prop_t fprop;
	nvlist_t *proplist;
	const char *normnm;
	char *strval;
	if (*props == NULL &&
	    nvlist_alloc(props, NV_UNIQUE_NAME, 0) != 0) {
		(void) fprintf(stderr,
		    gettext("internal error: out of memory\n"));
		return (1);
	}
	proplist = *props;
	if (poolprop) {
		const char *vname = zpool_prop_to_name(ZPOOL_PROP_VERSION);
		if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL &&
		    !zpool_prop_feature(propname)) {
			(void) fprintf(stderr, gettext("property '%s' is "
			    "not a valid pool property\n"), propname);
			return (2);
		}
		if ((prop == ZPROP_INVAL && zpool_prop_feature(propname) &&
		    nvlist_exists(proplist, vname)) ||
		    (prop == ZPOOL_PROP_VERSION &&
		    prop_list_contains_feature(proplist))) {
			(void) fprintf(stderr, gettext("'feature@' and "
			    "'version' properties cannot be specified "
			    "together\n"));
			return (2);
		}
		if (zpool_prop_feature(propname))
			normnm = propname;
		else
			normnm = zpool_prop_to_name(prop);
	} else {
		if ((fprop = zfs_name_to_prop(propname)) != ZPROP_INVAL) {
			normnm = zfs_prop_to_name(fprop);
		} else {
			normnm = propname;
		}
	}
	if (nvlist_lookup_string(proplist, normnm, &strval) == 0 &&
	    prop != ZPOOL_PROP_CACHEFILE) {
		(void) fprintf(stderr, gettext("property '%s' "
		    "specified multiple times\n"), propname);
		return (2);
	}
	if (nvlist_add_string(proplist, normnm, propval) != 0) {
		(void) fprintf(stderr, gettext("internal "
		    "error: out of memory\n"));
		return (1);
	}
	return (0);
}
static int add_prop_list ( const char * propname , char * propval , nvlist_t * * props , boolean_t poolprop ) { zpool_prop_t prop = ZPROP_INVAL ; zfs_prop_t fprop ; nvlist_t * proplist ; const char * normnm ; char * strval ; if ( * props == NULL && nvlist_alloc ( props , NV_UNIQUE_NAME , 0 ) != 0 ) { ( void ) fprintf ( stderr , gettext ( " \n " ) ) ; return ( 1 ) ; } proplist = * props ; if ( poolprop ) { const char * vname = zpool_prop_to_name ( ZPOOL_PROP_VERSION ) ; if ( ( prop = zpool_name_to_prop ( propname ) ) == ZPROP_INVAL && ! zpool_prop_feature ( propname ) ) { ( void ) fprintf ( stderr , gettext ( " " " \n " ) , propname ) ; return ( 2 ) ; } if ( ( prop == ZPROP_INVAL && zpool_prop_feature ( propname ) && nvlist_exists ( proplist , vname ) ) || ( prop == ZPOOL_PROP_VERSION && prop_list_contains_feature ( proplist ) ) ) { ( void ) fprintf ( stderr , gettext ( " " " " " \n " ) ) ; return ( 2 ) ; } if ( zpool_prop_feature ( propname ) ) normnm = propname ; else normnm = zpool_prop_to_name ( prop ) ; } else { if ( ( fprop = zfs_name_to_prop ( propname ) ) != ZPROP_INVAL ) { normnm = zfs_prop_to_name ( fprop ) ; } else { normnm = propname ; } } if ( nvlist_lookup_string ( proplist , normnm , & strval ) == 0 && prop != ZPOOL_PROP_CACHEFILE ) { ( void ) fprintf ( stderr , gettext ( " " " \n " ) , propname ) ; return ( 2 ) ; } if ( nvlist_add_string ( proplist , normnm , propval ) != 0 ) { ( void ) fprintf ( stderr , gettext ( " " " \n " ) ) ; return ( 1 ) ; } return ( 0 ) ; }
Add a property pair (name, string-value) into a property nvlist.
Add a property pair ( name string - value ) into a property nvlist .
/*
		 * feature@ properties and version should not be specified
		 * at the same time.
		 */