当前位置: 首页>>代码示例>>C++>>正文


C++ zfs_error_fmt函数代码示例

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


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

示例1: unshare_one

/*
 * Unshare a filesystem by mountpoint.
 */
static int
unshare_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,代码来源:libzfs_mount.c

示例2: zfs_unshare_iscsi

int
zfs_unshare_iscsi(zfs_handle_t *zhp)
{
	const char *dataset = zfs_get_name(zhp);
	libzfs_handle_t *hdl = zhp->zfs_hdl;

	/*
	 * Return if the volume is not shared
	 */
	if (zfs_is_shared_iscsi(zhp) != SHARED_ISCSI)
		return (0);

	/*
	 * If this fails with ENODEV it indicates that zvol wasn't shared so
	 * we should return success in that case.
	 */
	if (iscsitgt_zfs_unshare == NULL ||
	    (iscsitgt_zfs_unshare(dataset) != 0 && errno != ENODEV)) {
		if (errno == EPERM)
			zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
			    "Insufficient privileges to unshare iscsi"));
		return (zfs_error_fmt(hdl, EZFS_UNSHAREISCSIFAILED,
		    dgettext(TEXT_DOMAIN, "cannot unshare '%s'"), dataset));
	}

	return (0);
}
开发者ID:YaroslavLitvinov,项目名称:zfs-port,代码行数:27,代码来源:libzfs_mount.c

示例3: zfs_share_iscsi

int
zfs_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,代码来源:libzfs_mount.c

示例4: unmount_one

/*
 * Unmount a single filesystem.
 */
static int
unmount_one(libzfs_handle_t *hdl, const char *mountpoint, int flags)
{
	ASSERT((flags & ~MS_FORCE) == 0);

	char *cmd;
	int res_print;

	if(flags & MS_FORCE)
		res_print = asprintf(&cmd, "umount -l %s", mountpoint);
	else
		res_print = asprintf(&cmd, "umount %s", mountpoint);

	if(res_print == -1) {
		zfs_error_aux(hdl, strerror(ENOMEM));
		goto error;
	}

	int ret = system(cmd);
	free(cmd);
	if (ret != 0) {
		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "umount failed"));
		goto error;
	}

	return (0);
error:
	return (zfs_error_fmt(hdl, EZFS_UMOUNTFAILED,
	    dgettext(TEXT_DOMAIN, "cannot unmount '%s'"),
	    mountpoint));
}
开发者ID:YaroslavLitvinov,项目名称:zfs-port,代码行数:34,代码来源:libzfs_mount.c

示例5: unshare_one

/*
 * Unshare a filesystem by mountpoint.
 */
static int
unshare_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,代码来源:libzfs_mount.c

示例6: zfs_unmount

/*
 * Unmount the given filesystem.
 */
int
zfs_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,代码来源:libzfs_mount.c

示例7: unmount_one

/*
 * Unmount a single filesystem.
 */
static int
unmount_one(libzfs_handle_t *hdl, const char *mountpoint, int flags)
{
    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));
    }

    return (0);
}
开发者ID:kelsieflynn,项目名称:SamFlynnOS,代码行数:15,代码来源:libzfs_mount.c

示例8: get_history

/*
 * Perform ioctl to get some command history of a pool.
 *
 * 'buf' is the buffer to fill up to 'len' bytes.  'off' is the
 * logical offset of the history buffer to start reading from.
 *
 * Upon return, 'off' is the next logical offset to read from and
 * 'len' is the actual amount of bytes read into 'buf'.
 */
static int
get_history(zpool_handle_t *zhp, char *buf, uint64_t *off, uint64_t *len)
{
	zfs_cmd_t zc = { 0 };
	libzfs_handle_t *hdl = zhp->zpool_hdl;

	(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));

	zc.zc_history = (uint64_t)(uintptr_t)buf;
	zc.zc_history_len = *len;
	zc.zc_history_offset = *off;

	if (ioctl(hdl->libzfs_fd, ZFS_IOC_POOL_GET_HISTORY, &zc) != 0) {
		switch (errno) {
		case EPERM:
			return (zfs_error_fmt(hdl, EZFS_PERM,
			    dgettext(TEXT_DOMAIN,
			    "cannot show history for pool '%s'"),
			    zhp->zpool_name));
		case ENOENT:
			return (zfs_error_fmt(hdl, EZFS_NOHISTORY,
			    dgettext(TEXT_DOMAIN, "cannot get history for pool "
			    "'%s'"), zhp->zpool_name));
		case ENOTSUP:
			return (zfs_error_fmt(hdl, EZFS_BADVERSION,
			    dgettext(TEXT_DOMAIN, "cannot get history for pool "
			    "'%s', pool must be upgraded"), zhp->zpool_name));
		default:
			return (zpool_standard_error_fmt(hdl, errno,
			    dgettext(TEXT_DOMAIN,
			    "cannot get history for '%s'"), zhp->zpool_name));
		}
	}

	*len = zc.zc_history_len;
	*off = zc.zc_history_offset;

	return (0);
}
开发者ID:unofficial-opensource-apple,项目名称:zfs,代码行数:48,代码来源:libzfs_pool.c

