Add copyright
[unix-history] / usr / src / sys / kern / vfs_xxx.c
index c352854..b90a3cc 100644 (file)
@@ -1,45 +1,24 @@
-/*     vfs_xxx.c       4.3     82/12/28        */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/inode.h"
-#include "../h/fs.h"
-#include "../h/mount.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-#include "../h/conf.h"
-
-/*
- * Return the next character fromt the
- * kernel string pointed at by dirp.
- */
-schar()
-{
-       return (*u.u_dirp++ & 0377);
-}
-
 /*
 /*
- * Return the next character from the
- * user string pointed at by dirp.
+ * Copyright (c) 1982 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)vfs_xxx.c   6.4 (Berkeley) %G%
  */
  */
-uchar()
-{
-       register c;
 
 
-       c = fubyte(u.u_dirp++);
-       if (c == -1) {
-               u.u_error = EFAULT;
-               c = 0;
-       }
-       return (c);
-}
+#include "param.h"
+#include "systm.h"
+#include "inode.h"
+#include "fs.h"
+#include "mount.h"
+#include "dir.h"
+#include "user.h"
+#include "buf.h"
+#include "conf.h"
 
 
-#ifndef NOCOMPAT
-#include "../h/file.h"
-#include "../h/nami.h"
-#include "../h/descrip.h"
-#include "../h/kernel.h"
+#ifdef COMPAT
+#include "file.h"
+#include "kernel.h"
 
 /*
  * Oh, how backwards compatibility is ugly!!!
 
 /*
  * Oh, how backwards compatibility is ugly!!!
@@ -67,19 +46,13 @@ ofstat()
        register struct a {
                int     fd;
                struct ostat *sb;
        register struct a {
                int     fd;
                struct ostat *sb;
-       } *uap;
+       } *uap = (struct a *)u.u_ap;
+       extern struct file *getinode();
 
 
-       uap = (struct a *)u.u_ap;
-       fp = getf(uap->fd);
+       fp = getinode(uap->fd);
        if (fp == NULL)
                return;
        if (fp == NULL)
                return;
-       if (fp->f_type == DTYPE_SOCKET) {
-               struct ostat ub;
-
-               bzero((caddr_t)&ub, sizeof (ub));
-               (void) copyout((caddr_t)&ub, (caddr_t)uap->sb, sizeof (ub));
-       } else
-               ostat1(fp->f_inode, uap->sb);
+       ostat1((struct inode *)fp->f_data, uap->sb);
 }
 
 /*
 }
 
 /*
@@ -91,10 +64,13 @@ ostat()
        register struct a {
                char    *fname;
                struct ostat *sb;
        register struct a {
                char    *fname;
                struct ostat *sb;
-       } *uap;
+       } *uap = (struct a *)u.u_ap;
+       register struct nameidata *ndp = &u.u_nd;
 
 
-       uap = (struct a *)u.u_ap;
-       ip = namei(uchar, LOOKUP, 1);
+       ndp->ni_nameiop = LOOKUP | FOLLOW;
+       ndp->ni_segflg = UIO_USERSPACE;
+       ndp->ni_dirp = uap->fname;
+       ip = namei(ndp);
        if (ip == NULL)
                return;
        ostat1(ip, uap->sb);
        if (ip == NULL)
                return;
        ostat1(ip, uap->sb);
@@ -122,7 +98,32 @@ ostat1(ip, ub)
        ds.ost_atime = (int)ip->i_atime;
        ds.ost_mtime = (int)ip->i_mtime;
        ds.ost_ctime = (int)ip->i_ctime;
        ds.ost_atime = (int)ip->i_atime;
        ds.ost_mtime = (int)ip->i_mtime;
        ds.ost_ctime = (int)ip->i_ctime;
-       if (copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds)) < 0)
-               u.u_error = EFAULT;
+       u.u_error = copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds));
+}
+
+/*
+ * Set IUPD and IACC times on file.
+ * Can't set ICHG.
+ */
+outime()
+{
+       register struct a {
+               char    *fname;
+               time_t  *tptr;
+       } *uap = (struct a *)u.u_ap;
+       register struct inode *ip;
+       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));
+       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);
 }
 #endif
 }
 #endif