您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ zfs_prop_get函数代码示例

51自学网 2021-06-03 11:59:31
  C++
这篇教程C++ zfs_prop_get函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中zfs_prop_get函数的典型用法代码示例。如果您正苦于以下问题:C++ zfs_prop_get函数的具体用法?C++ zfs_prop_get怎么用?C++ zfs_prop_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了zfs_prop_get函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: libzfs_dataset_cmp

intlibzfs_dataset_cmp(const void *a, const void *b){	zfs_handle_t **za = (zfs_handle_t **)a;	zfs_handle_t **zb = (zfs_handle_t **)b;	char mounta[MAXPATHLEN];	char mountb[MAXPATHLEN];	boolean_t gota, gotb;	if ((gota = (zfs_get_type(*za) == ZFS_TYPE_FILESYSTEM)) != 0)		verify(zfs_prop_get(*za, ZFS_PROP_MOUNTPOINT, mounta,		    sizeof (mounta), NULL, NULL, 0, B_FALSE) == 0);	if ((gotb = (zfs_get_type(*zb) == ZFS_TYPE_FILESYSTEM)) != 0)		verify(zfs_prop_get(*zb, ZFS_PROP_MOUNTPOINT, mountb,		    sizeof (mountb), NULL, NULL, 0, B_FALSE) == 0);	if (gota && gotb)		return (strcmp(mounta, mountb));	if (gota)		return (-1);	if (gotb)		return (1);	return (strcmp(zfs_get_name(a), zfs_get_name(b)));}
开发者ID:tommiatplayfish,项目名称:zfs-crypto,代码行数:26,


示例2: get_zfs_dataset

static char *get_zfs_dataset(sa_handle_impl_t impl_handle, char *path,    boolean_t search_mnttab){	size_t i, count = 0;	char *dataset = NULL;	zfs_handle_t **zlist;	char mountpoint[ZFS_MAXPROPLEN];	char canmount[ZFS_MAXPROPLEN];	get_all_filesystems(impl_handle, &zlist, &count);	qsort(zlist, count, sizeof (void *), mountpoint_compare);	for (i = 0; i < count; i++) {		/* must have a mountpoint */		if (zfs_prop_get(zlist[i], ZFS_PROP_MOUNTPOINT, mountpoint,		    sizeof (mountpoint), NULL, NULL, 0, B_FALSE) != 0) {			/* no mountpoint */			continue;		}		/* mountpoint must be a path */		if (strcmp(mountpoint, ZFS_MOUNTPOINT_NONE) == 0 ||		    strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) == 0) {			/*			 * Search mmttab for mountpoint and get dataset.			 */			if (search_mnttab == B_TRUE &&			    get_legacy_mountpoint(path, mountpoint,			    sizeof (mountpoint), NULL, 0) == 0) {				dataset = mountpoint;				break;			}			continue;		}		/* canmount must be set */		canmount[0] = '/0';		if (zfs_prop_get(zlist[i], ZFS_PROP_CANMOUNT, canmount,		    sizeof (canmount), NULL, NULL, 0, B_FALSE) != 0 ||		    strcmp(canmount, "off") == 0)			continue;		/*		 * have a mountable handle but want to skip those marked none		 * and legacy		 */		if (strcmp(mountpoint, path) == 0) {			dataset = (char *)zfs_get_name(zlist[i]);			break;		}	}	if (dataset != NULL)		dataset = strdup(dataset);	return (dataset);}
开发者ID:BjoKaSH,项目名称:ZCE-CDDL-FILES,代码行数:59,


示例3: update_zfs_shares_cb

static intupdate_zfs_shares_cb(zfs_handle_t *zhp, void *pcookie){	update_cookie_t *udata = (update_cookie_t *)pcookie;	char mountpoint[ZFS_MAXPROPLEN];	char shareopts[ZFS_MAXPROPLEN];	char *dataset;	zfs_type_t type = zfs_get_type(zhp);	if (type == ZFS_TYPE_FILESYSTEM &&	    zfs_iter_filesystems(zhp, update_zfs_shares_cb, pcookie) != 0) {		zfs_close(zhp);		return (1);	}	if (type != ZFS_TYPE_FILESYSTEM) {		zfs_close(zhp);		return (0);	}	if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint,	    sizeof (mountpoint), NULL, NULL, 0, B_FALSE) != 0) {		zfs_close(zhp);		return (0);	}	dataset = (char *)zfs_get_name(zhp);	if (dataset == NULL) {		zfs_close(zhp);		return (0);	}	if (!zfs_is_mounted(zhp, NULL)) {		zfs_close(zhp);		return (0);	}	if ((udata->proto == NULL || strcmp(udata->proto, "nfs") == 0) &&	    zfs_prop_get(zhp, ZFS_PROP_SHARENFS, shareopts,	    sizeof (shareopts), NULL, NULL, 0, B_FALSE) == 0 &&	    strcmp(shareopts, "off") != 0) {		(void) process_share(udata->handle, NULL, mountpoint, NULL,		    "nfs", shareopts, NULL, dataset, B_FALSE);	}	if ((udata->proto == NULL || strcmp(udata->proto, "smb") == 0) &&	    zfs_prop_get(zhp, ZFS_PROP_SHARESMB, shareopts,	    sizeof (shareopts), NULL, NULL, 0, B_FALSE) == 0 &&	    strcmp(shareopts, "off") != 0) {		(void) process_share(udata->handle, NULL, mountpoint, NULL,		    "smb", shareopts, NULL, dataset, B_FALSE);	}	zfs_close(zhp);	return (0);}
开发者ID:DeHackEd,项目名称:zfs,代码行数:58,


示例4: mountpoint_compare

static intmountpoint_compare(const void *a, const void *b){	zfs_handle_t **za = (zfs_handle_t **)a;	zfs_handle_t **zb = (zfs_handle_t **)b;	char mounta[MAXPATHLEN];	char mountb[MAXPATHLEN];	verify(zfs_prop_get(*za, ZFS_PROP_MOUNTPOINT, mounta,	    sizeof (mounta), NULL, NULL, 0, B_FALSE) == 0);	verify(zfs_prop_get(*zb, ZFS_PROP_MOUNTPOINT, mountb,	    sizeof (mountb), NULL, NULL, 0, B_FALSE) == 0);	return (strcmp(mounta, mountb));}
开发者ID:BjoKaSH,项目名称:ZCE-CDDL-FILES,代码行数:15,


示例5: zfs_is_mountable

