FreeBSD/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
/*
 * Given a dataset and a list of fields, print out all the properties according
 * to the described layout.
 */
Given a dataset and a list of fields, print out all the properties according
to the described layout.
Given a dataset and a list of fields print out all the properties according to the described layout .
static void
print_dataset(zfs_handle_t *zhp, list_cbdata_t *cb)
{
	zprop_list_t *pl = cb->cb_proplist;
	boolean_t first = B_TRUE;
	char property[ZFS_MAXPROPLEN];
	nvlist_t *userprops = zfs_get_user_props(zhp);
	nvlist_t *propval;
	char *propstr;
	boolean_t right_justify;
	for (; pl != NULL; pl = pl->pl_next) {
		if (!first) {
			if (cb->cb_scripted)
				(void) printf("\t");
			else
				(void) printf("  ");
		} else {
			first = B_FALSE;
		}
		if (pl->pl_prop == ZFS_PROP_NAME) {
			(void) strlcpy(property, zfs_get_name(zhp),
			    sizeof(property));
			propstr = property;
			right_justify = zfs_prop_align_right(pl->pl_prop);
		} else if (pl->pl_prop != ZPROP_INVAL) {
			if (zfs_prop_get(zhp, pl->pl_prop, property,
			    sizeof (property), NULL, NULL, 0,
			    cb->cb_literal) != 0)
				propstr = "-";
			else
				propstr = property;
			right_justify = zfs_prop_align_right(pl->pl_prop);
		} else if (zfs_prop_userquota(pl->pl_user_prop)) {
			if (zfs_prop_get_userquota(zhp, pl->pl_user_prop,
			    property, sizeof (property), cb->cb_literal) != 0)
				propstr = "-";
			else
				propstr = property;
			right_justify = B_TRUE;
		} else if (zfs_prop_written(pl->pl_user_prop)) {
			if (zfs_prop_get_written(zhp, pl->pl_user_prop,
			    property, sizeof (property), cb->cb_literal) != 0)
				propstr = "-";
			else
				propstr = property;
			right_justify = B_TRUE;
		} else {
			if (nvlist_lookup_nvlist(userprops,
			    pl->pl_user_prop, &propval) != 0)
				propstr = "-";
			else
				verify(nvlist_lookup_string(propval,
				    ZPROP_VALUE, &propstr) == 0);
			right_justify = B_FALSE;
		}
		if (cb->cb_scripted || (pl->pl_next == NULL && !right_justify))
			(void) printf("%s", propstr);
		else if (right_justify)
			(void) printf("%*s", pl->pl_width, propstr);
		else
			(void) printf("%-*s", pl->pl_width, propstr);
	}
	(void) printf("\n");
}
static void print_dataset ( zfs_handle_t * zhp , list_cbdata_t * cb ) { zprop_list_t * pl = cb -> cb_proplist ; boolean_t first = B_TRUE ; char property [ ZFS_MAXPROPLEN ] ; nvlist_t * userprops = zfs_get_user_props ( zhp ) ; nvlist_t * propval ; char * propstr ; boolean_t right_justify ; for ( ; pl != NULL ; pl = pl -> pl_next ) { if ( ! first ) { if ( cb -> cb_scripted ) ( void ) printf ( " \t " ) ; else ( void ) printf ( " " ) ; } else { first = B_FALSE ; } if ( pl -> pl_prop == ZFS_PROP_NAME ) { ( void ) strlcpy ( property , zfs_get_name ( zhp ) , sizeof ( property ) ) ; propstr = property ; right_justify = zfs_prop_align_right ( pl -> pl_prop ) ; } else if ( pl -> pl_prop != ZPROP_INVAL ) { if ( zfs_prop_get ( zhp , pl -> pl_prop , property , sizeof ( property ) , NULL , NULL , 0 , cb -> cb_literal ) != 0 ) propstr = " " ; else propstr = property ; right_justify = zfs_prop_align_right ( pl -> pl_prop ) ; } else if ( zfs_prop_userquota ( pl -> pl_user_prop ) ) { if ( zfs_prop_get_userquota ( zhp , pl -> pl_user_prop , property , sizeof ( property ) , cb -> cb_literal ) != 0 ) propstr = " " ; else propstr = property ; right_justify = B_TRUE ; } else if ( zfs_prop_written ( pl -> pl_user_prop ) ) { if ( zfs_prop_get_written ( zhp , pl -> pl_user_prop , property , sizeof ( property ) , cb -> cb_literal ) != 0 ) propstr = " " ; else propstr = property ; right_justify = B_TRUE ; } else { if ( nvlist_lookup_nvlist ( userprops , pl -> pl_user_prop , & propval ) != 0 ) propstr = " " ; else verify ( nvlist_lookup_string ( propval , ZPROP_VALUE , & propstr ) == 0 ) ; right_justify = B_FALSE ; } if ( cb -> cb_scripted || ( pl -> pl_next == NULL && ! right_justify ) ) ( void ) printf ( " " , propstr ) ; else if ( right_justify ) ( void ) printf ( " " , pl -> pl_width , propstr ) ; else ( void ) printf ( " " , pl -> pl_width , propstr ) ; } ( void ) printf ( " \n " ) ; }
Given a dataset and a list of fields, print out all the properties according
 to the described layout.
Given a dataset and a list of fields print out all the properties according to the described layout .
/*
		 * If this is being called in scripted mode, or if this is the
		 * last column and it is left-justified, don't include a width
		 * format specifier.
		 */