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

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

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

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

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

示例1: zfs_unmount

/* * Unmount the given filesystem. */intzfs_unmount(zfs_handle_t *zhp, const char *mountpoint, int flags){	libzfs_handle_t *hdl = zhp->zfs_hdl;	struct mnttab entry;	char *mntpt = NULL;	/* check to see if we need to unmount the filesystem */	if (mountpoint != NULL || ((zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM ||				    zfs_get_type(zhp) == ZFS_TYPE_SNAPSHOT ) &&				   libzfs_mnttab_find(hdl, zhp->zfs_name,						      &entry) == 0)) {		/*		 * mountpoint may have come from a call to		 * getmnt/getmntany if it isn't NULL. If it is NULL,		 * we know it comes from libzfs_mnttab_find which can		 * then get freed later. We strdup it to play it safe.		 */		if (mountpoint == NULL)			mntpt = zfs_strdup(hdl, entry.mnt_mountp);		else			mntpt = zfs_strdup(hdl, mountpoint);#if defined(HAVE_ZPL)		/*		 * Unshare and unmount the filesystem		 */		if (zfs_unshare_proto(zhp, mntpt, share_all_proto) != 0)			return (-1);#else		if (unmount_one(hdl, mntpt, flags) != 0) {			free(mntpt);#if defined(HAVE_ZPL)			(void) zfs_shareall(zhp);#endif			return (-1);		}#endif		libzfs_mnttab_remove(hdl, zhp->zfs_name);#if defined(LINUX_PORT)		/* remove a /etc/mtab entry */		if (zfs_linux_remove_entry(mntpt, zhp->zfs_name, MTAB_FILE) < 0) {			free(mntpt);			return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED,				  dgettext(TEXT_DOMAIN, "failed to remove from /etc/mtab '%s'"),					      zhp->zfs_name));		}#endif		free(mntpt);	}	return (0);}
开发者ID:mirko67,项目名称:zfs,代码行数:56,


示例2: snapspec_cb

static intsnapspec_cb(zfs_handle_t *zhp, void *arg) {	snapspec_arg_t *ssa = arg;	char *shortsnapname;	int err = 0;	if (ssa->ssa_seenlast)		return (0);	shortsnapname = zfs_strdup(zhp->zfs_hdl,	    strchr(zfs_get_name(zhp), '@') + 1);	if (!ssa->ssa_seenfirst && strcmp(shortsnapname, ssa->ssa_first) == 0)		ssa->ssa_seenfirst = B_TRUE;	if (ssa->ssa_seenfirst) {		err = ssa->ssa_func(zhp, ssa->ssa_arg);	} else {		zfs_close(zhp);	}	if (strcmp(shortsnapname, ssa->ssa_last) == 0)		ssa->ssa_seenlast = B_TRUE;	free(shortsnapname);	return (err);}
开发者ID:Acidburn0zzz,项目名称:zfs,代码行数:26,


示例3: unshare_one

/* * Unshare a filesystem by mountpoint. */static intunshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint,    zfs_share_proto_t proto){#ifdef illumos	sa_share_t share;	int err;	char *mntpt;	/*	 * Mountpoint could get trashed if libshare calls getmntany	 * which it does during API initialization, so strdup the	 * value.	 */	mntpt = zfs_strdup(hdl, mountpoint);	/* make sure libshare initialized */	if ((err = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) {		free(mntpt);	/* don't need the copy anymore */		return (zfs_error_fmt(hdl, EZFS_SHARENFSFAILED,		    dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"),		    name, _sa_errorstr(err)));	}	share = zfs_sa_find_share(hdl->libzfs_sharehdl, mntpt);	free(mntpt);	/* don't need the copy anymore */	if (share != NULL) {		err = zfs_sa_disable_share(share, proto_table[proto].p_name);		if (err != SA_OK) {			return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,			    dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"),			    name, _sa_errorstr(err)));		}	} else {		return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,		    dgettext(TEXT_DOMAIN, "cannot unshare '%s': not found"),		    name));	}#else	char buf[MAXPATHLEN];	FILE *fp;	int err;	if (proto != PROTO_NFS) {		fprintf(stderr, "No SMB support in FreeBSD yet./n");		return (EOPNOTSUPP);	}	err = fsunshare(ZFS_EXPORTS_PATH, mountpoint);	if (err != 0) {		zfs_error_aux(hdl, "%s", strerror(err));		return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,		    dgettext(TEXT_DOMAIN,		    "cannot unshare '%s'"), name));	}#endif	return (0);}
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:61,


示例4: zfs_unshare_proto

/* * Unshare the given filesystem. */intzfs_unshare_proto(zfs_handle_t *zhp, const char *mountpoint,    zfs_share_proto_t *proto){	struct mnttab search = { 0 }, entry;	char *mntpt = NULL;	/* check to see if need to unmount the filesystem */	search.mnt_special = (char *)zfs_get_name(zhp);	search.mnt_fstype = MNTTYPE_ZFS;#ifndef __APPLE__	rewind(zhp->zfs_hdl->libzfs_mnttab);#endif /*!__APPLE__*/	if (mountpoint != NULL)		mntpt = zfs_strdup(zhp->zfs_hdl, mountpoint);	if (mountpoint != NULL || ((zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) &&	    getmntany(zhp->zfs_hdl->libzfs_mnttab, &entry, &search) == 0)) {		zfs_share_proto_t *curr_proto;		if (mountpoint == NULL)			mntpt = zfs_strdup(zhp->zfs_hdl, entry.mnt_mountp);		for (curr_proto = proto; *curr_proto != PROTO_END;		    curr_proto++) {			if (is_shared(zhp->zfs_hdl, mntpt, *curr_proto) &&			    unshare_one(zhp->zfs_hdl, zhp->zfs_name,			    mntpt, *curr_proto) != 0) {				if (mntpt != NULL)					free(mntpt);				return (-1);			}		}	}	if (mntpt != NULL)		free(mntpt);	return (0);}
开发者ID:roddi,项目名称:maczfs-10a286,代码行数:44,


示例5: zfs_unmount

/* * Unmount the given filesystem. */intzfs_unmount(zfs_handle_t *zhp, const char *mountpoint, int flags){	struct mnttab search = { 0 }, entry;	char *mntpt = NULL;	/* check to see if need to unmount the filesystem */	search.mnt_special = zhp->zfs_name;	search.mnt_fstype = MNTTYPE_ZFS;	rewind(zhp->zfs_hdl->libzfs_mnttab);	if (mountpoint != NULL || ((zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) &&	    getmntany(zhp->zfs_hdl->libzfs_mnttab, &entry, &search) == 0)) {		/*		 * mountpoint may have come from a call to		 * getmnt/getmntany if it isn't NULL. If it is NULL,		 * we know it comes from getmntany which can then get		 * overwritten later. We strdup it to play it safe.		 */		if (mountpoint == NULL)			mntpt = zfs_strdup(zhp->zfs_hdl, entry.mnt_mountp);		else			mntpt = zfs_strdup(zhp->zfs_hdl, mountpoint);		/*		 * Unshare and unmount the filesystem		 */		if (zfs_unshare_proto(zhp, mntpt, share_all_proto) != 0)			return (-1);		if (unmount_one(zhp->zfs_hdl, mntpt, flags) != 0) {			free(mntpt);			(void) zfs_shareall(zhp);			return (-1);		}		free(mntpt);	}	return (0);}
开发者ID:YaroslavLitvinov,项目名称:zfs-port,代码行数:43,


示例6: zfs_unmount

/* * Unmount the given filesystem. */intzfs_unmount(zfs_handle_t *zhp, const char *mountpoint, int flags){	libzfs_handle_t *hdl = zhp->zfs_hdl;	struct mnttab entry;	char *mntpt = NULL;	/* check to see if we need to unmount the filesystem */	if (mountpoint != NULL || ((zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) &&	    libzfs_mnttab_find(hdl, zhp->zfs_name, &entry) == 0)) {		/*		 * mountpoint may have come from a call to		 * getmnt/getmntany if it isn't NULL. If it is NULL,		 * we know it comes from libzfs_mnttab_find which can		 * then get freed later. We strdup it to play it safe.		 */		if (mountpoint == NULL)			mntpt = zfs_strdup(hdl, entry.mnt_mountp);		else			mntpt = zfs_strdup(hdl, mountpoint);		/*		 * Unshare and unmount the filesystem		 */		if (zfs_unshare_proto(zhp, mntpt, share_all_proto) != 0) {			free(mntpt);			return (-1);		}		if (unmount_one(hdl, mntpt, flags) != 0) {			free(mntpt);			(void) zfs_shareall(zhp);			return (-1);		}		libzfs_mnttab_remove(hdl, zhp->zfs_name);		free(mntpt);	}	return (0);}
开发者ID:Ramzec,项目名称:zfs,代码行数:43,


示例7: is_mounted

/* * Checks to see if the mount is active.  If the filesystem is mounted, we fill * in 'where' with the current mountpoint, and return 1.  Otherwise, we return * 0. */boolean_tis_mounted(libzfs_handle_t *zfs_hdl, const char *special, char **where){	struct mnttab entry;	if (libzfs_mnttab_find(zfs_hdl, special, &entry) != 0)		return (B_FALSE);	if (where != NULL)		*where = zfs_strdup(zfs_hdl, entry.mnt_mountp);	return (B_TRUE);}
开发者ID:tommiatplayfish,项目名称:zfs-crypto,代码行数:18,


示例8: zfs_unshare_proto

/* * Unshare the given filesystem. */intzfs_unshare_proto(zfs_handle_t *zhp, const char *mountpoint,    zfs_share_proto_t *proto){	libzfs_handle_t *hdl = zhp->zfs_hdl;	struct mnttab entry;	char *mntpt = NULL;	/* check to see if need to unmount the filesystem */	rewind(zhp->zfs_hdl->libzfs_mnttab);	if (mountpoint != NULL)		mountpoint = mntpt = zfs_strdup(hdl, mountpoint);	if (mountpoint != NULL || ((zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) &&	    libzfs_mnttab_find(hdl, zfs_get_name(zhp), &entry) == 0)) {		zfs_share_proto_t *curr_proto;		if (mountpoint == NULL)			mntpt = zfs_strdup(zhp->zfs_hdl, entry.mnt_mountp);		for (curr_proto = proto; *curr_proto != PROTO_END;		    curr_proto++) {			while (is_shared(hdl, mntpt, *curr_proto)) {			    if (unshare_one(hdl, zhp->zfs_name,					mntpt, *curr_proto) != 0) {				if (mntpt != NULL)					free(mntpt);				return (-1);			    }			}		}	}	if (mntpt != NULL)		free(mntpt);	return (0);}
开发者ID:ElCoyote27,项目名称:zfs-fuse,代码行数:41,


示例9: unshare_one

/* * Unshare a filesystem by mountpoint. */static intunshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint,    zfs_share_proto_t proto){#ifndef __APPLE__	sa_share_t share;	int err;#endif	char *mntpt;	/*	 * Mountpoint could get trashed if libshare calls getmntany	 * which id does during API initialization, so strdup the	 * value.	 */	mntpt = zfs_strdup(hdl, mountpoint);#ifndef __APPLE__	/* make sure libshare initialized */	if ((err = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) {		free(mntpt);	/* don't need the copy anymore */		return (zfs_error_fmt(hdl, EZFS_SHARENFSFAILED,		    dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"),		    name, _sa_errorstr(err)));	}	share = zfs_sa_find_share(hdl->libzfs_sharehdl, mntpt);#endif	free(mntpt);	/* don't need the copy anymore */#ifndef __APPLE__	if (share != NULL) {		err = zfs_sa_disable_share(share, proto_table[proto].p_name);		if (err != SA_OK) {			return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,			    dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"),			    name, _sa_errorstr(err)));		}	} else {		return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,		    dgettext(TEXT_DOMAIN, "cannot unshare '%s': not found"),		    name));	}#endif	return (0);}
开发者ID:roddi,项目名称:maczfs-10a286,代码行数:47,


示例10: is_mounted

/* * Checks to see if the mount is active.  If the filesystem is mounted, we fill * in 'where' with the current mountpoint, and return 1.  Otherwise, we return * 0. */boolean_tis_mounted(libzfs_handle_t *zfs_hdl, const char *special, char **where){	struct mnttab search = { 0 }, entry;	/*	 * Search for the entry in /etc/mnttab.  We don't bother getting the	 * mountpoint, as we can just search for the special device.  This will	 * also let us find mounts when the mountpoint is 'legacy'.	 */	search.mnt_special = (char *)special;	search.mnt_fstype = MNTTYPE_ZFS;	rewind(zfs_hdl->libzfs_mnttab);	if (getmntany(zfs_hdl->libzfs_mnttab, &entry, &search) != 0)		return (B_FALSE);	if (where != NULL)		*where = zfs_strdup(zfs_hdl, entry.mnt_mountp);	return (B_TRUE);}
开发者ID:YaroslavLitvinov,项目名称:zfs-port,代码行数:27,


示例11: unmount_one

/* * Unmount a single filesystem. */static intunmount_one(libzfs_handle_t *hdl, const char *mountpoint, int flags){	char *mntpt = NULL;	zfs_handle_t *zhp ;		if (umount2(mountpoint, flags) != 0) {		zfs_error_aux(hdl, strerror(errno));		return (zfs_error_fmt(hdl, EZFS_UMOUNTFAILED,		    dgettext(TEXT_DOMAIN, "cannot unmount '%s'"),		    mountpoint));	}	mntpt = zfs_strdup(hdl, mountpoint);	#if defined(LINUX_PORT)        /* remove a /etc/mtab entry */        if (zfs_linux_remove_entry(mntpt, zhp->zfs_name, MTAB_FILE) < 0) {            free(mntpt);            return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED,                        dgettext(TEXT_DOMAIN, "failed to remove from /etc/mtab '%s'"),                        zhp->zfs_name));        }	#endif	return (0);}
开发者ID:mirko67,项目名称:zfs,代码行数:26,


示例12: zpool_find_import_impl

//.........这里部分代码省略.........		 * Using raw devices instead of block devices when we're		 * reading the labels skips a bunch of slow operations during		 * close(2) processing, so we replace /dev/dsk with /dev/rdsk.		 */		if (strcmp(path, ZFS_DISK_ROOTD) == 0)			(void) strlcpy(rdsk, ZFS_RDISK_ROOTD, sizeof (rdsk));		else			(void) strlcpy(rdsk, path, sizeof (rdsk));		if ((dfd = open(rdsk, O_RDONLY)) < 0 ||		    (dirp = fdopendir(dfd)) == NULL) {			if (dfd >= 0)				(void) close(dfd);			zfs_error_aux(hdl, strerror(errno));			(void) zfs_error_fmt(hdl, EZFS_BADPATH,			    dgettext(TEXT_DOMAIN, "cannot open '%s'"),			    rdsk);			goto error;		}		avl_create(&slice_cache, slice_cache_compare,		    sizeof (rdsk_node_t), offsetof(rdsk_node_t, rn_node));		/*		 * This is not MT-safe, but we have no MT consumers of libzfs		 */		while ((dp = readdir(dirp)) != NULL) {			const char *name = dp->d_name;			if (name[0] == '.' &&			    (name[1] == 0 || (name[1] == '.' && name[2] == 0)))				continue;			slice = zfs_alloc(hdl, sizeof (rdsk_node_t));			slice->rn_name = zfs_strdup(hdl, name);			slice->rn_avl = &slice_cache;			slice->rn_dfd = dfd;			slice->rn_hdl = hdl;			slice->rn_nozpool = B_FALSE;			avl_add(&slice_cache, slice);		}		/*		 * create a thread pool to do all of this in parallel;		 * rn_nozpool is not protected, so this is racy in that		 * multiple tasks could decide that the same slice can		 * not hold a zpool, which is benign.  Also choose		 * double the number of processors; we hold a lot of		 * locks in the kernel, so going beyond this doesn't		 * buy us much.		 */		t = taskq_create("z_import", 2 * max_ncpus, defclsyspri,		    2 * max_ncpus, INT_MAX, TASKQ_PREPOPULATE);		for (slice = avl_first(&slice_cache); slice;		    (slice = avl_walk(&slice_cache, slice,		    AVL_AFTER)))			(void) taskq_dispatch(t, zpool_open_func, slice,			    TQ_SLEEP);		taskq_wait(t);		taskq_destroy(t);		cookie = NULL;		while ((slice = avl_destroy_nodes(&slice_cache,		    &cookie)) != NULL) {			if (slice->rn_config != NULL && !config_failed) {				nvlist_t *config = slice->rn_config;				boolean_t matched = B_TRUE;
开发者ID:cbreak-black,项目名称:zfs,代码行数:67,


示例13: zpool_vdev_name

/* * Given a vdev, return the name to display in iostat.  If the vdev has a path, * we use that, stripping off any leading "/dev/dsk/"; if not, we use the type. * We also check if this is a whole disk, in which case we strip off the * trailing 's0' slice name. * * This routine is also responsible for identifying when disks have been * reconfigured in a new location.  The kernel will have opened the device by * devid, but the path will still refer to the old location.  To catch this, we * first do a path -> devid translation (which is fast for the common case).  If * the devid matches, we're done.  If not, we do a reverse devid -> path * translation and issue the appropriate ioctl() to update the path of the vdev. * If 'zhp' is NULL, then this is an exported pool, and we don't need to do any * of these checks. */char *zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv){	char *path, *devid;	uint64_t value;	char buf[64];	if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NOT_PRESENT,	    &value) == 0) {		verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID,		    &value) == 0);		(void) snprintf(buf, sizeof (buf), "%llu", value);		path = buf;	} else if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0) {		if (zhp != NULL &&		    nvlist_lookup_string(nv, ZPOOL_CONFIG_DEVID, &devid) == 0) {			/*			 * Determine if the current path is correct.			 */			char *newdevid = path_to_devid(path);			if (newdevid == NULL ||			    strcmp(devid, newdevid) != 0) {				char *newpath;				if ((newpath = devid_to_path(devid)) != NULL) {					/*					 * Update the path appropriately.					 */					set_path(zhp, nv, newpath);					if (nvlist_add_string(nv,					    ZPOOL_CONFIG_PATH, newpath) == 0)						verify(nvlist_lookup_string(nv,						    ZPOOL_CONFIG_PATH,						    &path) == 0);					free(newpath);				}			}			if (newdevid)				devid_str_free(newdevid);		}		if (strncmp(path, "/dev/dsk/", 9) == 0)			path += 9;		if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_WHOLE_DISK,		    &value) == 0 && value) {			char *tmp = zfs_strdup(hdl, path);			if (tmp == NULL)				return (NULL);			tmp[strlen(path) - 2] = '/0';			return (tmp);		}	} else {		verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &path) == 0);		/*		 * If it's a raidz device, we need to stick in the parity level.		 */		if (strcmp(path, VDEV_TYPE_RAIDZ) == 0) {			verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NPARITY,			    &value) == 0);			(void) snprintf(buf, sizeof (buf), "%s%llu", path,			    value);			path = buf;		}	}	return (zfs_strdup(hdl, path));}
开发者ID:andreiw,项目名称:polaris,代码行数:87,