/* * Returns true if the given dataset is mountable, false otherwise.  Returns the * mountpoint in 'buf'. */static boolean_tzfs_is_mountable(zfs_handle_t *zhp, char *buf, size_t buflen,    zprop_source_t *source){	char sourceloc[ZFS_MAXNAMELEN];	zprop_source_t sourcetype;	if (!zfs_prop_valid_for_type(ZFS_PROP_MOUNTPOINT, zhp->zfs_type))		return (B_FALSE);	verify(zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, buf, buflen,	    &sourcetype, sourceloc, sizeof (sourceloc), B_FALSE) == 0);	if (strcmp(buf, ZFS_MOUNTPOINT_NONE) == 0 ||	    strcmp(buf, ZFS_MOUNTPOINT_LEGACY) == 0)		return (B_FALSE);	if (zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_OFF)		return (B_FALSE);	if (zfs_prop_get_int(zhp, ZFS_PROP_ZONED) &&	    getzoneid() == GLOBAL_ZONEID)		return (B_FALSE);    if (zfs_prop_get_int(zhp, ZFS_PROP_KEYSTATUS) ==        ZFS_CRYPT_KEY_UNAVAILABLE)        return (B_FALSE);	if (source)		*source = sourcetype;	return (B_TRUE);}
开发者ID:tommiatplayfish,项目名称:zfs-crypto,代码行数:37,


示例6: sa_zfs_sprintf_existing_prop

/* * This method builds values for "sharesmb" property from values * already existing on the share. The properties set via sa_zfs_sprint_new_prop * method are passed in sharesmb_val. If a existing property is already * set via sa_zfs_sprint_new_prop method, then they are not appended * to the sharesmb_val string. The returned sharesmb_val string is a combination * of new and existing values for 'sharesmb' property. */static intsa_zfs_sprintf_existing_prop(zfs_handle_t *handle, char *sharesmb_val){	char shareopts[ZFS_MAXPROPLEN], cur_val[MAXPATHLEN];	char *token, *last, *value;	if (zfs_prop_get(handle, ZFS_PROP_SHARESMB, shareopts,	    sizeof (shareopts), NULL, NULL, 0, B_FALSE) != 0)		return (-1);	if (strstr(shareopts, "=") == NULL)		return (0);	for (token = strtok_r(shareopts, ",", &last); token != NULL;	    token = strtok_r(NULL, ",", &last)) {		value = strchr(token, '=');		if (value == NULL)			return (-1);		*value++ = '/0';		(void) snprintf(cur_val, MAXPATHLEN, "%s=", token);		if (strstr(sharesmb_val, cur_val) == NULL) {			(void) strlcat(cur_val, value, MAXPATHLEN);			(void) strlcat(cur_val, ",", MAXPATHLEN);			(void) strlcat(sharesmb_val, cur_val, MAXPATHLEN);		}	}	return (0);}
开发者ID:BjoKaSH,项目名称:ZCE-CDDL-FILES,代码行数:38,


示例7: mount_cb

static intmount_cb(zfs_handle_t *zhp, void *data){	get_all_cb_t *cbp = data;	if (!(zfs_get_type(zhp) & ZFS_TYPE_FILESYSTEM)) {		zfs_close(zhp);		return (0);	}	if (zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_NOAUTO) {		zfs_close(zhp);		return (0);	}	/*	 * If this filesystem is inconsistent and has a receive resume	 * token, we can not mount it.	 */	if (zfs_prop_get_int(zhp, ZFS_PROP_INCONSISTENT) &&	    zfs_prop_get(zhp, ZFS_PROP_RECEIVE_RESUME_TOKEN,	    NULL, 0, NULL, NULL, 0, B_TRUE) == 0) {		zfs_close(zhp);		return (0);	}	libzfs_add_handle(cbp, zhp);	if (zfs_iter_filesystems(zhp, mount_cb, cbp) != 0) {		zfs_close(zhp);		return (-1);	}	return (0);}
开发者ID:SageCloud,项目名称:zfs,代码行数:33,


示例8: zfs_crypto_get_encryption_root

intzfs_crypto_get_encryption_root(zfs_handle_t *zhp, boolean_t *is_encroot,    char *buf){	int ret;	char prop_encroot[MAXNAMELEN];	/* if the dataset isn't encrypted, just return */	if (zfs_prop_get_int(zhp, ZFS_PROP_ENCRYPTION) == ZIO_CRYPT_OFF) {		*is_encroot = B_FALSE;		if (buf != NULL)			buf[0] = '/0';		return (0);	}	ret = zfs_prop_get(zhp, ZFS_PROP_ENCRYPTION_ROOT, prop_encroot,	    sizeof (prop_encroot), NULL, NULL, 0, B_TRUE);	if (ret != 0) {		*is_encroot = B_FALSE;		if (buf != NULL)			buf[0] = '/0';		return (ret);	}	*is_encroot = strcmp(prop_encroot, zfs_get_name(zhp)) == 0;	if (buf != NULL)		strcpy(buf, prop_encroot);	return (0);}
开发者ID:cbreak-black,项目名称:zfs,代码行数:30,


示例9: sa_zfs_is_shared

intsa_zfs_is_shared(sa_handle_t sahandle, char *path){	int ret = 0;	char *dataset;	zfs_handle_t *handle = NULL;	char shareopts[ZFS_MAXPROPLEN];	libzfs_handle_t *libhandle;	dataset = get_zfs_dataset((sa_handle_t)sahandle, path, B_FALSE);	if (dataset != NULL) {		libhandle = libzfs_init();		if (libhandle != NULL) {			handle = zfs_open(libhandle, dataset,			    ZFS_TYPE_FILESYSTEM);			if (handle != NULL) {				if (zfs_prop_get(handle, ZFS_PROP_SHARENFS,				    shareopts, sizeof (shareopts), NULL, NULL,				    0, B_FALSE) == 0 &&				    strcmp(shareopts, "off") != 0) {					ret = 1; /* it is shared */				}				zfs_close(handle);			}			libzfs_fini(libhandle);		}		free(dataset);	}	return (ret);}
开发者ID:BjoKaSH,项目名称:ZCE-CDDL-FILES,代码行数:30,


示例10: zfs_share_iscsi

