-/* $OpenBSD: fuse_vnops.c,v 1.16 2014/03/18 08:51:53 mpi Exp $ */
+/* $OpenBSD: fuse_vnops.c,v 1.17 2014/05/19 13:55:29 syl Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;
if (!fmp->sess_init)
- return (0);
+ return (ENXIO);
isdir = 0;
if (ip->vtype == VDIR)
ip = VTOI(ap->a_vp);
fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;
- if (!fmp->sess_init || (fmp->undef_op & UNDEF_ACCESS))
+ if (!fmp->sess_init)
+ return (ENXIO);
+
+ if (fmp->undef_op & UNDEF_ACCESS)
goto system_check;
if (ap->a_vp->v_type == VLNK)
fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;
if (!fmp->sess_init)
- goto fake;
+ return (ENXIO);
fbuf = fb_setup(0, ip->ufs_ino.i_number, FBT_GETATTR, p);
memcpy(vap, &fbuf->fb_vattr, sizeof(*vap));
fb_delete(fbuf);
return (error);
-fake:
- bzero(vap, sizeof(*vap));
- vap->va_type = vp->v_type;
- return (0);
}
int
((int)vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL))
return (EINVAL);
- if (!fmp->sess_init || (fmp->undef_op & UNDEF_SETATTR))
+ if (!fmp->sess_init)
return (ENXIO);
+ if (fmp->undef_op & UNDEF_SETATTR)
+ return (ENOSYS);
+
fbuf = fb_setup(sizeof(*io), ip->ufs_ino.i_number, FBT_SETATTR, p);
io = fbtod(fbuf, struct fb_io *);
io->fi_flags = 0;
struct fusebuf *fbuf;
int error = 0;
+ ip = VTOI(vp);
+ dip = VTOI(dvp);
+ fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;
+
+ if (!fmp->sess_init) {
+ VOP_ABORTOP(dvp, cnp);
+ error = ENXIO;
+ goto out2;
+ }
+ if (fmp->undef_op & UNDEF_LINK) {
+ VOP_ABORTOP(dvp, cnp);
+ error = ENOSYS;
+ goto out2;
+ }
if (vp->v_type == VDIR) {
VOP_ABORTOP(dvp, cnp);
error = EISDIR;
goto out2;
}
- ip = VTOI(vp);
- dip = VTOI(dvp);
- fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;
-
- if (!fmp->sess_init || (fmp->undef_op & UNDEF_LINK))
- goto out1;
-
fbuf = fb_setup(cnp->cn_namelen + 1, dip->ufs_ino.i_number,
FBT_LINK, p);
dp = VTOI(dvp);
fmp = (struct fusefs_mnt *)dp->ufs_ino.i_ump;
- if (!fmp->sess_init || (fmp->undef_op & UNDEF_SYMLINK)) {
+ if (!fmp->sess_init) {
+ error = ENXIO;
+ goto bad;
+ }
+
+ if (fmp->undef_op & UNDEF_SYMLINK) {
error = ENOSYS;
goto bad;
}
fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;
if (!fmp->sess_init)
- return (0);
+ return (ENXIO);
if (uio->uio_resid < sizeof(struct dirent))
return (EINVAL);
uio = ap->a_uio;
p = uio->uio_procp;
- if (!fmp->sess_init || (fmp->undef_op & UNDEF_READLINK)) {
- error = ENOSYS;
- goto out;
- }
+ if (!fmp->sess_init)
+ return (ENXIO);
+
+ if (fmp->undef_op & UNDEF_READLINK)
+ return (ENOSYS);
fbuf = fb_setup(0, ip->ufs_ino.i_number, FBT_READLINK, p);
fmp->undef_op |= UNDEF_READLINK;
fb_delete(fbuf);
- goto out;
+ return (error);
}
error = uiomove(fbuf->fb_dat, fbuf->fb_len, uio);
fb_delete(fbuf);
-out:
+
return (error);
}
fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;
mode = MAKEIMODE(vap->va_type, vap->va_mode);
- if (!fmp->sess_init || (fmp->undef_op & UNDEF_CREATE)) {
+ if (!fmp->sess_init) {
+ error = ENXIO;
+ goto out;
+ }
+
+ if (fmp->undef_op & UNDEF_CREATE) {
error = ENOSYS;
goto out;
}
ip = VTOI(dvp);
fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;
- if (!fmp->sess_init || (fmp->undef_op & UNDEF_MKNOD)) {
+ if (!fmp->sess_init) {
+ error = ENXIO;
+ goto out;
+ }
+
+ if (fmp->undef_op & UNDEF_MKNOD) {
error = ENOSYS;
goto out;
}
}
VN_KNOTE(fdvp, NOTE_WRITE); /* XXX right place? */
- if (!fmp->sess_init || (fmp->undef_op & UNDEF_RENAME)) {
+ if (!fmp->sess_init) {
+ error = ENXIO;
+ VOP_UNLOCK(fvp, 0, p);
+ goto abortit;
+ }
+
+ if (fmp->undef_op & UNDEF_RENAME) {
error = ENOSYS;
VOP_UNLOCK(fvp, 0, p);
goto abortit;
fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;
- if (!fmp->sess_init || (fmp->undef_op & UNDEF_MKDIR)) {
+ if (!fmp->sess_init) {
+ error = ENXIO;
+ goto out;
+ }
+
+ if (fmp->undef_op & UNDEF_MKDIR) {
error = ENOSYS;
goto out;
}
dp = VTOI(dvp);
fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;
+ if (!fmp->sess_init) {
+ error = ENXIO;
+ goto out;
+ }
+
+ if (fmp->undef_op & UNDEF_RMDIR) {
+ error = ENOSYS;
+ goto out;
+ }
+
/*
* No rmdir "." please.
*/
return (EINVAL);
}
- if (!fmp->sess_init || (fmp->undef_op & UNDEF_RMDIR)) {
- error = ENOSYS;
- goto out;
- }
-
VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
fbuf = fb_setup(cnp->cn_namelen + 1, dp->ufs_ino.i_number,
dp = VTOI(dvp);
fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump;
- if (!fmp->sess_init || (fmp->undef_op & UNDEF_REMOVE)) {
+ if (!fmp->sess_init) {
+ error = ENXIO;
+ goto out;
+ }
+
+ if (fmp->undef_op & UNDEF_REMOVE) {
error = ENOSYS;
goto out;
}