示例9: zpool_open_canfail

/*
 * Open a handle to the given pool, even if the pool is currently in the FAULTED
 * state.
 */
zpool_handle_t *
zpool_open_canfail(libzfs_handle_t *hdl, const char *pool)
{
	zpool_handle_t *zhp;
	boolean_t missing;

	/*
	 * Make sure the pool name is valid.
	 */
	if (!zpool_name_valid(hdl, B_TRUE, pool)) {
		(void) zfs_error_fmt(hdl, EZFS_INVALIDNAME,
		    dgettext(TEXT_DOMAIN, "cannot open '%s'"),
		    pool);
		return (NULL);
	}

	if ((zhp = zfs_alloc(hdl, sizeof (zpool_handle_t))) == NULL)
		return (NULL);

	zhp->zpool_hdl = hdl;
	(void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));

	if (zpool_refresh_stats(zhp, &missing) != 0) {
		zpool_close(zhp);
		return (NULL);
	}

	if (missing) {
		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
		    "no such pool"));
		(void) zfs_error_fmt(hdl, EZFS_NOENT,
		    dgettext(TEXT_DOMAIN, "cannot open '%s'"),
		    pool);
		zpool_close(zhp);
		return (NULL);
	}

	return (zhp);
}
开发者ID:unofficial-opensource-apple,项目名称:zfs,代码行数:43,代码来源:libzfs_pool.c

示例10: unmount_one

/*
 * Unmount a single filesystem.
 */
static int
unmount_one(libzfs_handle_t *hdl, const char *mountpoint, int flags)
{
	int error;

	error = do_unmount(mountpoint, flags);
	if (error != 0) {
		return (zfs_error_fmt(hdl, EZFS_UMOUNTFAILED,
		    dgettext(TEXT_DOMAIN, "cannot unmount '%s'"),
		    mountpoint));
	}

	return (0);
}
开发者ID:tommiatplayfish,项目名称:zfs-crypto,代码行数:17,代码来源:libzfs_mount.c

示例11: unmount_one

/*
 * Unmount a single filesystem.
 */
static int
unmount_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,代码来源:libzfs_mount.c

示例12: zpool_open

/*
 * Similar to zpool_open_canfail(), but refuses to open pools in the faulted
 * state.
 */
zpool_handle_t *
zpool_open(libzfs_handle_t *hdl, const char *pool)
{
	zpool_handle_t *zhp;

	if ((zhp = zpool_open_canfail(hdl, pool)) == NULL)
		return (NULL);

	if (zhp->zpool_state == POOL_STATE_UNAVAIL) {
		(void) zfs_error_fmt(hdl, EZFS_POOLUNAVAIL,
		    dgettext(TEXT_DOMAIN, "cannot open '%s'"), zhp->zpool_name);
		zpool_close(zhp);
		return (NULL);
	}

	return (zhp);
}
开发者ID:unofficial-opensource-apple,项目名称:zfs,代码行数:21,代码来源:libzfs_pool.c

示例13: unmount_one

/*
 * Unmount a single filesystem.
 */
static int
unmount_one(libzfs_handle_t *hdl, const char *mountpoint, int flags)
{
	ASSERT((flags & ~MS_FORCE) == 0);

	int ret = 0;
	
	pid_t umountpid = fork();
	
	if (umountpid == -1) {
		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "umount failed: fork() failed"));
		goto error;
	}
	
	if (umountpid) {
		/* parent, we wait */
		umountpid = waitpid(umountpid,&ret,0);
	}
	else{
		/* child, we umount */
		if (flags & MS_FORCE) execlp("umount","umount","-l",mountpoint,NULL);
		else execlp("umount","umount",mountpoint,NULL);
		/* we do not reach this line */
	}

	if (umountpid == -1) {
		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "umount failed: waitpid() failed"));
		goto error;
	}

	if (ret != 0) {
		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "umount failed: umount child process failed"));
		goto error;
	}

	return (0);