intzfs_share_iscsi(zfs_handle_t *zhp){	char shareopts[ZFS_MAXPROPLEN];	const char *dataset = zhp->zfs_name;	libzfs_handle_t *hdl = zhp->zfs_hdl;	/*	 * Return success if there are no share options.	 */	if (zfs_prop_get(zhp, ZFS_PROP_SHAREISCSI, shareopts,	    sizeof (shareopts), NULL, NULL, 0, B_FALSE) != 0 ||	    strcmp(shareopts, "off") == 0)		return (0);	if (iscsitgt_zfs_share == NULL || iscsitgt_zfs_share(dataset) != 0) {		int error = EZFS_SHAREISCSIFAILED;		/*		 * If service isn't availabele and EPERM was		 * returned then use special error.		 */		if (iscsitgt_svc_online && errno == EPERM &&		    (iscsitgt_svc_online() != 0))			error = EZFS_ISCSISVCUNAVAIL;		return (zfs_error_fmt(hdl, error,		    dgettext(TEXT_DOMAIN, "cannot share '%s'"), dataset));	}	return (0);}
开发者ID:haad,项目名称:netbsd-zfs,代码行数:32,


示例11: verify_zfs_handle

static char *verify_zfs_handle(zfs_handle_t *hdl, const char *path, boolean_t search_mnttab){	char mountpoint[ZFS_MAXPROPLEN];	char canmount[ZFS_MAXPROPLEN] = { 0 };	/* must have a mountpoint */	if (zfs_prop_get(hdl, ZFS_PROP_MOUNTPOINT, mountpoint,	    sizeof (mountpoint), NULL, NULL, 0, B_FALSE) != 0) {		/* no mountpoint */		return (NULL);	}	/* mountpoint must be a path */	if (strcmp(mountpoint, ZFS_MOUNTPOINT_NONE) == 0 ||	    strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) == 0) {		/*		 * Search mmttab for mountpoint and get dataset.		 */		if (search_mnttab == B_TRUE &&		    get_legacy_mountpoint(path, mountpoint,		    sizeof (mountpoint), NULL, 0) == 0) {			return (strdup(mountpoint));		}		return (NULL);	}	/* canmount must be set */	if (zfs_prop_get(hdl, ZFS_PROP_CANMOUNT, canmount,	    sizeof (canmount), NULL, NULL, 0, B_FALSE) != 0 ||	    strcmp(canmount, "off") == 0)		return (NULL);	/*	 * have a mountable handle but want to skip those marked none	 * and legacy	 */	if (strcmp(mountpoint, path) == 0) {		return (strdup((char *)zfs_get_name(hdl)));	}	return (NULL);}
开发者ID:bahamas10,项目名称:openzfs,代码行数:43,


示例12: tlm_build_snapshot_name

/* * Insert the backup snapshot name into the path. * * Input: * 	name: Original path name. * * Output: * 	name: Original name modified to include a snapshot. * * Returns: * 	Original name modified to include a snapshot. */char *tlm_build_snapshot_name(char *name, char *sname, char *jname){    zfs_handle_t *zhp;    char *rest;    char volname[ZFS_MAXNAMELEN];    char mountpoint[PATH_MAX];    if (get_zfsvolname(volname, ZFS_MAXNAMELEN, name) == -1)        goto notzfs;    (void) mutex_lock(&zlib_mtx);    if ((zlibh == NULL) ||            (zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == NULL) {        (void) mutex_unlock(&zlib_mtx);        goto notzfs;    }    if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint, PATH_MAX, NULL,                     NULL, 0, B_FALSE) != 0) {        zfs_close(zhp);        (void) mutex_unlock(&zlib_mtx);        goto notzfs;    }    zfs_close(zhp);    (void) mutex_unlock(&zlib_mtx);    rest = name + strlen(mountpoint);    (void) snprintf(sname, TLM_MAX_PATH_NAME, "%s/%s/%s%s", mountpoint,                    TLM_SNAPSHOT_DIR, jname, rest);    return (sname);notzfs:    (void) strlcpy(sname, name, TLM_MAX_PATH_NAME);    return (sname);}
开发者ID:mikess,项目名称:illumos-gate,代码行数:50,


示例13: match_mountpoint

/* * A ZFS file system iterator call-back function which returns the * zfs_handle_t for a ZFS file system on the specified mount point. */static intmatch_mountpoint(zfs_handle_t *zhp, void *data){	int			res;	zfs_mount_data_t	*cbp;	char			mp[ZFS_MAXPROPLEN];	if (zfs_get_type(zhp) != ZFS_TYPE_FILESYSTEM) {		zfs_close(zhp);		return (0);	}	cbp = (zfs_mount_data_t *)data;	if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mp, sizeof (mp), NULL, NULL,	    0, B_FALSE) == 0 && strcmp(mp, cbp->match_name) == 0) {		cbp->match_handle = zhp;		return (1);	}	res = zfs_iter_filesystems(zhp, match_mountpoint, data);	zfs_close(zhp);	return (res);}
开发者ID:andreiw,项目名称:polaris,代码行数:27,


示例14: srvsvc_shareacl_getpath

/* * This method computes ACL on share path from a share name. * Return 0 upon success, -1 upon failure. */static intsrvsvc_shareacl_getpath(smb_share_t *si, char *shr_acl_path){	char dataset[MAXPATHLEN];	char mp[ZFS_MAXPROPLEN];	libzfs_handle_t *libhd;	zfs_handle_t *zfshd;	int ret = 0;	ret = smb_getdataset(si->shr_path, dataset, MAXPATHLEN);	if (ret != 0)		return (ret);	if ((libhd = libzfs_init()) == NULL)		return (-1);	if ((zfshd = zfs_open(libhd, dataset, ZFS_TYPE_DATASET)) == NULL) {		libzfs_fini(libhd);		return (-1);	}	if (zfs_prop_get(zfshd, ZFS_PROP_MOUNTPOINT, mp, sizeof (mp), NULL,	    NULL, 0, B_FALSE) != 0) {		zfs_close(zfshd);		libzfs_fini(libhd);		return (-1);	}	zfs_close(zfshd);	libzfs_fini(libhd);	(void) snprintf(shr_acl_path, MAXPATHLEN, "%s/.zfs/shares/%s",	    mp, si->shr_name);	return (ret);}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:40,


示例15: get_zfs_property

static char *get_zfs_property(char *dataset, zfs_prop_t property){	zfs_handle_t *handle = NULL;	char shareopts[ZFS_MAXPROPLEN];	libzfs_handle_t *libhandle;	libhandle = libzfs_init();	if (libhandle != NULL) {		handle = zfs_open(libhandle, dataset, ZFS_TYPE_FILESYSTEM);		if (handle != NULL) {			if (zfs_prop_get(handle, property, shareopts,			    sizeof (shareopts), NULL, NULL, 0,			    B_FALSE) == 0) {				zfs_close(handle);				libzfs_fini(libhandle);				return (strdup(shareopts));			}			zfs_close(handle);		}		libzfs_fini(libhandle);	}	return (NULL);}
开发者ID:BjoKaSH,项目名称:ZCE-CDDL-FILES,代码行数:24,


