vop_truncate takes off_t rather than u_long length op
[unix-history] / usr / src / sys / ufs / ffs / ffs_inode.c
index 46899e7..62fe626 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ffs_inode.c 7.42 (Berkeley) %G%
+ *     @(#)ffs_inode.c 7.47 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -47,7 +47,6 @@ ffs_vget(mntp, ino, vpp)
        ino_t ino;
        struct vnode **vpp;
 {
        ino_t ino;
        struct vnode **vpp;
 {
-       extern struct vnodeops ffs_vnodeops, ffs_specops, ffs_fifoops;
        register struct fs *fs;
        register struct inode *ip;
        struct ufsmount *ump;
        register struct fs *fs;
        register struct inode *ip;
        struct ufsmount *ump;
@@ -56,7 +55,7 @@ ffs_vget(mntp, ino, vpp)
        struct vnode *vp;
        union ihead *ih;
        dev_t dev;
        struct vnode *vp;
        union ihead *ih;
        dev_t dev;
-       int i, error;
+       int i, type, error;
 
        ump = VFSTOUFS(mntp);
        dev = ump->um_dev;
 
        ump = VFSTOUFS(mntp);
        dev = ump->um_dev;
@@ -68,13 +67,16 @@ ffs_vget(mntp, ino, vpp)
                *vpp = NULL;
                return (error);
        }
                *vpp = NULL;
                return (error);
        }
-       ip = VTOI(vp);
+       type = ump->um_devvp->v_tag == VT_MFS ? M_MFSNODE : M_FFSNODE; /* XXX */
+       MALLOC(ip, struct inode *, sizeof(struct inode), type, M_WAITOK);
+       vp->v_data = ip;
        ip->i_vnode = vp;
        ip->i_flag = 0;
        ip->i_devvp = 0;
        ip->i_mode = 0;
        ip->i_diroff = 0;
        ip->i_lockf = 0;
        ip->i_vnode = vp;
        ip->i_flag = 0;
        ip->i_devvp = 0;
        ip->i_mode = 0;
        ip->i_diroff = 0;
        ip->i_lockf = 0;
+       ip->i_fs = fs = ump->um_fs;
        ip->i_dev = dev;
        ip->i_number = ino;
 #ifdef QUOTA
        ip->i_dev = dev;
        ip->i_number = ino;
 #ifdef QUOTA
@@ -90,13 +92,12 @@ ffs_vget(mntp, ino, vpp)
        ufs_ihashins(ip);
 
        /* Read in the disk contents for the inode, copy into the inode. */
        ufs_ihashins(ip);
 
        /* Read in the disk contents for the inode, copy into the inode. */
-       fs = ump->um_fs;
        if (error = bread(ump->um_devvp, fsbtodb(fs, itod(fs, ino)),
            (int)fs->fs_bsize, NOCRED, &bp)) {
                /*
                 * The inode does not contain anything useful, so it would
        if (error = bread(ump->um_devvp, fsbtodb(fs, itod(fs, ino)),
            (int)fs->fs_bsize, NOCRED, &bp)) {
                /*
                 * The inode does not contain anything useful, so it would
-                * be misleading to leave it on its hash chain.  Iput() will
-                * return it to the free list.
+                * be misleading to leave it on its hash chain. It will be
+                * returned to the free list by ufs_iput().
                 */
                remque(ip);
                ip->i_forw = ip;
                 */
                remque(ip);
                ip->i_forw = ip;
@@ -114,10 +115,10 @@ ffs_vget(mntp, ino, vpp)
        brelse(bp);
 
        /*
        brelse(bp);
 
        /*
-        * Initialize the vnode from the inode, check for aliases.  In all
-        * cases re-init ip, the underlying vnode/inode may have changed.
+        * Initialize the vnode from the inode, check for aliases.
+        * Note that the underlying vnode may have changed.
         */
         */
-       if (error = ufs_vinit(mntp, &ffs_specops, &ffs_fifoops, &vp)) {
+       if (error = ufs_vinit(mntp, &ffs_specops, FFS_FIFOOPS, &vp)) {
                ufs_iput(ip);
                *vpp = NULL;
                return (error);
                ufs_iput(ip);
                *vpp = NULL;
                return (error);
@@ -125,11 +126,8 @@ ffs_vget(mntp, ino, vpp)
        /*
         * Finish inode initialization now that aliasing has been resolved.
         */
        /*
         * Finish inode initialization now that aliasing has been resolved.
         */
-       ip = VTOI(vp);
-       ip->i_fs = fs;
        ip->i_devvp = ump->um_devvp;
        VREF(ip->i_devvp);
        ip->i_devvp = ump->um_devvp;
        VREF(ip->i_devvp);
-
        /*
         * Set up a generation number for this inode if it does not
         * already have one. This should only happen on old filesystems.
        /*
         * Set up a generation number for this inode if it does not
         * already have one. This should only happen on old filesystems.
@@ -172,8 +170,10 @@ ffs_update(vp, ta, tm, waitfor)
                return (0);
        if (ip->i_flag&IACC)
                ip->i_atime = ta->tv_sec;
                return (0);
        if (ip->i_flag&IACC)
                ip->i_atime = ta->tv_sec;
-       if (ip->i_flag&IUPD)
+       if (ip->i_flag&IUPD) {
                ip->i_mtime = tm->tv_sec;
                ip->i_mtime = tm->tv_sec;
+               INCRQUAD(ip->i_modrev);
+       }
        if (ip->i_flag&ICHG)
                ip->i_ctime = time.tv_sec;
        ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
        if (ip->i_flag&ICHG)
                ip->i_ctime = time.tv_sec;
        ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
@@ -263,7 +263,7 @@ ffs_truncate(ovp, length, flags)
                        return (error);
                oip->i_size = length;
                size = blksize(fs, oip, lbn);
                        return (error);
                oip->i_size = length;
                size = blksize(fs, oip, lbn);
-               (void) vnode_pager_uncache(ITOV(oip));
+               (void) vnode_pager_uncache(ovp);
                bzero(bp->b_un.b_addr + offset, (unsigned)(size - offset));
                allocbuf(bp, size);
                if (flags & IO_SYNC)
                bzero(bp->b_un.b_addr + offset, (unsigned)(size - offset));
                allocbuf(bp, size);
                if (flags & IO_SYNC)
@@ -287,7 +287,7 @@ ffs_truncate(ovp, length, flags)
        for (i = NDADDR - 1; i > lastblock; i--)
                oip->i_db[i] = 0;
        oip->i_flag |= ICHG|IUPD;
        for (i = NDADDR - 1; i > lastblock; i--)
                oip->i_db[i] = 0;
        oip->i_flag |= ICHG|IUPD;
-       vinvalbuf(ITOV(oip), (length > 0));
+       vinvalbuf(ovp, (length > 0));
        allerror = ffs_update(ovp, &time, &time, MNT_WAIT);
 
        /*
        allerror = ffs_update(ovp, &time, &time, MNT_WAIT);
 
        /*