Пример #1
0
static void zfsfuse_statfs(fuse_req_t req)
{
	struct statvfs64 zfs_stat;

	int ret = VFS_STATVFS(vfs, &zfs_stat);
	if(ret != 0) {
		fuse_reply_err(req, ret);
		return;
	}

	struct statvfs stat = { 0 };

	/* There's a bug somewhere in FUSE, in the kernel or in df(1) where
	   f_bsize is being used to calculate filesystem size instead of
	   f_frsize, so we must use that instead */
	stat.f_bsize = zfs_stat.f_frsize;
	stat.f_frsize = zfs_stat.f_frsize;
	stat.f_blocks = zfs_stat.f_blocks;
	stat.f_bfree = zfs_stat.f_bfree;
	stat.f_bavail = zfs_stat.f_bavail;
	stat.f_files = zfs_stat.f_files;
	stat.f_ffree = zfs_stat.f_ffree;
	stat.f_favail = zfs_stat.f_favail;
	stat.f_fsid = zfs_stat.f_fsid;
	stat.f_flag = zfs_stat.f_flag;
	stat.f_namemax = zfs_stat.f_namemax;

	fuse_reply_statfs(req, &stat);
}
Пример #2
0
void mfs_meta_statfs(fuse_req_t req, fuse_ino_t ino) {
#else
void mfs_meta_statfs(fuse_req_t req) {
#endif
	uint64_t totalspace,availspace,trashspace,reservedspace;
	uint32_t inodes;
	struct statvfs stfsbuf;
	memset(&stfsbuf,0,sizeof(stfsbuf));

#if FUSE_USE_VERSION >= 26
	(void)ino;
#endif
	fs_statfs(&totalspace,&availspace,&trashspace,&reservedspace,&inodes);

	stfsbuf.f_namemax = NAME_MAX;
	stfsbuf.f_frsize = 512;
	stfsbuf.f_bsize = 512;
	stfsbuf.f_blocks = trashspace/512+reservedspace/512;
	stfsbuf.f_bfree = reservedspace/512;
	stfsbuf.f_bavail = reservedspace/512;
	stfsbuf.f_files = 1000000000+PKGVERSION;
	stfsbuf.f_ffree = 1000000000+PKGVERSION;
	stfsbuf.f_favail = 1000000000+PKGVERSION;

	fuse_reply_statfs(req,&stfsbuf);
}
Пример #3
0
static void do_statfs(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
	(void) nodeid;
	(void) inarg;

	if (req->f->op.statfs)
		req->f->op.statfs(req, nodeid);
	else {
		struct statvfs buf = {
			.f_namemax = 255,
			.f_bsize = 512,
		};
		fuse_reply_statfs(req, &buf);
	}
}

static void do_setxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
	struct fuse_setxattr_in *arg = (struct fuse_setxattr_in *) inarg;
	char *name = PARAM(arg);
	char *value = name + strlen(name) + 1;

	if (req->f->op.setxattr)
#ifdef __APPLE__
		req->f->op.setxattr(req, nodeid, name, value, arg->size,
				    arg->flags, arg->position);
#else
		req->f->op.setxattr(req, nodeid, name, value, arg->size,
				    arg->flags);
#endif
	else
		fuse_reply_err(req, ENOSYS);
}
static void do_statfs(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
	(void) nodeid;
	(void) inarg;

	if (req->f->op.statfs)
		req->f->op.statfs(req, nodeid);
	else {
		struct statvfs buf = {
			.f_namemax = 255,
			.f_bsize = 512,
		};
		fuse_reply_statfs(req, &buf);
	}
}

static void do_setxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
	struct fuse_setxattr_in *arg = (struct fuse_setxattr_in *) inarg;
	char *name = PARAM(arg);
	char *value = name + strlen(name) + 1;

	if (req->f->op.setxattr)
		req->f->op.setxattr(req, nodeid, name, value, arg->size,
				    arg->flags);
	else
		fuse_reply_err(req, ENOSYS);
}

static void do_getxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
	struct fuse_getxattr_in *arg = (struct fuse_getxattr_in *) inarg;

	if (req->f->op.getxattr)
		req->f->op.getxattr(req, nodeid, PARAM(arg), arg->size);
	else
		fuse_reply_err(req, ENOSYS);
}

