-/* $OpenBSD: fuse_ops.c,v 1.24 2014/02/05 20:13:58 syl Exp $ */
+/* $OpenBSD: fuse_ops.c,v 1.25 2016/08/30 16:45:54 natano Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
return (0); \
}
-static void
-stat2attr(struct vattr *v, struct stat *st)
-{
- v->va_fileid = st->st_ino;
- v->va_bytes = st->st_blocks;
- v->va_mode = st->st_mode;
- v->va_nlink = st->st_nlink;
- v->va_uid = st->st_uid;
- v->va_gid = st->st_gid;
- v->va_rdev = st->st_rdev;
- v->va_size = st->st_size;
- v->va_blocksize = st->st_blksize;
- v->va_atime.tv_sec = st->st_atime;
- v->va_atime.tv_nsec = st->st_atimensec;
- v->va_mtime.tv_sec = st->st_mtime;
- v->va_mtime.tv_nsec = st->st_mtimensec;
- v->va_ctime.tv_sec = st->st_ctime;
- v->va_ctime.tv_nsec = st->st_ctimensec;
-}
-
static int
-update_vattr(struct fuse *f, struct vattr *attr, const char *realname,
+update_attr(struct fuse *f, struct stat *attr, const char *realname,
struct fuse_vnode *vn)
{
- struct stat st;
int ret;
- bzero(&st, sizeof(st));
- ret = f->op.getattr(realname, &st);
+ memset(attr, 0, sizeof(struct stat));
+ ret = f->op.getattr(realname, attr);
- if (st.st_blksize == 0)
- st.st_blksize = 512;
- if (st.st_blocks == 0)
- st.st_blocks = 4;
+ if (attr->st_blksize == 0)
+ attr->st_blksize = 512;
+ if (attr->st_blocks == 0)
+ attr->st_blocks = 4;
- st.st_ino = vn->ino;
+ attr->st_ino = vn->ino;
if (f->conf.set_mode)
- st.st_mode = (st.st_mode & S_IFMT) | (0777 & ~f->conf.umask);
+ attr->st_mode = (attr->st_mode & S_IFMT) | (0777 & ~f->conf.umask);
if (f->conf.set_uid)
- st.st_uid = f->conf.uid;
+ attr->st_uid = f->conf.uid;
if (f->conf.set_gid)
- st.st_gid = f->conf.gid;
-
- stat2attr(attr, &st);
+ attr->st_gid = f->conf.gid;
return (ret);
}
DPRINTF("Opcode:\tgetattr\n");
DPRINTF("Inode:\t%llu\n", (unsigned long long)fbuf->fb_ino);
- bzero(&fbuf->fb_vattr, sizeof(fbuf->fb_vattr));
+ memset(&fbuf->fb_attr, 0, sizeof(struct stat));
vn = tree_get(&f->vnode_tree, fbuf->fb_ino);
if (vn == NULL) {
return (0);
}
- fbuf->fb_err = update_vattr(f, &fbuf->fb_vattr, realname, vn);
+ fbuf->fb_err = update_attr(f, &fbuf->fb_attr, realname, vn);
free(realname);
return (0);
return (0);
}
- fbuf->fb_err = update_vattr(f, &fbuf->fb_vattr, realname, vn);
+ fbuf->fb_err = update_attr(f, &fbuf->fb_attr, realname, vn);
free(fbuf->fb_dat);
free(realname);
fbuf->fb_err = -ENOSYS;
if (!fbuf->fb_err) {
- fbuf->fb_err = update_vattr(f, &fbuf->fb_vattr, realname, vn);
- fbuf->fb_ino = fbuf->fb_vattr.va_fileid;
- fbuf->fb_io_mode = fbuf->fb_vattr.va_mode;
+ fbuf->fb_err = update_attr(f, &fbuf->fb_attr, realname, vn);
+ fbuf->fb_ino = fbuf->fb_attr.st_ino;
+ fbuf->fb_io_mode = fbuf->fb_attr.st_mode;
}
free(realname);
fbuf->fb_err = f->op.mkdir(realname, mode);
if (!fbuf->fb_err) {
- fbuf->fb_err = update_vattr(f, &fbuf->fb_vattr, realname, vn);
- fbuf->fb_io_mode = fbuf->fb_vattr.va_mode;
+ fbuf->fb_err = update_attr(f, &fbuf->fb_attr, realname, vn);
+ fbuf->fb_io_mode = fbuf->fb_attr.st_mode;
fbuf->fb_ino = vn->ino;
}
free(realname);
if (io->fi_flags & FUSE_FATTR_MODE) {
if (f->op.chmod)
fbuf->fb_err = f->op.chmod(realname,
- fbuf->fb_vattr.va_mode);
+ fbuf->fb_attr.st_mode);
else
fbuf->fb_err = -ENOSYS;
}
if (!fbuf->fb_err && (io->fi_flags & FUSE_FATTR_UID ||
io->fi_flags & FUSE_FATTR_GID) ) {
uid = (io->fi_flags & FUSE_FATTR_UID) ?
- fbuf->fb_vattr.va_uid : (gid_t)-1;
+ fbuf->fb_attr.st_uid : (gid_t)-1;
gid = (io->fi_flags & FUSE_FATTR_GID) ?
- fbuf->fb_vattr.va_gid : (uid_t)-1;
+ fbuf->fb_attr.st_gid : (uid_t)-1;
if (f->op.chown)
fbuf->fb_err = f->op.chown(realname, uid, gid);
else
if (!fbuf->fb_err && ( io->fi_flags & FUSE_FATTR_MTIME ||
io->fi_flags & FUSE_FATTR_ATIME)) {
- ts[0].tv_sec = fbuf->fb_vattr.va_atime.tv_sec;
- ts[0].tv_nsec = fbuf->fb_vattr.va_atime.tv_nsec;
- ts[1].tv_sec = fbuf->fb_vattr.va_mtime.tv_sec;
- ts[1].tv_nsec = fbuf->fb_vattr.va_mtime.tv_nsec;
+ ts[0] = fbuf->fb_attr.st_atim;
+ ts[1] = fbuf->fb_attr.st_mtim;
tbuf.actime = ts[0].tv_sec;
tbuf.modtime = ts[1].tv_sec;
if (!fbuf->fb_err && (io->fi_flags & FUSE_FATTR_SIZE)) {
if (f->op.truncate)
fbuf->fb_err = f->op.truncate(realname,
- fbuf->fb_vattr.va_size);
+ fbuf->fb_attr.st_size);
else
fbuf->fb_err = -ENOSYS;
}
- bzero(&fbuf->fb_vattr, sizeof(fbuf->fb_vattr));
+ memset(&fbuf->fb_attr, 0, sizeof(struct stat));
if (!fbuf->fb_err)
- fbuf->fb_err = update_vattr(f, &fbuf->fb_vattr, realname, vn);
+ fbuf->fb_err = update_attr(f, &fbuf->fb_attr, realname, vn);
free(realname);
free(fbuf->fb_dat);
fbuf->fb_err = f->op.mknod(realname, mode, dev);
if (!fbuf->fb_err) {
- fbuf->fb_err = update_vattr(f, &fbuf->fb_vattr, realname, vn);
- fbuf->fb_io_mode = fbuf->fb_vattr.va_mode;
- fbuf->fb_ino = fbuf->fb_vattr.va_fileid;
+ fbuf->fb_err = update_attr(f, &fbuf->fb_attr, realname, vn);
+ fbuf->fb_io_mode = fbuf->fb_attr.st_mode;
+ fbuf->fb_ino = fbuf->fb_attr.st_ino;
}
free(realname);
-/* $OpenBSD: fuse_private.h,v 1.12 2016/08/27 01:57:27 guenther Exp $ */
+/* $OpenBSD: fuse_private.h,v 1.13 2016/08/30 16:45:54 natano Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
#define _FUSE_SUBR_H_
#include <sys/dirent.h>
+#include <sys/event.h>
#include <sys/mount.h>
+#include <sys/stat.h>
#include <sys/statvfs.h>
-#include <sys/time.h>
-#include <sys/vnode.h>
+#include <sys/tree.h>
#include <sys/fusebuf.h>
#include <limits.h>
-.\" $OpenBSD: fb_setup.9,v 1.5 2016/05/16 20:12:20 jmc Exp $
+.\" $OpenBSD: fb_setup.9,v 1.6 2016/08/30 16:45:54 natano Exp $
.\"
.\" Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 16 2016 $
+.Dd $Mdocdate: August 30 2016 $
.Dt FB_SETUP 9
.Os
.Sh NAME
struct fb_hdr fb_hdr;
union {
struct statvfs FD_stat;
- struct vattr FD_vattr;
+ struct stat FD_attr;
struct fb_io FD_io;
} FD;
- uint8_t *F_databuf;
+ uint8_t *fb_dat;
};
#define fb_next fb_hdr.fh_next
#define fb_uuid fb_hdr.fh_uuid
#define fb_stat FD.FD_stat
-#define fb_vattr FD.FD_vattr
+#define fb_attr FD.FD_attr
#define fb_io_fd FD.FD_io.fi_fd
#define fb_io_ino FD.FD_io.fi_ino
#define fb_io_off FD.FD_io.fi_off
#define fb_io_len FD.FD_io.fi_len
#define fb_io_mode FD.FD_io.fi_mode
#define fb_io_flags FD.FD_io.fi_flags
-#define fb_dat F_databuf
.Ed
.Sh DESCRIPTION
These functions provide a way to manage the kernel messaging mechanism for
A struct
.Xr statvfs 3
filled in by the FUSE client statfs for the FUSE VFS statfs code.
-.It Fa FD_vattr
+.It Fa FD_attr
Used by the getattr and setattr calls.
.It Fa FD_io
Contains all fields commonly used by FUSE client callbacks to
mkdir, and setattr.
.El
.Pp
-Setattr uses a struct fb_io and a struct vattr.
+Setattr uses a struct fb_io and a struct stat.
Settattr uses
.Fa FD_stat
and encapsulates a struct fb_io in
-/* $OpenBSD: fuse_device.c,v 1.20 2016/01/22 17:09:43 stefan Exp $ */
+/* $OpenBSD: fuse_device.c,v 1.21 2016/08/30 16:45:54 natano Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/poll.h>
+#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/vnode.h>
#include <sys/fusebuf.h>
-/* $OpenBSD: fuse_file.c,v 1.8 2014/03/18 08:51:53 mpi Exp $ */
+/* $OpenBSD: fuse_file.c,v 1.9 2016/08/30 16:45:54 natano Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/vnode.h>
#include <sys/fusebuf.h>
-/* $OpenBSD: fuse_lookup.c,v 1.14 2016/08/21 09:23:33 natano Exp $ */
+/* $OpenBSD: fuse_lookup.c,v 1.15 2016/08/30 16:45:54 natano Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
#include <sys/systm.h>
#include <sys/mount.h>
#include <sys/namei.h>
+#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/vnode.h>
#include <sys/lock.h>
goto out;
}
- nid = fbuf->fb_vattr.va_fileid;
+ nid = fbuf->fb_attr.st_ino;
}
if (nameiop == DELETE && (flags & ISLASTCN)) {
if (error)
goto out;
- tdp->v_type = IFTOVT(fbuf->fb_vattr.va_mode);
+ tdp->v_type = IFTOVT(fbuf->fb_attr.st_mode);
*vpp = tdp;
cnp->cn_flags |= SAVENAME;
if (error)
goto out;
- tdp->v_type = IFTOVT(fbuf->fb_vattr.va_mode);
+ tdp->v_type = IFTOVT(fbuf->fb_attr.st_mode);
if (vdp != NULL && vdp->v_type == VDIR)
VTOI(tdp)->parent = dp->ufs_ino.i_number;
-/* $OpenBSD: fuse_vfsops.c,v 1.26 2016/08/15 07:39:46 natano Exp $ */
+/* $OpenBSD: fuse_vfsops.c,v 1.27 2016/08/30 16:45:54 natano Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
#include <sys/pool.h>
#include <sys/proc.h>
#include <sys/specdev.h>
+#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/sysctl.h>
#include <sys/vnode.h>
-/* $OpenBSD: fuse_vnops.c,v 1.31 2016/08/21 09:23:33 natano Exp $ */
+/* $OpenBSD: fuse_vnops.c,v 1.32 2016/08/30 16:45:54 natano Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
#include <sys/poll.h>
#include <sys/proc.h>
#include <sys/specdev.h>
+#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/vnode.h>
#include <sys/lock.h>
struct proc *p = ap->a_p;
struct fusefs_node *ip;
struct fusebuf *fbuf;
+ struct stat *st;
int error = 0;
ip = VTOI(vp);
return (error);
}
- memcpy(vap, &fbuf->fb_vattr, sizeof(*vap));
+ VATTR_NULL(vap);
+ st = &fbuf->fb_attr;
+ vap->va_type = IFTOVT(st->st_mode);
+ vap->va_mode = st->st_mode & ~S_IFMT;
+ vap->va_nlink = st->st_nlink;
+ vap->va_uid = st->st_uid;
+ vap->va_gid = st->st_gid;
vap->va_fsid = fmp->mp->mnt_stat.f_fsid.val[0];
- vap->va_type = IFTOVT(vap->va_mode);
- vap->va_bytes *= S_BLKSIZE;
- vap->va_mode &= ~S_IFMT;
+ vap->va_fileid = st->st_ino;
+ vap->va_size = st->st_size;
+ vap->va_blocksize = st->st_blksize;
+ vap->va_atime = st->st_atim;
+ vap->va_mtime = st->st_mtim;
+ vap->va_ctime = st->st_ctim;
+ vap->va_rdev = st->st_rdev;
+ vap->va_bytes = st->st_blocks * S_BLKSIZE;
fb_delete(fbuf);
return (error);
error = EROFS;
goto out;
}
- fbuf->fb_vattr.va_uid = vap->va_uid;
+ fbuf->fb_attr.st_uid = vap->va_uid;
io->fi_flags |= FUSE_FATTR_UID;
}
error = EROFS;
goto out;
}
- fbuf->fb_vattr.va_gid = vap->va_gid;
+ fbuf->fb_attr.st_gid = vap->va_gid;
io->fi_flags |= FUSE_FATTR_GID;
}
break;
}
- fbuf->fb_vattr.va_size = vap->va_size;
+ fbuf->fb_attr.st_size = vap->va_size;
io->fi_flags |= FUSE_FATTR_SIZE;
}
error = EROFS;
goto out;
}
- fbuf->fb_vattr.va_atime.tv_sec = vap->va_atime.tv_sec;
- fbuf->fb_vattr.va_atime.tv_nsec = vap->va_atime.tv_nsec;
+ fbuf->fb_attr.st_atim = vap->va_atime;
io->fi_flags |= FUSE_FATTR_ATIME;
}
error = EROFS;
goto out;
}
- fbuf->fb_vattr.va_mtime.tv_sec = vap->va_mtime.tv_sec;
- fbuf->fb_vattr.va_mtime.tv_nsec = vap->va_mtime.tv_nsec;
+ fbuf->fb_attr.st_mtim = vap->va_mtime;
io->fi_flags |= FUSE_FATTR_MTIME;
}
/* XXX should set a flag if (vap->va_vaflags & VA_UTIMES_CHANGE) */
error = EROFS;
goto out;
}
- fbuf->fb_vattr.va_mode = vap->va_mode & ALLPERMS;
+ fbuf->fb_attr.st_mode = vap->va_mode & ALLPERMS;
io->fi_flags |= FUSE_FATTR_MODE;
}
goto out;
}
- if (io->fi_flags & FUSE_FATTR_SIZE && vp->v_type == VDIR) {
- error = EISDIR;
- goto out;
- }
-
error = fb_queue(fmp->dev, fbuf);
if (error) {
if (error == ENOSYS)
-/* $OpenBSD: fusebuf.c,v 1.11 2015/03/14 03:38:51 jsg Exp $ */
+/* $OpenBSD: fusebuf.c,v 1.12 2016/08/30 16:45:54 natano Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/pool.h>
+#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/systm.h>
#include <sys/vnode.h>
-/* $OpenBSD: fusebuf.h,v 1.10 2016/08/13 11:42:46 natano Exp $ */
+/* $OpenBSD: fusebuf.h,v 1.11 2016/08/30 16:45:54 natano Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon
* Copyright (c) 2013 Martin Pieuchot
struct fb_hdr fb_hdr;
union {
struct statvfs FD_stat; /* vfs statfs */
- struct vattr FD_vattr; /* for attr vnops */
+ struct stat FD_attr; /* for attr vnops */
struct fb_io FD_io; /* for file io vnops */
} FD;
- uint8_t *F_databuf; /* data's */
+ uint8_t *fb_dat; /* data's */
};
#define fb_next fb_hdr.fh_next
#define fb_uuid fb_hdr.fh_uuid
#define fb_stat FD.FD_stat
-#define fb_vattr FD.FD_vattr
+#define fb_attr FD.FD_attr
#define fb_io_fd FD.FD_io.fi_fd
#define fb_io_ino FD.FD_io.fi_ino
#define fb_io_off FD.FD_io.fi_off
#define fb_io_mode FD.FD_io.fi_mode
#define fb_io_flags FD.FD_io.fi_flags
#define fb_io_rdev FD.FD_io.fi_rdev
-#define fb_dat F_databuf
/*
* Macros for type conversion