From 72b3e305af69d13145eebcf173957ec0e3a33195 Mon Sep 17 00:00:00 2001 From: Peter Edwards Date: Sat, 29 Jan 2005 16:23:39 +0000 Subject: [PATCH] Unbreak a few filesystems for which vnode_create_vobject() wasn't being called in "open", causing mmap() to fail. Where possible, pass size of file to vnode_create_vobject() rather than having it find it out the hard way via VOP_LOOKUP Reviewed by: phk --- sys/fs/cd9660/cd9660_vfsops.c | 2 +- sys/fs/cd9660/cd9660_vnops.c | 19 +++++++++++++++++++ sys/fs/msdosfs/msdosfs_vnops.c | 17 +++++++++++++++++ sys/fs/smbfs/smbfs_vnops.c | 4 +++- sys/isofs/cd9660/cd9660_vfsops.c | 2 +- sys/isofs/cd9660/cd9660_vnops.c | 19 +++++++++++++++++++ 6 files changed, 60 insertions(+), 3 deletions(-) diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index 3d484c9e1363..5830f03ab688 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -616,7 +616,7 @@ cd9660_fhtovp(mp, fhp, vpp) return (ESTALE); } *vpp = nvp; - vnode_create_vobject(*vpp, 0, curthread); + vnode_create_vobject(*vpp, ip->i_size, curthread); return (0); } diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c index bc45abe2909c..5b3d7233d302 100644 --- a/sys/fs/cd9660/cd9660_vnops.c +++ b/sys/fs/cd9660/cd9660_vnops.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include static vop_setattr_t cd9660_setattr; +static vop_open_t cd9660_open; static vop_access_t cd9660_access; static vop_getattr_t cd9660_getattr; static vop_ioctl_t cd9660_ioctl; @@ -155,6 +156,23 @@ cd9660_access(ap) ip->inode.iso_gid, ap->a_mode, ap->a_cred, NULL)); } +static int +cd9660_open(ap) + struct vop_open_args /* { + struct vnode *a_vp; + int a_mode; + struct ucred *a_cred; + struct thread *a_td; + int a_fdidx; + } */ *ap; +{ + struct iso_node *ip = VTOI(ap->a_vp); + + vnode_create_vobject(ap->a_vp, ip->i_size, ap->a_td); + return 0; +} + + static int cd9660_getattr(ap) struct vop_getattr_args /* { @@ -782,6 +800,7 @@ cd9660_pathconf(ap) */ struct vop_vector cd9660_vnodeops = { .vop_default = &default_vnodeops, + .vop_open = cd9660_open, .vop_access = cd9660_access, .vop_bmap = cd9660_bmap, .vop_cachedlookup = cd9660_lookup, diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index bbe4cb2214a1..636b92ae4638 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -87,6 +87,7 @@ static vop_advlock_t msdosfs_advlock; static vop_create_t msdosfs_create; static vop_mknod_t msdosfs_mknod; +static vop_open_t msdosfs_open; static vop_close_t msdosfs_close; static vop_access_t msdosfs_access; static vop_getattr_t msdosfs_getattr; @@ -208,6 +209,21 @@ msdosfs_mknod(ap) return (EINVAL); } +static int +msdosfs_open(ap) + struct vop_open_args /* { + struct vnode *a_vp; + int a_mode; + struct ucred *a_cred; + struct thread *a_td; + int a_fdidx; + } */ *ap; +{ + struct denode *dep = VTODE(ap->a_vp); + vnode_create_vobject(ap->a_vp, dep->de_FileSize, ap->a_td); + return 0; +} + static int msdosfs_close(ap) struct vop_close_args /* { @@ -1876,6 +1892,7 @@ struct vop_vector msdosfs_vnodeops = { .vop_advlock = msdosfs_advlock, .vop_bmap = msdosfs_bmap, .vop_cachedlookup = msdosfs_lookup, + .vop_open = msdosfs_open, .vop_close = msdosfs_close, .vop_create = msdosfs_create, .vop_fsync = msdosfs_fsync, diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c index fb0976f113ee..b75abd7fccf9 100644 --- a/sys/fs/smbfs/smbfs_vnops.c +++ b/sys/fs/smbfs/smbfs_vnops.c @@ -212,8 +212,10 @@ smbfs_open(ap) error = smbfs_smb_open(np, accmode, &scred); } } - if (error == 0) + if (error == 0) { np->n_flag |= NOPEN; + vnode_create_vobject(ap->a_vp, vattr.va_size, ap->a_td); + } smbfs_attr_cacheremove(vp); return error; } diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index 3d484c9e1363..5830f03ab688 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -616,7 +616,7 @@ cd9660_fhtovp(mp, fhp, vpp) return (ESTALE); } *vpp = nvp; - vnode_create_vobject(*vpp, 0, curthread); + vnode_create_vobject(*vpp, ip->i_size, curthread); return (0); } diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index bc45abe2909c..5b3d7233d302 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include static vop_setattr_t cd9660_setattr; +static vop_open_t cd9660_open; static vop_access_t cd9660_access; static vop_getattr_t cd9660_getattr; static vop_ioctl_t cd9660_ioctl; @@ -155,6 +156,23 @@ cd9660_access(ap) ip->inode.iso_gid, ap->a_mode, ap->a_cred, NULL)); } +static int +cd9660_open(ap) + struct vop_open_args /* { + struct vnode *a_vp; + int a_mode; + struct ucred *a_cred; + struct thread *a_td; + int a_fdidx; + } */ *ap; +{ + struct iso_node *ip = VTOI(ap->a_vp); + + vnode_create_vobject(ap->a_vp, ip->i_size, ap->a_td); + return 0; +} + + static int cd9660_getattr(ap) struct vop_getattr_args /* { @@ -782,6 +800,7 @@ cd9660_pathconf(ap) */ struct vop_vector cd9660_vnodeops = { .vop_default = &default_vnodeops, + .vop_open = cd9660_open, .vop_access = cd9660_access, .vop_bmap = cd9660_bmap, .vop_cachedlookup = cd9660_lookup,