error:
	return (zfs_error_fmt(hdl, EZFS_UMOUNTFAILED,
	    dgettext(TEXT_DOMAIN, "cannot unmount '%s'"),
	    mountpoint));
}
开发者ID:ElCoyote27,项目名称:zfs-fuse,代码行数:44,代码来源:libzfs_mount.c

示例14: 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 int
zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto)
{
	char mountpoint[ZFS_MAXPROPLEN];
	char shareopts[ZFS_MAXPROPLEN];
	char sourcestr[ZFS_MAXPROPLEN];
#if defined(HAVE_ZPL)
	libzfs_handle_t *hdl = zhp->zfs_hdl;
	sa_share_t share;
#endif
	zfs_share_proto_t *curr_proto;
	zprop_source_t sourcetype;
#if defined(HAVE_ZPL)
	int ret;
#endif

	if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL))
		return (0);

#if defined(HAVE_ZPL)
	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 != NULL ?
		    _sa_errorstr(ret) : "");
		return (-1);
	}
#endif

	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;
#if !defined(HAVE_ZPL)
       if (*curr_proto == PROTO_NFS) {
           int pid;
           int rc;
           if ((pid = fork()) < 0) {
               fprintf(stderr, "cannot share '%s'", zfs_get_name(zhp));
               return -1;
           } else if (pid == 0) {
               /* child process */
               /* exec exportfs */
               char export_string[PATH_MAX];
               char options[100];
               char *argv [] = {
                   "exportfs",
                   "-v",
                   "-i",
                   export_string,
                   "-o",
                   options,
                   NULL
               };
               struct statfs buf;
               int fsid_arr[2];
               uint64_t fsid;

               if (statfs(mountpoint, &buf) < 0)
                   return -1;

               memcpy((void *)fsid_arr, (void *) &buf.f_fsid, sizeof(int) * 2);
               fsid = fsid_arr[0];
               fsid |= (((uint64_t)fsid_arr[1]) << 32);
//               fprintf(stderr, "using fsid=%lu\n", fsid);

               sprintf(export_string, "*:%s", mountpoint);
               sprintf(options, "rw,sync,fsid=%lu", fsid);
               execvp("exportfs", argv);
               return -1;
           }
           /* parent process */
           if (waitpid(pid, &rc, WUNTRACED) != pid) {
               fprintf(stderr, "cannot share '%s'", zfs_get_name(zhp));
               return -1;
           }

           if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0) {
               fprintf(stderr, "cannot share '%s'", zfs_get_name(zhp));
               return -1;
           }
//.........这里部分代码省略.........
开发者ID:mirko67,项目名称:zfs,代码行数:101,代码来源:libzfs_mount.c

示例15: zfs_mount

/*
 * Mount the given filesystem.
 */
int
zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
{
	struct stat buf;
	char mountpoint[ZFS_MAXPROPLEN];
	char mntopts[MNT_LINE_MAX];
	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));

    /*
     * Load encryption key if required and not already present.
     * Don't need to check ZFS_PROP_ENCRYPTION because encrypted
     * datasets have keystatus of ZFS_CRYPT_KEY_NONE.
     */
    fprintf(stderr, "zfs_mount: mount, keystatus is %d\r\n",
            zfs_prop_get_int(zhp, ZFS_PROP_KEYSTATUS));
    if (zfs_prop_get_int(zhp, ZFS_PROP_KEYSTATUS) ==
        ZFS_CRYPT_KEY_UNAVAILABLE) {
        fprintf(stderr, "loading KEY\r\n");
        (void )zfs_key_load(zhp, B_FALSE, B_FALSE, B_FALSE);
    }

	/*
	 * 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));

	if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL))
		return (0);

	/* 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));
		}
	}

	/*
	 * 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"));
		} else if (rc == EPERM) {
//.........这里部分代码省略.........
开发者ID:tommiatplayfish,项目名称:zfs-crypto,代码行数:101,代码来源:libzfs_mount.c


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