示例16: zfs_sort

/* * Sort datasets by specified columns. * * o  Numeric types sort in ascending order. * o  String types sort in alphabetical order. * o  Types inappropriate for a row sort that row to the literal *    bottom, regardless of the specified ordering. * * If no sort columns are specified, or two datasets compare equally * across all specified columns, they are sorted alphabetically by name * with snapshots grouped under their parents. */static intzfs_sort(const void *larg, const void *rarg, void *data){	zfs_handle_t *l = ((zfs_node_t *)larg)->zn_handle;	zfs_handle_t *r = ((zfs_node_t *)rarg)->zn_handle;	zfs_sort_column_t *sc = (zfs_sort_column_t *)data;	zfs_sort_column_t *psc;	for (psc = sc; psc != NULL; psc = psc->sc_next) {		char lbuf[ZFS_MAXPROPLEN], rbuf[ZFS_MAXPROPLEN];		char *lstr, *rstr;		uint64_t lnum, rnum;		boolean_t lvalid, rvalid;		int ret = 0;		/*		 * We group the checks below the generic code.  If 'lstr' and		 * 'rstr' are non-NULL, then we do a string based comparison.		 * Otherwise, we compare 'lnum' and 'rnum'.		 */		lstr = rstr = NULL;		if (psc->sc_prop == ZPROP_INVAL) {			nvlist_t *luser, *ruser;			nvlist_t *lval, *rval;			luser = zfs_get_user_props(l);			ruser = zfs_get_user_props(r);			lvalid = (nvlist_lookup_nvlist(luser,			    psc->sc_user_prop, &lval) == 0);			rvalid = (nvlist_lookup_nvlist(ruser,			    psc->sc_user_prop, &rval) == 0);			if (lvalid)				verify(nvlist_lookup_string(lval,				    ZPROP_VALUE, &lstr) == 0);			if (rvalid)				verify(nvlist_lookup_string(rval,				    ZPROP_VALUE, &rstr) == 0);		} else if (psc->sc_prop == ZFS_PROP_NAME) {			lvalid = rvalid = B_TRUE;			(void) strlcpy(lbuf, zfs_get_name(l), sizeof(lbuf));			(void) strlcpy(rbuf, zfs_get_name(r), sizeof(rbuf));			lstr = lbuf;			rstr = rbuf;		} else if (zfs_prop_is_string(psc->sc_prop)) {			lvalid = (zfs_prop_get(l, psc->sc_prop, lbuf,			    sizeof (lbuf), NULL, NULL, 0, B_TRUE) == 0);			rvalid = (zfs_prop_get(r, psc->sc_prop, rbuf,			    sizeof (rbuf), NULL, NULL, 0, B_TRUE) == 0);			lstr = lbuf;			rstr = rbuf;		} else {			lvalid = zfs_prop_valid_for_type(psc->sc_prop,			    zfs_get_type(l));			rvalid = zfs_prop_valid_for_type(psc->sc_prop,			    zfs_get_type(r));			if (lvalid)				(void) zfs_prop_get_numeric(l, psc->sc_prop,				    &lnum, NULL, NULL, 0);			if (rvalid)				(void) zfs_prop_get_numeric(r, psc->sc_prop,				    &rnum, NULL, NULL, 0);		}		if (!lvalid && !rvalid)			continue;		else if (!lvalid)			return (1);		else if (!rvalid)			return (-1);		if (lstr)			ret = strcmp(lstr, rstr);		else if (lnum < rnum)			ret = -1;		else if (lnum > rnum)			ret = 1;		if (ret != 0) {			if (psc->sc_reverse == B_TRUE)				ret = (ret < 0) ? 1 : -1;			return (ret);		}//.........这里部分代码省略.........
开发者ID:Der-Jan,项目名称:freebsd-crypto,代码行数:101,


示例17: sa_get_zfs_shares

intsa_get_zfs_shares(sa_handle_t handle, char *groupname){	sa_group_t zfsgroup;	boolean_t nfs;	boolean_t nfs_inherited;	boolean_t smb;	boolean_t smb_inherited;	zfs_handle_t **zlist;	char nfsshareopts[ZFS_MAXPROPLEN];	char smbshareopts[ZFS_MAXPROPLEN];	sa_share_t share;	zprop_source_t source;	char nfssourcestr[ZFS_MAXPROPLEN];	char smbsourcestr[ZFS_MAXPROPLEN];	char mountpoint[ZFS_MAXPROPLEN];	size_t count = 0, i;	libzfs_handle_t *zfs_libhandle;	int err = SA_OK;	/*	 * If we can't access libzfs, don't bother doing anything.	 */	zfs_libhandle = ((sa_handle_impl_t)handle)->zfs_libhandle;	if (zfs_libhandle == NULL)		return (SA_SYSTEM_ERR);	zfsgroup = find_or_create_group(handle, groupname, NULL, &err);	/* Not an error, this could be a legacy condition */	if (zfsgroup == NULL)		return (SA_OK);	/*	 * need to walk the mounted ZFS pools and datasets to	 * find shares that are possible.	 */	get_all_filesystems((sa_handle_impl_t)handle, &zlist, &count);	qsort(zlist, count, sizeof (void *), mountpoint_compare);	for (i = 0; i < count; i++) {		char *dataset;		source = ZPROP_SRC_ALL;		/* If no mountpoint, skip. */		if (zfs_prop_get(zlist[i], ZFS_PROP_MOUNTPOINT,		    mountpoint, sizeof (mountpoint), NULL, NULL, 0,		    B_FALSE) != 0)			continue;		/*		 * zfs_get_name value must not be freed. It is just a		 * pointer to a value in the handle.		 */		if ((dataset = (char *)zfs_get_name(zlist[i])) == NULL)			continue;		/*		 * only deal with "mounted" file systems since		 * unmounted file systems can't actually be shared.		 */		if (!zfs_is_mounted(zlist[i], NULL))			continue;		nfs = nfs_inherited = B_FALSE;		if (zfs_prop_get(zlist[i], ZFS_PROP_SHARENFS, nfsshareopts,		    sizeof (nfsshareopts), &source, nfssourcestr,		    ZFS_MAXPROPLEN, B_FALSE) == 0 &&		    strcmp(nfsshareopts, "off") != 0) {			if (source & ZPROP_SRC_INHERITED)				nfs_inherited = B_TRUE;			else				nfs = B_TRUE;		}		smb = smb_inherited = B_FALSE;		if (zfs_prop_get(zlist[i], ZFS_PROP_SHARESMB, smbshareopts,		    sizeof (smbshareopts), &source, smbsourcestr,		    ZFS_MAXPROPLEN, B_FALSE) == 0 &&		    strcmp(smbshareopts, "off") != 0) {			if (source & ZPROP_SRC_INHERITED)				smb_inherited = B_TRUE;			else				smb = B_TRUE;		}		/*		 * If the mountpoint is already shared, it must be a		 * non-ZFS share. We want to remove the share from its		 * parent group and reshare it under ZFS.		 */		share = sa_find_share(handle, mountpoint);		if (share != NULL &&		    (nfs || smb || nfs_inherited || smb_inherited)) {			err = sa_remove_share(share);			share = NULL;		}		/*//.........这里部分代码省略.........
开发者ID:BjoKaSH,项目名称:ZCE-CDDL-FILES,代码行数:101,


示例18: zfs_crypto_rewrap

intzfs_crypto_rewrap(zfs_handle_t *zhp, nvlist_t *raw_props, boolean_t inheritkey){	int ret;	char errbuf[1024];	boolean_t is_encroot;	nvlist_t *props = NULL;	uint8_t *wkeydata = NULL;	uint_t wkeylen = 0;	dcp_cmd_t cmd = (inheritkey) ? DCP_CMD_INHERIT : DCP_CMD_NEW_KEY;	uint64_t crypt, pcrypt, keystatus, pkeystatus;	uint64_t keyformat = ZFS_KEYFORMAT_NONE;	zfs_handle_t *pzhp = NULL;	char *keylocation = NULL;	char origin_name[MAXNAMELEN];	char prop_keylocation[MAXNAMELEN];	char parent_name[ZFS_MAX_DATASET_NAME_LEN];	(void) snprintf(errbuf, sizeof (errbuf),	    dgettext(TEXT_DOMAIN, "Key change error"));	/* check that encryption is enabled for the pool */	if (!encryption_feature_is_enabled(zhp->zpool_hdl)) {		zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN,		    "Encryption feature not enabled."));		ret = EINVAL;		goto error;	}	/* get crypt from dataset */	crypt = zfs_prop_get_int(zhp, ZFS_PROP_ENCRYPTION);	if (crypt == ZIO_CRYPT_OFF) {		zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN,		    "Dataset not encrypted."));		ret = EINVAL;		goto error;	}	/* get the encryption root of the dataset */	ret = zfs_crypto_get_encryption_root(zhp, &is_encroot, NULL);	if (ret != 0) {		zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN,		    "Failed to get encryption root for '%s'."),		    zfs_get_name(zhp));		goto error;	}	/* Clones use their origin's key and cannot rewrap it */	ret = zfs_prop_get(zhp, ZFS_PROP_ORIGIN, origin_name,	    sizeof (origin_name), NULL, NULL, 0, B_TRUE);	if (ret == 0 && strcmp(origin_name, "") != 0) {		zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN,		    "Keys cannot be changed on clones."));		ret = EINVAL;		goto error;	}	/*	 * If the user wants to use the inheritkey variant of this function	 * we don't need to collect any crypto arguments.	 */	if (!inheritkey) {		/* validate the provided properties */		ret = zfs_crypto_verify_rewrap_nvlist(zhp, raw_props, &props,		    errbuf);		if (ret != 0)			goto error;		/*		 * Load keyformat and keylocation from the nvlist. Fetch from		 * the dataset properties if not specified.		 */		(void) nvlist_lookup_uint64(props,		    zfs_prop_to_name(ZFS_PROP_KEYFORMAT), &keyformat);		(void) nvlist_lookup_string(props,		    zfs_prop_to_name(ZFS_PROP_KEYLOCATION), &keylocation);		if (is_encroot) {			/*			 * If this is already an ecryption root, just keep			 * any properties not set by the user.			 */			if (keyformat == ZFS_KEYFORMAT_NONE) {				keyformat = zfs_prop_get_int(zhp,				    ZFS_PROP_KEYFORMAT);				ret = nvlist_add_uint64(props,				    zfs_prop_to_name(ZFS_PROP_KEYFORMAT),				    keyformat);				if (ret != 0) {					zfs_error_aux(zhp->zfs_hdl,					    dgettext(TEXT_DOMAIN, "Failed to "					    "get existing keyformat "					    "property."));					goto error;				}			}			if (keylocation == NULL) {				ret = zfs_prop_get(zhp, ZFS_PROP_KEYLOCATION,				    prop_keylocation, sizeof (prop_keylocation),//.........这里部分代码省略.........
开发者ID:cbreak-black,项目名称:zfs,代码行数:101,


示例19: zfs_mount

/* * Mount the given filesystem. */intzfs_mount(zfs_handle_t *zhp, const char *options, int flags){	struct stat buf;	char mountpoint[ZFS_MAXPROPLEN];	char mntopts[MNT_LINE_MAX];	char overlay[ZFS_MAXPROPLEN];	libzfs_handle_t *hdl = zhp->zfs_hdl;	int remount = 0, rc;	if (options == NULL) {		(void) strlcpy(mntopts, MNTOPT_DEFAULTS, sizeof (mntopts));	} else {		(void) strlcpy(mntopts, options, sizeof (mntopts));	}	if (strstr(mntopts, MNTOPT_REMOUNT) != NULL)		remount = 1;	/*	 * If the pool is imported read-only then all mounts must be read-only	 */	if (zpool_get_prop_int(zhp->zpool_hdl, ZPOOL_PROP_READONLY, NULL))		(void) strlcat(mntopts, "," MNTOPT_RO, sizeof (mntopts));	if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL))		return (0);	/*	 * Append default mount options which apply to the mount point.	 * This is done because under Linux (unlike Solaris) multiple mount	 * points may reference a single super block.  This means that just	 * given a super block there is no back reference to update the per	 * mount point options.	 */	rc = zfs_add_options(zhp, mntopts, sizeof (mntopts));	if (rc) {		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,		    "default options unavailable"));		return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED,		    dgettext(TEXT_DOMAIN, "cannot mount '%s'"),		    mountpoint));	}	/*	 * Append zfsutil option so the mount helper allow the mount	 */	strlcat(mntopts, "," MNTOPT_ZFSUTIL, sizeof (mntopts));	/* Create the directory if it doesn't already exist */	if (lstat(mountpoint, &buf) != 0) {		if (mkdirp(mountpoint, 0755) != 0) {			zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,			    "failed to create mountpoint"));			return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED,			    dgettext(TEXT_DOMAIN, "cannot mount '%s'"),			    mountpoint));		}	}	/*	 * Overlay mounts are disabled by default but may be enabled	 * via the 'overlay' property or the 'zfs mount -O' option.	 */	if (!(flags & MS_OVERLAY)) {		if (zfs_prop_get(zhp, ZFS_PROP_OVERLAY, overlay,			    sizeof (overlay), NULL, NULL, 0, B_FALSE) == 0) {			if (strcmp(overlay, "on") == 0) {				flags |= MS_OVERLAY;			}		}	}	/*	 * Determine if the mountpoint is empty.  If so, refuse to perform the	 * mount.  We don't perform this check if 'remount' is	 * specified or if overlay option(-O) is given	 */	if ((flags & MS_OVERLAY) == 0 && !remount &&	    !dir_is_empty(mountpoint)) {		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,		    "directory is not empty"));		return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED,		    dgettext(TEXT_DOMAIN, "cannot mount '%s'"), mountpoint));	}	/* perform the mount */	rc = do_mount(zfs_get_name(zhp), mountpoint, mntopts);	if (rc) {		/*		 * Generic errors are nasty, but there are just way too many		 * from mount(), and they're well-understood.  We pick a few		 * common ones to improve upon.		 */		if (rc == EBUSY) {			zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,			    "mountpoint or dataset is busy"));//.........这里部分代码省略.........
开发者ID:SageCloud,项目名称:zfs,代码行数:101,


