123415Smckusick /*
229123Smckusick * Copyright (c) 1982, 1986 Regents of the University of California.
323415Smckusick * All rights reserved. The Berkeley software License Agreement
423415Smckusick * specifies the terms and conditions for redistribution.
523415Smckusick *
6*37730Smckusick * @(#)vfs_xxx.c 7.3 (Berkeley) 05/09/89
723415Smckusick */
88720Sroot
937622Smckusick #ifdef COMPAT
1017102Sbloom #include "param.h"
1117102Sbloom #include "user.h"
1237622Smckusick #include "vnode.h"
1317102Sbloom #include "file.h"
149880Ssam
159880Ssam /*
169880Ssam * Oh, how backwards compatibility is ugly!!!
179880Ssam */
189880Ssam struct ostat {
199880Ssam dev_t ost_dev;
209984Ssam u_short ost_ino;
219880Ssam u_short ost_mode;
229880Ssam short ost_nlink;
239880Ssam short ost_uid;
249880Ssam short ost_gid;
259880Ssam dev_t ost_rdev;
269880Ssam int ost_size;
279880Ssam int ost_atime;
289880Ssam int ost_mtime;
299880Ssam int ost_ctime;
309880Ssam };
319880Ssam
329880Ssam /*
339880Ssam * The old fstat system call.
349880Ssam */
ofstat()359880Ssam ofstat()
369880Ssam {
3737622Smckusick struct file *fp;
389880Ssam register struct a {
399880Ssam int fd;
409880Ssam struct ostat *sb;
4112757Ssam } *uap = (struct a *)u.u_ap;
429880Ssam
4337622Smckusick u.u_error = getvnode(uap->fd, &fp);
4437622Smckusick if (u.u_error)
459880Ssam return;
4637622Smckusick u.u_error = ostat1((struct inode *)fp->f_data, uap->sb);
479880Ssam }
489880Ssam
499880Ssam /*
509880Ssam * Old stat system call. This version follows links.
519880Ssam */
ostat()529880Ssam ostat()
539880Ssam {
5437622Smckusick register struct vnode *vp;
559880Ssam register struct a {
569880Ssam char *fname;
579880Ssam struct ostat *sb;
5816695Smckusick } *uap = (struct a *)u.u_ap;
5916695Smckusick register struct nameidata *ndp = &u.u_nd;
609880Ssam
6116695Smckusick ndp->ni_nameiop = LOOKUP | FOLLOW;
6216695Smckusick ndp->ni_segflg = UIO_USERSPACE;
6316695Smckusick ndp->ni_dirp = uap->fname;
6437622Smckusick if (u.u_error = namei(ndp))
659880Ssam return;
6637622Smckusick ostat1(ndp->ni_vp, uap->sb);
6737622Smckusick vrele(ndp->ni_vp);
689880Ssam }
699880Ssam
ostat1(vp,ub)7037622Smckusick ostat1(vp, ub)
7137622Smckusick register struct vnode *vp;
729880Ssam struct ostat *ub;
739880Ssam {
749880Ssam struct ostat ds;
7537622Smckusick struct vattr vattr;
7637622Smckusick int error;
779880Ssam
78*37730Smckusick error = VOP_GETATTR(vp, &vattr, u.u_cred);
7937622Smckusick if (error)
8037622Smckusick return(error);
819880Ssam /*
829880Ssam * Copy from inode table
839880Ssam */
8437622Smckusick ds.ost_dev = vattr.va_fsid;
8537622Smckusick ds.ost_ino = (short)vattr.va_fileid;
8637622Smckusick ds.ost_mode = (u_short)vattr.va_mode;
8737622Smckusick ds.ost_nlink = vattr.va_nlink;
8837622Smckusick ds.ost_uid = (short)vattr.va_uid;
8937622Smckusick ds.ost_gid = (short)vattr.va_gid;
9037622Smckusick ds.ost_rdev = (dev_t)vattr.va_rdev;
9137622Smckusick ds.ost_size = (int)vattr.va_size;
9237622Smckusick ds.ost_atime = (int)vattr.va_atime.tv_sec;
9337622Smckusick ds.ost_mtime = (int)vattr.va_mtime.tv_sec;
9437622Smckusick ds.ost_ctime = (int)vattr.va_atime.tv_sec;
9537622Smckusick return (copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds)));
969880Ssam }
9712850Ssam
9812850Ssam /*
9912850Ssam * Set IUPD and IACC times on file.
10012850Ssam * Can't set ICHG.
10112850Ssam */
outime()10212850Ssam outime()
10312850Ssam {
10412850Ssam register struct a {
10512850Ssam char *fname;
10612850Ssam time_t *tptr;
10712850Ssam } *uap = (struct a *)u.u_ap;
10837622Smckusick struct vattr vattr;
10912850Ssam time_t tv[2];
11012850Ssam
11137622Smckusick u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
11237622Smckusick if (u.u_error)
11312850Ssam return;
11437622Smckusick vattr_null(&vattr);
11537622Smckusick vattr.va_atime.tv_sec = tv[0];
11637622Smckusick vattr.va_atime.tv_usec = 0;
11737622Smckusick vattr.va_mtime.tv_sec = tv[1];
11837622Smckusick vattr.va_mtime.tv_usec = 0;
11937622Smckusick u.u_error = namesetattr(uap->fname, FOLLOW, &vattr);
12012850Ssam }
1219880Ssam #endif
122