示例14: unmount_one

/* * Unmount a single filesystem. */static intunmount_one(libzfs_handle_t *hdl, const char *mountpoint, int flags){#ifdef __APPLE__#if !TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE	/* First try going through diskarb */	if (diskarb_unmount(mountpoint, flags) == 0) {		return (0);	}#endif#endif#ifdef __APPLE__	if (unmount(mountpoint, flags) != 0) {#else	if (umount2(mountpoint, flags) != 0) {#endif		zfs_error_aux(hdl, strerror(errno));		return (zfs_error_fmt(hdl, EZFS_UMOUNTFAILED,		    dgettext(TEXT_DOMAIN, "cannot unmount '%s'"),		    mountpoint));	}	return (0);}/* * Unmount the given filesystem. */intzfs_unmount(zfs_handle_t *zhp, const char *mountpoint, int flags){	struct mnttab search = { 0 }, entry;	char *mntpt = NULL;	/* check to see if need to unmount the filesystem */	search.mnt_special = zhp->zfs_name;	search.mnt_fstype = MNTTYPE_ZFS;#ifndef __APPLE__	rewind(zhp->zfs_hdl->libzfs_mnttab);#endif /*!__APPLE__*/	if (mountpoint != NULL || ((zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) &&	    getmntany(zhp->zfs_hdl->libzfs_mnttab, &entry, &search) == 0)) {		/*		 * mountpoint may have come from a call to		 * getmnt/getmntany if it isn't NULL. If it is NULL,		 * we know it comes from getmntany which can then get		 * overwritten later. We strdup it to play it safe.		 */		if (mountpoint == NULL)			mntpt = zfs_strdup(zhp->zfs_hdl, entry.mnt_mountp);		else			mntpt = zfs_strdup(zhp->zfs_hdl, mountpoint);		/*		 * Unshare and unmount the filesystem		 */#ifndef __APPLE__		if (zfs_unshare_proto(zhp, mntpt, share_all_proto) != 0)			return (-1);#endif		if (unmount_one(zhp->zfs_hdl, mntpt, flags) != 0) {			free(mntpt);			(void) zfs_shareall(zhp);			return (-1);		}		free(mntpt);	}	return (0);}/* * Unmount this filesystem and any children inheriting the mountpoint property. * To do this, just act like we're changing the mountpoint property, but don't * remount the filesystems afterwards. */intzfs_unmountall(zfs_handle_t *zhp, int flags){	prop_changelist_t *clp;	int ret;	clp = changelist_gather(zhp, ZFS_PROP_MOUNTPOINT, flags);	if (clp == NULL)		return (-1);	ret = changelist_prefix(clp);	changelist_free(clp);	return (ret);}
开发者ID:roddi,项目名称:maczfs-10a286,代码行数:96,


示例15: zpool_disable_datasets

/* * Unshare and unmount all datasets within the given pool.  We don't want to * rely on traversing the DSL to discover the filesystems within the pool, * because this may be expensive (if not all of them are mounted), and can fail * arbitrarily (on I/O error, for example).  Instead, we walk /etc/mtab and * gather all the filesystems that are currently mounted. */intzpool_disable_datasets(zpool_handle_t *zhp, boolean_t force){	int used, alloc;	struct mnttab entry;	size_t namelen;	char **mountpoints = NULL;	zfs_handle_t **datasets = NULL;	libzfs_handle_t *hdl = zhp->zpool_hdl;	int i;	int ret = -1;	int flags = (force ? MS_FORCE : 0);	namelen = strlen(zhp->zpool_name);	rewind(hdl->libzfs_mnttab);	used = alloc = 0;	while (getmntent(hdl->libzfs_mnttab, &entry) == 0) {		/*		 * Ignore non-ZFS entries.		 */		if (entry.mnt_fstype == NULL ||		    strcmp(entry.mnt_fstype, MNTTYPE_ZFS) != 0)			continue;		/*		 * Ignore filesystems not within this pool.		 */		if (entry.mnt_mountp == NULL ||		    strncmp(entry.mnt_special, zhp->zpool_name, namelen) != 0 ||		    (entry.mnt_special[namelen] != '/' &&		    entry.mnt_special[namelen] != '/0'))			continue;		/*		 * At this point we've found a filesystem within our pool.  Add		 * it to our growing list.		 */		if (used == alloc) {			if (alloc == 0) {				if ((mountpoints = zfs_alloc(hdl,				    8 * sizeof (void *))) == NULL)					goto out;				if ((datasets = zfs_alloc(hdl,				    8 * sizeof (void *))) == NULL)					goto out;				alloc = 8;			} else {				void *ptr;				if ((ptr = zfs_realloc(hdl, mountpoints,				    alloc * sizeof (void *),				    alloc * 2 * sizeof (void *))) == NULL)					goto out;				mountpoints = ptr;				if ((ptr = zfs_realloc(hdl, datasets,				    alloc * sizeof (void *),				    alloc * 2 * sizeof (void *))) == NULL)					goto out;				datasets = ptr;				alloc *= 2;			}		}		if ((mountpoints[used] = zfs_strdup(hdl,		    entry.mnt_mountp)) == NULL)			goto out;		/*		 * This is allowed to fail, in case there is some I/O error.  It		 * is only used to determine if we need to remove the underlying		 * mountpoint, so failure is not fatal.		 */		datasets[used] = make_dataset_handle(hdl, entry.mnt_special);		used++;	}	/*	 * At this point, we have the entire list of filesystems, so sort it by	 * mountpoint.	 */	qsort(mountpoints, used, sizeof (char *), mountpoint_compare);	/*	 * Walk through and first unshare everything.	 */	for (i = 0; i < used; i++) {		zfs_share_proto_t *curr_proto;//.........这里部分代码省略.........
开发者ID:tommiatplayfish,项目名称:zfs-crypto,代码行数:101,


示例16: namespace_reload

/* * Loads the pool namespace, or re-loads it if the cache has changed. */static intnamespace_reload(libzfs_handle_t *hdl){	nvlist_t *config;	config_node_t *cn;	nvpair_t *elem;	zfs_cmd_t zc = { "/0", "/0", "/0", "/0", 0 };	void *cookie;	if (hdl->libzfs_ns_gen == 0) {		/*		 * This is the first time we've accessed the configuration		 * cache.  Initialize the AVL tree and then fall through to the		 * common code.		 */		if ((hdl->libzfs_ns_avlpool = uu_avl_pool_create("config_pool",		    sizeof (config_node_t),		    offsetof(config_node_t, cn_avl),		    config_node_compare, UU_DEFAULT)) == NULL)			return (no_memory(hdl));		if ((hdl->libzfs_ns_avl = uu_avl_create(hdl->libzfs_ns_avlpool,		    NULL, UU_DEFAULT)) == NULL)			return (no_memory(hdl));	}	if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0)		return (-1);	for (;;) {		zc.zc_cookie = hdl->libzfs_ns_gen;		//if (ioctl(hdl->libzfs_fd, ZFS_IOC_POOL_CONFIGS, &zc) != 0) {		if (zfs_ioctl(hdl, ZFS_IOC_POOL_CONFIGS, &zc) != 0) {			switch (errno) {			case EEXIST:				/*				 * The namespace hasn't changed.				 */				zcmd_free_nvlists(&zc);				return (0);			case ENOMEM:				if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {					zcmd_free_nvlists(&zc);					return (-1);				}				break;			default:				zcmd_free_nvlists(&zc);				return (zfs_standard_error(hdl, errno,				    dgettext(TEXT_DOMAIN, "failed to read "				    "pool configuration")));			}		} else {			hdl->libzfs_ns_gen = zc.zc_cookie;			break;		}	}	if (zcmd_read_dst_nvlist(hdl, &zc, &config) != 0) {		zcmd_free_nvlists(&zc);		return (-1);	}	zcmd_free_nvlists(&zc);	/*	 * Clear out any existing configuration information.	 */	cookie = NULL;	while ((cn = uu_avl_teardown(hdl->libzfs_ns_avl, &cookie)) != NULL) {		nvlist_free(cn->cn_config);		free(cn->cn_name);		free(cn);	}	elem = NULL;	while ((elem = nvlist_next_nvpair(config, elem)) != NULL) {		nvlist_t *child;		uu_avl_index_t where;		if ((cn = zfs_alloc(hdl, sizeof (config_node_t))) == NULL) {			nvlist_free(config);			return (-1);		}		if ((cn->cn_name = zfs_strdup(hdl,		    nvpair_name(elem))) == NULL) {			free(cn);			nvlist_free(config);			return (-1);		}		verify(nvpair_value_nvlist(elem, &child) == 0);		if (nvlist_dup(child, &cn->cn_config, 0) != 0) {			free(cn->cn_name);//.........这里部分代码省略.........
开发者ID:dariaphoebe,项目名称:zfs-1,代码行数:101,


示例17: zfs_iter_snapspec

/* * spec is a string like "A,B%C,D" * * <snaps>, where <snaps> can be: *      <snap>          (single snapshot) *      <snap>%<snap>   (range of snapshots, inclusive) *      %<snap>         (range of snapshots, starting with earliest) *      <snap>%         (range of snapshots, ending with last) *      %               (all snapshots) *      <snaps>[,...]   (comma separated list of the above) * * If a snapshot can not be opened, continue trying to open the others, but * return ENOENT at the end. */intzfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig,    zfs_iter_f func, void *arg){	char *buf, *comma_separated, *cp;	int err = 0;	int ret = 0;	buf = zfs_strdup(fs_zhp->zfs_hdl, spec_orig);	cp = buf;	while ((comma_separated = strsep(&cp, ",")) != NULL) {		char *pct = strchr(comma_separated, '%');		if (pct != NULL) {			snapspec_arg_t ssa = { 0 };			ssa.ssa_func = func;			ssa.ssa_arg = arg;			if (pct == comma_separated)				ssa.ssa_seenfirst = B_TRUE;			else				ssa.ssa_first = comma_separated;			*pct = '/0';			ssa.ssa_last = pct + 1;			/*			 * If there is a lastname specified, make sure it			 * exists.			 */			if (ssa.ssa_last[0] != '/0') {				char snapname[ZFS_MAXNAMELEN];				(void) snprintf(snapname, sizeof (snapname),				    "%[email
C++ zfs_zget函数代码示例
C++ zfs_prop_get_int函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。