update to work with vnodes
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Thu, 4 May 1989 06:07:50 +0000 (22:07 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Thu, 4 May 1989 06:07:50 +0000 (22:07 -0800)
SCCS-vsn: sys/kern/vfs_xxx.c 7.2

usr/src/sys/kern/vfs_xxx.c

index c38c9b2..b0e9ba8 100644 (file)
@@ -6,19 +6,11 @@
  *     @(#)vfs_xxx.c   7.2 (Berkeley) %G%
  */
 
  *     @(#)vfs_xxx.c   7.2 (Berkeley) %G%
  */
 
+#ifdef COMPAT
 #include "param.h"
 #include "param.h"
-#include "systm.h"
-#include "inode.h"
-#include "fs.h"
-#include "mount.h"
-#include "dir.h"
 #include "user.h"
 #include "user.h"
-#include "buf.h"
-#include "conf.h"
-
-#ifdef COMPAT
+#include "vnode.h"
 #include "file.h"
 #include "file.h"
-#include "kernel.h"
 
 /*
  * Oh, how backwards compatibility is ugly!!!
 
 /*
  * Oh, how backwards compatibility is ugly!!!
@@ -42,17 +34,16 @@ struct      ostat {
  */
 ofstat()
 {
  */
 ofstat()
 {
-       register struct file *fp;
+       struct file *fp;
        register struct a {
                int     fd;
                struct ostat *sb;
        } *uap = (struct a *)u.u_ap;
        register struct a {
                int     fd;
                struct ostat *sb;
        } *uap = (struct a *)u.u_ap;
-       extern struct file *getinode();
 
 
-       fp = getinode(uap->fd);
-       if (fp == NULL)
+       u.u_error = getvnode(uap->fd, &fp);
+       if (u.u_error)
                return;
                return;
-       ostat1((struct inode *)fp->f_data, uap->sb);
+       u.u_error = ostat1((struct inode *)fp->f_data, uap->sb);
 }
 
 /*
 }
 
 /*
@@ -60,7 +51,7 @@ ofstat()
  */
 ostat()
 {
  */
 ostat()
 {
-       register struct inode *ip;
+       register struct vnode *vp;
        register struct a {
                char    *fname;
                struct ostat *sb;
        register struct a {
                char    *fname;
                struct ostat *sb;
@@ -70,35 +61,38 @@ ostat()
        ndp->ni_nameiop = LOOKUP | FOLLOW;
        ndp->ni_segflg = UIO_USERSPACE;
        ndp->ni_dirp = uap->fname;
        ndp->ni_nameiop = LOOKUP | FOLLOW;
        ndp->ni_segflg = UIO_USERSPACE;
        ndp->ni_dirp = uap->fname;
-       ip = namei(ndp);
-       if (ip == NULL)
+       if (u.u_error = namei(ndp))
                return;
                return;
-       ostat1(ip, uap->sb);
-       iput(ip);
+       ostat1(ndp->ni_vp, uap->sb);
+       vrele(ndp->ni_vp);
 }
 
 }
 
-ostat1(ip, ub)
-       register struct inode *ip;
+ostat1(vp, ub)
+       register struct vnode *vp;
        struct ostat *ub;
 {
        struct ostat ds;
        struct ostat *ub;
 {
        struct ostat ds;
+       struct vattr vattr;
+       int error;
 
 
-       IUPDAT(ip, &time, &time, 0);
+       error = vop_getattr(vp, &vattr, u.u_cred);
+       if (error)
+               return(error);
        /*
         * Copy from inode table
         */
        /*
         * Copy from inode table
         */
-       ds.ost_dev = ip->i_dev;
-       ds.ost_ino = (short)ip->i_number;
-       ds.ost_mode = (u_short)ip->i_mode;
-       ds.ost_nlink = ip->i_nlink;
-       ds.ost_uid = (short)ip->i_uid;
-       ds.ost_gid = (short)ip->i_gid;
-       ds.ost_rdev = (dev_t)ip->i_rdev;
-       ds.ost_size = (int)ip->i_size;
-       ds.ost_atime = (int)ip->i_atime;
-       ds.ost_mtime = (int)ip->i_mtime;
-       ds.ost_ctime = (int)ip->i_ctime;
-       u.u_error = copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds));
+       ds.ost_dev = vattr.va_fsid;
+       ds.ost_ino = (short)vattr.va_fileid;
+       ds.ost_mode = (u_short)vattr.va_mode;
+       ds.ost_nlink = vattr.va_nlink;
+       ds.ost_uid = (short)vattr.va_uid;
+       ds.ost_gid = (short)vattr.va_gid;
+       ds.ost_rdev = (dev_t)vattr.va_rdev;
+       ds.ost_size = (int)vattr.va_size;
+       ds.ost_atime = (int)vattr.va_atime.tv_sec;
+       ds.ost_mtime = (int)vattr.va_mtime.tv_sec;
+       ds.ost_ctime = (int)vattr.va_atime.tv_sec;
+       return (copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds)));
 }
 
 /*
 }
 
 /*
@@ -111,19 +105,17 @@ outime()
                char    *fname;
                time_t  *tptr;
        } *uap = (struct a *)u.u_ap;
                char    *fname;
                time_t  *tptr;
        } *uap = (struct a *)u.u_ap;
-       register struct inode *ip;
+       struct vattr vattr;
        time_t tv[2];
        time_t tv[2];
-       struct timeval tv0, tv1;
 
 
-       if ((ip = owner(uap->fname, FOLLOW)) == NULL)
-               return;
        u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
        u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
-       if (u.u_error == 0) {
-               ip->i_flag |= IACC|IUPD|ICHG;
-               tv0.tv_sec = tv[0]; tv0.tv_usec = 0;
-               tv1.tv_sec = tv[1]; tv1.tv_usec = 0;
-               iupdat(ip, &tv0, &tv1, 0);
-       }
-       iput(ip);
+       if (u.u_error)
+               return;
+       vattr_null(&vattr);
+       vattr.va_atime.tv_sec = tv[0];
+       vattr.va_atime.tv_usec = 0;
+       vattr.va_mtime.tv_sec = tv[1];
+       vattr.va_mtime.tv_usec = 0;
+       u.u_error = namesetattr(uap->fname, FOLLOW, &vattr);
 }
 #endif
 }
 #endif