Index: sys/fs/fuse/fuse_node.h =================================================================== --- sys/fs/fuse/fuse_node.h +++ sys/fs/fuse/fuse_node.h @@ -121,15 +121,13 @@ }; /* - * This overlays the fid structure (see mount.h). Mostly the same as the types - * used by UFS and ext2. + * This overlays the fid structure fid_data field (see mount.h). */ -struct fuse_fid { - uint16_t len; /* Length of structure. */ - uint16_t pad; /* Force 32-bit alignment. */ - uint32_t gen; /* Generation number. */ - uint64_t nid; /* FUSE node id. */ +struct fuse_fid_data { + uint32_t ffd_gen; /* Generation number. */ + uint64_t ffd_nid; /* FUSE node id. */ }; +CTASSERT(sizeof(struct fuse_fid_data) <= MAXFIDSZ); #define VTOFUD(vp) \ ((struct fuse_vnode_data *)((vp)->v_data)) Index: sys/fs/fuse/fuse_vfsops.c =================================================================== --- sys/fs/fuse/fuse_vfsops.c +++ sys/fs/fuse/fuse_vfsops.c @@ -269,21 +269,26 @@ fuse_vfsop_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) { - struct fuse_fid *ffhp = (struct fuse_fid *)fhp; + struct fuse_fid_data *ffhp; struct fuse_vnode_data *fvdat; struct vnode *nvp; int error; + if (fhp->fid_len != sizeof(struct fuse_fid_data)) + return (EINVAL); + + ffhp = (struct fuse_fid_data *)&fhp->fid_data[0]; + if (!(fuse_get_mpdata(mp)->dataflags & FSESS_EXPORT_SUPPORT)) - return EOPNOTSUPP; + return (EOPNOTSUPP); - error = VFS_VGET(mp, ffhp->nid, LK_EXCLUSIVE, &nvp); + error = VFS_VGET(mp, ffhp->ffd_nid, LK_EXCLUSIVE, &nvp); if (error) { *vpp = NULLVP; return (error); } fvdat = VTOFUD(nvp); - if (fvdat->generation != ffhp->gen ) { + if (fvdat->generation != ffhp->ffd_gen) { vput(nvp); *vpp = NULLVP; return (ESTALE); Index: sys/fs/fuse/fuse_vnops.c =================================================================== --- sys/fs/fuse/fuse_vnops.c +++ sys/fs/fuse/fuse_vnops.c @@ -2473,41 +2473,37 @@ * This will only work for FUSE file systems that guarantee the uniqueness of * nodeid:generation, which most don't. */ +static int +fuse_vnop_vptofh(struct vop_vptofh_args *ap) /* vop_vptofh { IN struct vnode *a_vp; IN struct fid *a_fhp; }; */ -static int -fuse_vnop_vptofh(struct vop_vptofh_args *ap) { struct vnode *vp = ap->a_vp; + struct fid *fhp = ap->a_fhp; struct fuse_vnode_data *fvdat = VTOFUD(vp); - struct fuse_fid *fhp = (struct fuse_fid *)(ap->a_fhp); - _Static_assert(sizeof(struct fuse_fid) <= sizeof(struct fid), - "FUSE fid type is too big"); + struct fuse_fid_data *ffhp; struct mount *mp = vnode_mount(vp); struct fuse_data *data = fuse_get_mpdata(mp); struct vattr va; int err; if (!(data->dataflags & FSESS_EXPORT_SUPPORT)) - return EOPNOTSUPP; + return (EOPNOTSUPP); + if (fvdat->generation > UINT32_MAX) + return (EOVERFLOW); err = fuse_internal_getattr(vp, &va, curthread->td_ucred, curthread); if (err) - return err; + return (err); - /*ip = VTOI(ap->a_vp);*/ - /*ufhp = (struct ufid *)ap->a_fhp;*/ - fhp->len = sizeof(struct fuse_fid); - fhp->nid = fvdat->nid; - if (fvdat->generation <= UINT32_MAX) - fhp->gen = fvdat->generation; - else - return EOVERFLOW; + fhp->fid_len = sizeof(struct fuse_fid_data); + ffhp = (struct fuse_fid_data *)&fhp->fid_data[0]; + ffhp->ffd_nid = fvdat->nid; + ffhp->ffd_gen = fvdat->generation; + return (0); } - -