static void do_listxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
	struct fuse_getxattr_in *arg = (struct fuse_getxattr_in *) inarg;

	if (req->f->op.listxattr)
		req->f->op.listxattr(req, nodeid, arg->size);
	else
		fuse_reply_err(req, ENOSYS);
}

static void do_removexattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
	char *name = (char *) inarg;

	if (req->f->op.removexattr)
		req->f->op.removexattr(req, nodeid, name);
	else
		fuse_reply_err(req, ENOSYS);
}
int fuse_reply_statfs_compat(fuse_req_t req, const struct statfs *stbuf)
{
	struct statvfs newbuf;

	memset(&newbuf, 0, sizeof(newbuf));
	convert_statfs_compat(stbuf, &newbuf);

	return fuse_reply_statfs(req, &newbuf);
}
Пример #6
0
static void serve_statfs(fuse_req_t req)
{
	Dprintf("%s()\n", __FUNCTION__);
	struct statvfs st; // For more info, see: man 2 statvfs
	int r;

	r = CALL(reqcfs(req), get_metadata, 0, FSTITCH_FEATURE_BLOCKSIZE, sizeof(st.f_frsize), &st.f_frsize);
	if (r < 0)
		goto serve_statfs_err;
	else if (sizeof(st.f_bsize) != r)
	{
		r = -1;
		goto serve_statfs_err;
	}
	st.f_bsize = st.f_frsize;

	r = CALL(reqcfs(req), get_metadata, 0, FSTITCH_FEATURE_DEVSIZE, sizeof(st.f_blocks), &st.f_blocks);
	if (sizeof(st.f_blocks) != r)
		st.f_blocks = st.f_bfree = st.f_bavail = 0;
	else
	{
		r = CALL(reqcfs(req), get_metadata, 0, FSTITCH_FEATURE_FREESPACE, sizeof(st.f_bavail), &st.f_bavail);
		if (sizeof(st.f_bavail) != r)
			st.f_bfree = st.f_bavail = 0;
		else
			st.f_bfree = st.f_bavail;
	}

	// TODO - add lfs features for these guys
	st.f_files = 0;
	st.f_ffree = st.f_favail = 0;
	st.f_flag = 0;
	st.f_namemax = NAME_MAX;

	r = fuse_reply_statfs(req, &st);
	fuse_reply_assert(!r);
	return;

serve_statfs_err:
	r = fuse_reply_err(req, -r);
	fuse_reply_assert(!r);
	return;
}
static void do_statfs(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
    (void) nodeid;
    (void) inarg;

    if (req->f->op.statfs)
        req->f->op.statfs(req, nodeid);
    else {
#if HAVE_SYS_STATVFS_H		
        struct statfs buf = {
            .f_namelen = 255,
            .f_bsize = 512,
        };
        fuse_reply_statfs(req, &buf);
#endif		
    }
}

static void do_setxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
    const struct fuse_setxattr_in *arg = (const struct fuse_setxattr_in *) inarg;
    const char *name = PARAM(arg);
    const char *value = name + strlen(name) + 1;

    if (req->f->op.setxattr)
        req->f->op.setxattr(req, nodeid, name, value, arg->size, arg->flags);
    else
        fuse_reply_err(req, ENOSYS);
}

static void do_getxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
    const struct fuse_getxattr_in *arg = (const struct fuse_getxattr_in *) inarg;

    if (req->f->op.getxattr)
        req->f->op.getxattr(req, nodeid, PARAM(arg), arg->size);
    else
        fuse_reply_err(req, ENOSYS);
}

static void do_listxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
    const struct fuse_getxattr_in *arg = (const struct fuse_getxattr_in *) inarg;

    if (req->f->op.listxattr)
        req->f->op.listxattr(req, nodeid, arg->size);
    else
        fuse_reply_err(req, ENOSYS);
}

static void do_removexattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
    const char *name = (const char *) inarg;

    if (req->f->op.removexattr)
        req->f->op.removexattr(req, nodeid, name);
    else
        fuse_reply_err(req, ENOSYS);
}

static void convert_fuse_file_lock(const struct fuse_file_lock *fl,
                                   struct flock *flock)
{
    memset(flock, 0, sizeof(struct flock));
    flock->l_type = fl->type;
    flock->l_whence = SEEK_SET;
    flock->l_start = fl->start;
    if (fl->end == OFFSET_MAX)
        flock->l_len = 0;
    else
        flock->l_len = fl->end - fl->start + 1;
    flock->l_pid = fl->pid;
}