FreeBSD/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
/*
 * Generic callback function to list a dataset or snapshot.
 */
Generic callback function to list a dataset or snapshot.
Generic callback function to list a dataset or snapshot .
static int
holds_callback(zfs_handle_t *zhp, void *data)
{
	holds_cbdata_t *cbp = data;
	nvlist_t *top_nvl = *cbp->cb_nvlp;
	nvlist_t *nvl = NULL;
	nvpair_t *nvp = NULL;
	const char *zname = zfs_get_name(zhp);
	size_t znamelen = strnlen(zname, ZFS_MAXNAMELEN);
	if (cbp->cb_recursive && cbp->cb_snapname != NULL) {
		const char *snapname;
		char *delim  = strchr(zname, '@');
		if (delim == NULL)
			return (0);
		snapname = delim + 1;
		if (strcmp(cbp->cb_snapname, snapname))
			return (0);
	}
	if (zfs_get_holds(zhp, &nvl) != 0)
		return (-1);
	if (znamelen > cbp->cb_max_namelen)
		cbp->cb_max_namelen  = znamelen;
	while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL) {
		const char *tag = nvpair_name(nvp);
		size_t taglen = strnlen(tag, MAXNAMELEN);
		if (taglen > cbp->cb_max_taglen)
			cbp->cb_max_taglen  = taglen;
	}
	return (nvlist_add_nvlist(top_nvl, zname, nvl));
}
static int holds_callback ( zfs_handle_t * zhp , void * data ) { holds_cbdata_t * cbp = data ; nvlist_t * top_nvl = * cbp -> cb_nvlp ; nvlist_t * nvl = NULL ; nvpair_t * nvp = NULL ; const char * zname = zfs_get_name ( zhp ) ; size_t znamelen = strnlen ( zname , ZFS_MAXNAMELEN ) ; if ( cbp -> cb_recursive && cbp -> cb_snapname != NULL ) { const char * snapname ; char * delim = strchr ( zname , ' ' ) ; if ( delim == NULL ) return ( 0 ) ; snapname = delim + 1 ; if ( strcmp ( cbp -> cb_snapname , snapname ) ) return ( 0 ) ; } if ( zfs_get_holds ( zhp , & nvl ) != 0 ) return ( -1 ) ; if ( znamelen > cbp -> cb_max_namelen ) cbp -> cb_max_namelen = znamelen ; while ( ( nvp = nvlist_next_nvpair ( nvl , nvp ) ) != NULL ) { const char * tag = nvpair_name ( nvp ) ; size_t taglen = strnlen ( tag , MAXNAMELEN ) ; if ( taglen > cbp -> cb_max_taglen ) cbp -> cb_max_taglen = taglen ; } return ( nvlist_add_nvlist ( top_nvl , zname , nvl ) ) ; }
Generic callback function to list a dataset or snapshot.
Generic callback function to list a dataset or snapshot .