示例20: match_mountpoint

/* * A ZFS file system iterator call-back function which returns the * zfs_handle_t for a ZFS file system on the specified mount point. */static intmatch_mountpoint(zfs_handle_t *zhp, void *data){	int			res;	zfs_mount_data_t	*cbp;	char			mp[ZFS_MAXPROPLEN];	if (zfs_get_type(zhp) != ZFS_TYPE_FILESYSTEM) {		zfs_close(zhp);		return (0);	}	/* First check if the dataset is mounted. */	if (zfs_prop_get(zhp, ZFS_PROP_MOUNTED, mp, sizeof (mp), NULL, NULL,	    0, B_FALSE) != 0 || strcmp(mp, "no") == 0) {		zfs_close(zhp);		return (0);	}	/* Now check mount point. */	if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mp, sizeof (mp), NULL, NULL,	    0, B_FALSE) != 0) {		zfs_close(zhp);		return (0);	}	cbp = (zfs_mount_data_t *)data;	if (strcmp(mp, "legacy") == 0) {		/* If legacy, must look in mnttab for mountpoint. */		FILE		*fp;		struct mnttab	entry;		const char	*nm;		nm = zfs_get_name(zhp);		if ((fp = fopen(MNTTAB, "r")) == NULL) {			zfs_close(zhp);			return (0);		}		while (getmntent(fp, &entry) == 0) {			if (strcmp(nm, entry.mnt_special) == 0) {				if (strcmp(entry.mnt_mountp, cbp->match_name)				    == 0) {					(void) fclose(fp);					cbp->match_handle = zhp;					return (1);				}				break;			}		}		(void) fclose(fp);	} else if (strcmp(mp, cbp->match_name) == 0) {		cbp->match_handle = zhp;		return (1);	}	/* Iterate over any nested datasets. */	res = zfs_iter_filesystems(zhp, match_mountpoint, data);	zfs_close(zhp);	return (res);}
开发者ID:bahamas10,项目名称:openzfs,代码行数:67,


