From 422c9c215b3f4d9dde18865ab5c92cd51e8f5348 Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Tue, 21 Apr 1992 20:37:30 -0800 Subject: [PATCH] VOP_TRUNCATE now takes a cred argument SCCS-vsn: sys/miscfs/deadfs/dead_vnops.c 7.17 SCCS-vsn: sys/ufs/mfs/mfsnode.h 7.9 SCCS-vsn: sys/ufs/ffs/ufs_vnops.c 7.85 SCCS-vsn: sys/ufs/ufs/ufs_vnops.c 7.85 SCCS-vsn: sys/nfs/nfsnode.h 7.19 SCCS-vsn: sys/nfs/nfs_vnops.c 7.71 SCCS-vsn: sys/sys/vnode.h 7.49 SCCS-vsn: sys/ufs/lfs/lfs_vnops.c 7.79 SCCS-vsn: sys/ufs/lfs/lfs_inode.c 7.61 SCCS-vsn: sys/ufs/lfs/lfs_extern.h 7.13 --- usr/src/sys/miscfs/deadfs/dead_vnops.c | 5 +++-- usr/src/sys/nfs/nfs_vnops.c | 5 +++-- usr/src/sys/nfs/nfsnode.h | 5 +++-- usr/src/sys/sys/vnode.h | 6 +++--- usr/src/sys/ufs/ffs/ufs_vnops.c | 9 +++++---- usr/src/sys/ufs/lfs/lfs_extern.h | 4 ++-- usr/src/sys/ufs/lfs/lfs_inode.c | 5 +++-- usr/src/sys/ufs/lfs/lfs_vnops.c | 6 +++--- usr/src/sys/ufs/mfs/mfsnode.h | 5 +++-- usr/src/sys/ufs/ufs/ufs_vnops.c | 9 +++++---- 10 files changed, 33 insertions(+), 26 deletions(-) diff --git a/usr/src/sys/miscfs/deadfs/dead_vnops.c b/usr/src/sys/miscfs/deadfs/dead_vnops.c index fcaddc212d..5bf607394e 100644 --- a/usr/src/sys/miscfs/deadfs/dead_vnops.c +++ b/usr/src/sys/miscfs/deadfs/dead_vnops.c @@ -4,7 +4,7 @@ * * %sccs.include.redist.c% * - * @(#)dead_vnops.c 7.16 (Berkeley) %G% + * @(#)dead_vnops.c 7.17 (Berkeley) %G% */ #include "param.h" @@ -187,7 +187,8 @@ int dead_print __P(( #define dead_truncate ((int (*) __P(( \ struct vnode *vp, \ off_t length, \ - int flags))) nullop) + int flags, \ + struct ucred *cred))) nullop) #define dead_update ((int (*) __P(( \ struct vnode *vp, \ struct timeval *ta, \ diff --git a/usr/src/sys/nfs/nfs_vnops.c b/usr/src/sys/nfs/nfs_vnops.c index ddf037baf1..b20f06a08d 100644 --- a/usr/src/sys/nfs/nfs_vnops.c +++ b/usr/src/sys/nfs/nfs_vnops.c @@ -7,7 +7,7 @@ * * %sccs.include.redist.c% * - * @(#)nfs_vnops.c 7.70 (Berkeley) %G% + * @(#)nfs_vnops.c 7.71 (Berkeley) %G% */ /* @@ -2051,10 +2051,11 @@ nfs_vfree(pvp, ino, mode) * NFS file truncation. */ int -nfs_truncate(vp, length, flags) +nfs_truncate(vp, length, flags, cred) struct vnode *vp; off_t length; int flags; + struct ucred *cred; { /* Use nfs_setattr */ diff --git a/usr/src/sys/nfs/nfsnode.h b/usr/src/sys/nfs/nfsnode.h index 3fc6119769..ec117a533e 100644 --- a/usr/src/sys/nfs/nfsnode.h +++ b/usr/src/sys/nfs/nfsnode.h @@ -7,7 +7,7 @@ * * %sccs.include.redist.c% * - * @(#)nfsnode.h 7.18 (Berkeley) %G% + * @(#)nfsnode.h 7.19 (Berkeley) %G% */ /* @@ -254,7 +254,8 @@ void nfs_vfree __P(( int nfs_truncate __P(( struct vnode *vp, off_t length, - int flags)); + int flags, + struct ucred *cred)); int nfs_update __P(( struct vnode *vp, struct timeval *ta, diff --git a/usr/src/sys/sys/vnode.h b/usr/src/sys/sys/vnode.h index 74eade1bcb..c426c52603 100644 --- a/usr/src/sys/sys/vnode.h +++ b/usr/src/sys/sys/vnode.h @@ -235,9 +235,9 @@ struct vnodeops { int mode, struct ucred *cred, struct vnode **vpp)); #define VOP_VFREE(v,i,m) (*((v)->v_op->vop_vfree))(v,i,m) void (*vop_vfree) __P((struct vnode *pvp, ino_t ino, int mode)); -#define VOP_TRUNCATE(v,l,f) (*((v)->v_op->vop_truncate))(v,l,f) - int (*vop_truncate) - __P((struct vnode *vp, off_t length, int flags)); +#define VOP_TRUNCATE(v,l,f,c) (*((v)->v_op->vop_truncate))(v,l,f,c) + int (*vop_truncate) __P((struct vnode *vp, + off_t length, int flags, struct ucred *cred)); #define VOP_UPDATE(v,ta,tm,w) (*((v)->v_op->vop_update))(v,ta,tm,w) int (*vop_update) __P((struct vnode *vp, struct timeval *ta, struct timeval *tm, int waitfor)); diff --git a/usr/src/sys/ufs/ffs/ufs_vnops.c b/usr/src/sys/ufs/ffs/ufs_vnops.c index 1905d5445e..c3bf1351be 100644 --- a/usr/src/sys/ufs/ffs/ufs_vnops.c +++ b/usr/src/sys/ufs/ffs/ufs_vnops.c @@ -4,7 +4,7 @@ * * %sccs.include.redist.c% * - * @(#)ufs_vnops.c 7.84 (Berkeley) %G% + * @(#)ufs_vnops.c 7.85 (Berkeley) %G% */ #include @@ -289,7 +289,7 @@ ufs_setattr(vp, vap, cred, p) if (vap->va_size != VNOVAL) { if (vp->v_type == VDIR) return (EISDIR); - if (error = VOP_TRUNCATE(vp, vap->va_size, 0)) /* IO_SYNC? */ + if (error = VOP_TRUNCATE(vp, vap->va_size, 0, cred)) return (error); } ip = VTOI(vp); @@ -981,7 +981,8 @@ ufs_rename(fdvp, fvp, fcnp, if (doingdirectory) { if (--xp->i_nlink != 0) panic("rename: linked directory"); - error = VOP_TRUNCATE(ITOV(xp), (u_long)0, IO_SYNC); + error = VOP_TRUNCATE(ITOV(xp), (off_t)0, IO_SYNC, + tcnp->cn_cred); } xp->i_flag |= ICHG; ufs_iput(xp); @@ -1256,7 +1257,7 @@ ufs_rmdir(dvp, vp, cnp) * worry about them later. */ ip->i_nlink -= 2; - error = VOP_TRUNCATE(vp, (u_long)0, IO_SYNC); + error = VOP_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred); cache_purge(ITOV(ip)); out: if (dvp) diff --git a/usr/src/sys/ufs/lfs/lfs_extern.h b/usr/src/sys/ufs/lfs/lfs_extern.h index 311bf6a5d3..16e1368d8f 100644 --- a/usr/src/sys/ufs/lfs/lfs_extern.h +++ b/usr/src/sys/ufs/lfs/lfs_extern.h @@ -4,7 +4,7 @@ * * %sccs.include.redist.c% * - * @(#)lfs_extern.h 7.12 (Berkeley) %G% + * @(#)lfs_extern.h 7.13 (Berkeley) %G% */ struct fid; @@ -38,7 +38,7 @@ int lfs_root __P((struct mount *, struct vnode **)); int lfs_segwrite __P((struct mount *, int)); int lfs_statfs __P((struct mount *, struct statfs *, struct proc *)); int lfs_sync __P((struct mount *, int)); -int lfs_truncate __P((struct vnode *, off_t, int)); +int lfs_truncate __P((struct vnode *, off_t, int, struct ucred *)); int lfs_unmount __P((struct mount *, int, struct proc *)); int lfs_update __P((struct vnode *, struct timeval *, struct timeval *, int)); diff --git a/usr/src/sys/ufs/lfs/lfs_inode.c b/usr/src/sys/ufs/lfs/lfs_inode.c index 04c5510575..17197bda92 100644 --- a/usr/src/sys/ufs/lfs/lfs_inode.c +++ b/usr/src/sys/ufs/lfs/lfs_inode.c @@ -4,7 +4,7 @@ * * %sccs.include.redist.c% * - * @(#)lfs_inode.c 7.60 (Berkeley) %G% + * @(#)lfs_inode.c 7.61 (Berkeley) %G% */ #include @@ -215,10 +215,11 @@ lfs_update(vp, ta, tm, waitfor) */ /* ARGSUSED */ int -lfs_truncate(vp, length, flags) +lfs_truncate(vp, length, flags, cred) struct vnode *vp; off_t length; int flags; + struct ucred *cred; { register INDIR *ap; register int i; diff --git a/usr/src/sys/ufs/lfs/lfs_vnops.c b/usr/src/sys/ufs/lfs/lfs_vnops.c index 75018bba10..5cb8365f74 100644 --- a/usr/src/sys/ufs/lfs/lfs_vnops.c +++ b/usr/src/sys/ufs/lfs/lfs_vnops.c @@ -4,7 +4,7 @@ * * %sccs.include.redist.c% * - * @(#)lfs_vnops.c 7.78 (Berkeley) %G% + * @(#)lfs_vnops.c 7.79 (Berkeley) %G% */ #include @@ -324,7 +324,7 @@ lfs_write(vp, uio, ioflag, cred) ip->i_mode &= ~(ISUID|ISGID); } while (error == 0 && uio->uio_resid > 0 && n != 0); if (error && (ioflag & IO_UNIT)) { - (void)lfs_truncate(vp, osize, ioflag & IO_SYNC); + (void)lfs_truncate(vp, osize, ioflag & IO_SYNC, cred); uio->uio_offset -= resid - uio->uio_resid; uio->uio_resid = resid; } @@ -389,7 +389,7 @@ lfs_inactive(vp, p) if (!getinoquota(ip)) (void)chkiq(ip, -1, NOCRED, 0); #endif - error = lfs_truncate(vp, (off_t)0, 0); + error = lfs_truncate(vp, (off_t)0, 0, NOCRED); mode = ip->i_mode; ip->i_mode = 0; ip->i_rdev = 0; diff --git a/usr/src/sys/ufs/mfs/mfsnode.h b/usr/src/sys/ufs/mfs/mfsnode.h index 717d2a0749..c070b60809 100644 --- a/usr/src/sys/ufs/mfs/mfsnode.h +++ b/usr/src/sys/ufs/mfs/mfsnode.h @@ -4,7 +4,7 @@ * * %sccs.include.redist.c% * - * @(#)mfsnode.h 7.8 (Berkeley) %G% + * @(#)mfsnode.h 7.9 (Berkeley) %G% */ /* @@ -163,7 +163,8 @@ struct mfsnode { #define mfs_truncate ((int (*) __P(( \ struct vnode *vp, \ off_t length, \ - int flags))) mfs_badop) + int flags, \ + struct ucred *cred))) mfs_badop) #define mfs_update ((int (*) __P(( \ struct vnode *vp, \ struct timeval *ta, \ diff --git a/usr/src/sys/ufs/ufs/ufs_vnops.c b/usr/src/sys/ufs/ufs/ufs_vnops.c index 1905d5445e..c3bf1351be 100644 --- a/usr/src/sys/ufs/ufs/ufs_vnops.c +++ b/usr/src/sys/ufs/ufs/ufs_vnops.c @@ -4,7 +4,7 @@ * * %sccs.include.redist.c% * - * @(#)ufs_vnops.c 7.84 (Berkeley) %G% + * @(#)ufs_vnops.c 7.85 (Berkeley) %G% */ #include @@ -289,7 +289,7 @@ ufs_setattr(vp, vap, cred, p) if (vap->va_size != VNOVAL) { if (vp->v_type == VDIR) return (EISDIR); - if (error = VOP_TRUNCATE(vp, vap->va_size, 0)) /* IO_SYNC? */ + if (error = VOP_TRUNCATE(vp, vap->va_size, 0, cred)) return (error); } ip = VTOI(vp); @@ -981,7 +981,8 @@ ufs_rename(fdvp, fvp, fcnp, if (doingdirectory) { if (--xp->i_nlink != 0) panic("rename: linked directory"); - error = VOP_TRUNCATE(ITOV(xp), (u_long)0, IO_SYNC); + error = VOP_TRUNCATE(ITOV(xp), (off_t)0, IO_SYNC, + tcnp->cn_cred); } xp->i_flag |= ICHG; ufs_iput(xp); @@ -1256,7 +1257,7 @@ ufs_rmdir(dvp, vp, cnp) * worry about them later. */ ip->i_nlink -= 2; - error = VOP_TRUNCATE(vp, (u_long)0, IO_SYNC); + error = VOP_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred); cache_purge(ITOV(ip)); out: if (dvp) -- 2.20.1