示例21: changelist_postfix

/* * If the property is 'mountpoint' or 'sharenfs', go through and remount and/or * reshare the filesystems as necessary.  In changelist_gather() we recorded * whether the filesystem was previously shared or mounted.  The action we take * depends on the previous state, and whether the value was previously 'legacy'. * For non-legacy properties, we only remount/reshare the filesystem if it was * previously mounted/shared.  Otherwise, we always remount/reshare the * filesystem. */intchangelist_postfix(prop_changelist_t *clp){	prop_changenode_t *cn;	char shareopts[ZFS_MAXPROPLEN];	int ret = 0;	libzfs_handle_t *hdl;	/*	 * If we're changing the mountpoint, attempt to destroy the underlying	 * mountpoint.  All other datasets will have inherited from this dataset	 * (in which case their mountpoints exist in the filesystem in the new	 * location), or have explicit mountpoints set (in which case they won't	 * be in the changelist).	 */	if ((cn = uu_list_last(clp->cl_list)) == NULL)		return (0);	if (clp->cl_prop == ZFS_PROP_MOUNTPOINT)		remove_mountpoint(cn->cn_handle);	/*	 * It is possible that the changelist_prefix() used libshare	 * to unshare some entries. Since libshare caches data, an	 * attempt to reshare during postfix can fail unless libshare	 * is uninitialized here so that it will reinitialize later.	 */	if (cn->cn_handle != NULL) {		hdl = cn->cn_handle->zfs_hdl;		assert(hdl != NULL);#ifndef __APPLE__		zfs_uninit_libshare(hdl);#endif	}	/*	 * We walk the datasets in reverse, because we want to mount any parent	 * datasets before mounting the children.	 */	for (cn = uu_list_last(clp->cl_list); cn != NULL;	    cn = uu_list_prev(clp->cl_list, cn)) {		boolean_t sharenfs;#ifndef __APPLE__		/*		 * If we are in the global zone, but this dataset is exported		 * to a local zone, do nothing.		 */		if (getzoneid() == GLOBAL_ZONEID && cn->cn_zoned)			continue;#endif /*!__APPLE__*/		zfs_refresh_properties(cn->cn_handle);		if (ZFS_IS_VOLUME(cn->cn_handle)) {			/*			 * If we're doing a rename, recreate the /dev/zvol			 * links.			 */			if (clp->cl_realprop == ZFS_PROP_NAME &&			    zvol_create_link(cn->cn_handle->zfs_hdl,			    cn->cn_handle->zfs_name) != 0) {				ret = -1;			} else if (cn->cn_shared ||			    clp->cl_prop == ZFS_PROP_SHAREISCSI) {				if (zfs_prop_get(cn->cn_handle,				    ZFS_PROP_SHAREISCSI, shareopts,				    sizeof (shareopts), NULL, NULL, 0,				    B_FALSE) == 0 &&				    strcmp(shareopts, "off") == 0) {					ret = zfs_unshare_iscsi(cn->cn_handle);				} else {					ret = zfs_share_iscsi(cn->cn_handle);				}			}			continue;		}		/*		 * Remount if previously mounted or mountpoint was legacy,		 * or sharenfs property is set.		 */		sharenfs = ((zfs_prop_get(cn->cn_handle, ZFS_PROP_SHARENFS,		    shareopts, sizeof (shareopts), NULL, NULL, 0,		    B_FALSE) == 0) && (strcmp(shareopts, "off") != 0));		if ((cn->cn_mounted || clp->cl_waslegacy || sharenfs) &&		    !zfs_is_mounted(cn->cn_handle, NULL) &&		    zfs_mount(cn->cn_handle, NULL, 0) != 0)//.........这里部分代码省略.........
开发者ID:roddi,项目名称:mac-zfs,代码行数:101,


示例22: sa_zfs_get_info

/* * sa_get_zfs_info(libzfs, path, mountpoint, dataset) * * Find the ZFS dataset and mountpoint for a given path */intsa_zfs_get_info(libzfs_handle_t *libzfs, char *path, char *mountpointp,    char *datasetp){	get_all_cbdata_t cb = { 0 };	int i;	char mountpoint[ZFS_MAXPROPLEN];	char dataset[ZFS_MAXPROPLEN];	char canmount[ZFS_MAXPROPLEN];	char *dp;	int count;	int ret = 0;	cb.cb_types = ZFS_TYPE_FILESYSTEM;	if (libzfs == NULL)		return (0);	(void) zfs_iter_root(libzfs, get_one_filesystem, &cb);	count = cb.cb_used;	qsort(cb.cb_handles, count, sizeof (void *), mountpoint_compare);	for (i = 0; i < count; i++) {		/* must have a mountpoint */		if (zfs_prop_get(cb.cb_handles[i], ZFS_PROP_MOUNTPOINT,		    mountpoint, sizeof (mountpoint),		    NULL, NULL, 0, B_FALSE) != 0) {			/* no mountpoint */			continue;		}		/* mountpoint must be a path */		if (strcmp(mountpoint, ZFS_MOUNTPOINT_NONE) == 0 ||		    strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) == 0) {			/*			 * Search mmttab for mountpoint			 */			if (get_legacy_mountpoint(path, dataset,			    ZFS_MAXPROPLEN, mountpoint,			    ZFS_MAXPROPLEN) == 0) {				ret = 1;				break;			}			continue;		}		/* canmount must be set */		canmount[0] = '/0';		if (zfs_prop_get(cb.cb_handles[i], ZFS_PROP_CANMOUNT, canmount,		    sizeof (canmount), NULL, NULL, 0, B_FALSE) != 0 ||		    strcmp(canmount, "off") == 0)			continue;		/*		 * have a mountable handle but want to skip those marked none		 * and legacy		 */		if (strcmp(mountpoint, path) == 0) {			dp = (char *)zfs_get_name(cb.cb_handles[i]);			if (dp != NULL) {				if (datasetp != NULL)					(void) strcpy(datasetp, dp);				if (mountpointp != NULL)					(void) strcpy(mountpointp, mountpoint);				ret = 1;			}			break;		}	}	return (ret);}
开发者ID:BjoKaSH,项目名称:ZCE-CDDL-FILES,代码行数:79,


示例23: change_one

static intchange_one(zfs_handle_t *zhp, void *data){	prop_changelist_t *clp = data;	char property[ZFS_MAXPROPLEN];	char where[64];	prop_changenode_t *cn;	zfs_source_t sourcetype;	/*	 * We only want to unmount/unshare those filesystems that may inherit	 * from the target filesystem.  If we find any filesystem with a	 * locally set mountpoint, we ignore any children since changing the	 * property will not affect them.  If this is a rename, we iterate	 * over all children regardless, since we need them unmounted in	 * order to do the rename.  Also, if this is a volume and we're doing	 * a rename, then always add it to the changelist.	 */	if (!(ZFS_IS_VOLUME(zhp) && clp->cl_realprop == ZFS_PROP_NAME) &&	    zfs_prop_get(zhp, clp->cl_prop, property,	    sizeof (property), &sourcetype, where, sizeof (where),	    B_FALSE) != 0) {		zfs_close(zhp);		return (0);	}	if (clp->cl_alldependents || clp->cl_allchildren ||	    sourcetype == ZFS_SRC_DEFAULT || sourcetype == ZFS_SRC_INHERITED) {		if ((cn = zfs_alloc(zfs_get_handle(zhp),		    sizeof (prop_changenode_t))) == NULL) {			zfs_close(zhp);			return (-1);		}		cn->cn_handle = zhp;		cn->cn_mounted = zfs_is_mounted(zhp, NULL);		cn->cn_shared = zfs_is_shared(zhp);#ifndef __APPLE__		cn->cn_zoned = zfs_prop_get_int(zhp, ZFS_PROP_ZONED);		/* Indicate if any child is exported to a local zone. */		if (getzoneid() == GLOBAL_ZONEID && cn->cn_zoned)			clp->cl_haszonedchild = B_TRUE;#endif /*!__APPLE__*/		uu_list_node_init(cn, &cn->cn_listnode, clp->cl_pool);		if (clp->cl_sorted) {			uu_list_index_t idx;			(void) uu_list_find(clp->cl_list, cn, NULL,			    &idx);			uu_list_insert(clp->cl_list, cn, idx);		} else {			ASSERT(!clp->cl_alldependents);			verify(uu_list_insert_before(clp->cl_list,			    uu_list_first(clp->cl_list), cn) == 0);		}		if (!clp->cl_alldependents)			return (zfs_iter_children(zhp, change_one, data));	} else {		zfs_close(zhp);	}	return (0);}
开发者ID:roddi,项目名称:mac-zfs,代码行数:69,


示例24: changelist_gather

//.........这里部分代码省略.........	clp->cl_flags = flags;	if (clp->cl_list == NULL) {		assert(uu_error() == UU_ERROR_NO_MEMORY);		(void) zfs_error(zhp->zfs_hdl, EZFS_NOMEM, "internal error");		changelist_free(clp);		return (NULL);	}	/*	 * If this is a rename or the 'zoned' property, we pretend we're	 * changing the mountpoint and flag it so we can catch all children in	 * change_one().	 *	 * Flag cl_alldependents to catch all children plus the dependents	 * (clones) that are not in the hierarchy.	 */	if (prop == ZFS_PROP_NAME) {		clp->cl_prop = ZFS_PROP_MOUNTPOINT;		clp->cl_alldependents = B_TRUE;	} else if (prop == ZFS_PROP_ZONED) {		clp->cl_prop = ZFS_PROP_MOUNTPOINT;		clp->cl_allchildren = B_TRUE;	} else if (prop == ZFS_PROP_CANMOUNT) {		clp->cl_prop = ZFS_PROP_MOUNTPOINT;	} else if (prop == ZFS_PROP_VOLSIZE) {		clp->cl_prop = ZFS_PROP_MOUNTPOINT;	} else if (prop == ZFS_PROP_VERSION) {		clp->cl_prop = ZFS_PROP_MOUNTPOINT;	} else {		clp->cl_prop = prop;	}	clp->cl_realprop = prop;	if (clp->cl_prop != ZFS_PROP_MOUNTPOINT &&	    clp->cl_prop != ZFS_PROP_SHARENFS &&	    clp->cl_prop != ZFS_PROP_SHAREISCSI)		return (clp);	if (clp->cl_alldependents) {		if (zfs_iter_dependents(zhp, B_TRUE, change_one, clp) != 0) {			changelist_free(clp);			return (NULL);		}	} else if (zfs_iter_children(zhp, change_one, clp) != 0) {		changelist_free(clp);		return (NULL);	}	/*	 * We have to re-open ourselves because we auto-close all the handles	 * and can't tell the difference.	 */	if ((temp = zfs_open(zhp->zfs_hdl, zfs_get_name(zhp),	    ZFS_TYPE_ANY)) == NULL) {		changelist_free(clp);		return (NULL);	}	/*	 * Always add ourself to the list.  We add ourselves to the end so that	 * we're the last to be unmounted.	 */	if ((cn = zfs_alloc(zhp->zfs_hdl,	    sizeof (prop_changenode_t))) == NULL) {		zfs_close(temp);		changelist_free(clp);		return (NULL);	}	cn->cn_handle = temp;	cn->cn_mounted = zfs_is_mounted(temp, NULL);	cn->cn_shared = zfs_is_shared(temp);#ifndef	__APPLE__	cn->cn_zoned = zfs_prop_get_int(zhp, ZFS_PROP_ZONED);#endif	/*!__APPLE__*/	uu_list_node_init(cn, &cn->cn_listnode, clp->cl_pool);	if (clp->cl_sorted) {		uu_list_index_t idx;		(void) uu_list_find(clp->cl_list, cn, NULL, &idx);		uu_list_insert(clp->cl_list, cn, idx);	} else {		verify(uu_list_insert_after(clp->cl_list,		    uu_list_last(clp->cl_list), cn) == 0);	}	/*	 * If the mountpoint property was previously 'legacy', or 'none',	 * record it as the behavior of changelist_postfix() will be different.	 */	if ((clp->cl_prop == ZFS_PROP_MOUNTPOINT) &&	    (zfs_prop_get(zhp, prop, property, sizeof (property),	    NULL, NULL, 0, B_FALSE) == 0 &&	    (strcmp(property, "legacy") == 0 || strcmp(property, "none") == 0)))		clp->cl_waslegacy = B_TRUE;	return (clp);}
开发者ID:roddi,项目名称:mac-zfs,代码行数:101,


示例25: zfs_share_proto

/* * Share the given filesystem according to the options in the specified * protocol specific properties (sharenfs, sharesmb).  We rely * on "libshare" to the dirty work for us. */static intzfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto){	char mountpoint[ZFS_MAXPROPLEN];	char shareopts[ZFS_MAXPROPLEN];	char sourcestr[ZFS_MAXPROPLEN];	libzfs_handle_t *hdl = zhp->zfs_hdl;	sa_share_t share;	zfs_share_proto_t *curr_proto;	zprop_source_t sourcetype;	int ret;	if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL))		return (0);	if ((ret = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) {		(void) zfs_error_fmt(hdl, EZFS_SHARENFSFAILED,		    dgettext(TEXT_DOMAIN, "cannot share '%s': %s"),		    zfs_get_name(zhp), sa_errorstr(ret));		return (-1);	}	for (curr_proto = proto; *curr_proto != PROTO_END; curr_proto++) {		/*		 * Return success if there are no share options.		 */		if (zfs_prop_get(zhp, proto_table[*curr_proto].p_prop,		    shareopts, sizeof (shareopts), &sourcetype, sourcestr,		    ZFS_MAXPROPLEN, B_FALSE) != 0 ||		    strcmp(shareopts, "off") == 0)			continue;		/*		 * If the 'zoned' property is set, then zfs_is_mountable()		 * will have already bailed out if we are in the global zone.		 * But local zones cannot be NFS servers, so we ignore it for		 * local zones as well.		 */		if (zfs_prop_get_int(zhp, ZFS_PROP_ZONED))			continue;		share = sa_find_share(hdl->libzfs_sharehdl, mountpoint);		if (share == NULL) {			/*			 * This may be a new file system that was just			 * created so isn't in the internal cache			 * (second time through). Rather than			 * reloading the entire configuration, we can			 * assume ZFS has done the checking and it is			 * safe to add this to the internal			 * configuration.			 */			if (sa_zfs_process_share(hdl->libzfs_sharehdl,			    NULL, NULL, mountpoint,			    proto_table[*curr_proto].p_name, sourcetype,			    shareopts, sourcestr, zhp->zfs_name) != SA_OK) {				(void) zfs_error_fmt(hdl,				    proto_table[*curr_proto].p_share_err,				    dgettext(TEXT_DOMAIN, "cannot share '%s'"),				    zfs_get_name(zhp));				return (-1);			}			hdl->libzfs_shareflags |= ZFSSHARE_MISS;			share = sa_find_share(hdl->libzfs_sharehdl,			    mountpoint);		}		if (share != NULL) {			int err;			err = sa_enable_share(share,			    proto_table[*curr_proto].p_name);			if (err != SA_OK) {				(void) zfs_error_fmt(hdl,				    proto_table[*curr_proto].p_share_err,				    dgettext(TEXT_DOMAIN, "cannot share '%s'"),				    zfs_get_name(zhp));				return (-1);			}		} else {			(void) zfs_error_fmt(hdl,			    proto_table[*curr_proto].p_share_err,			    dgettext(TEXT_DOMAIN, "cannot share '%s'"),			    zfs_get_name(zhp));			return (-1);		}	}	return (0);}
开发者ID:tommiatplayfish,项目名称:zfs-crypto,代码行数:93,



注:本文中的zfs_prop_get函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ zfs_prop_get_int函数代码示例
C++ zfs_open函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。