1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)vfs_xxx.c 7.3 (Berkeley) 05/09/89 7 */ 8 9 #ifdef COMPAT 10 #include "param.h" 11 #include "user.h" 12 #include "vnode.h" 13 #include "file.h" 14 15 /* 16 * Oh, how backwards compatibility is ugly!!! 17 */ 18 struct ostat { 19 dev_t ost_dev; 20 u_short ost_ino; 21 u_short ost_mode; 22 short ost_nlink; 23 short ost_uid; 24 short ost_gid; 25 dev_t ost_rdev; 26 int ost_size; 27 int ost_atime; 28 int ost_mtime; 29 int ost_ctime; 30 }; 31 32 /* 33 * The old fstat system call. 34 */ 35 ofstat() 36 { 37 struct file *fp; 38 register struct a { 39 int fd; 40 struct ostat *sb; 41 } *uap = (struct a *)u.u_ap; 42 43 u.u_error = getvnode(uap->fd, &fp); 44 if (u.u_error) 45 return; 46 u.u_error = ostat1((struct inode *)fp->f_data, uap->sb); 47 } 48 49 /* 50 * Old stat system call. This version follows links. 51 */ 52 ostat() 53 { 54 register struct vnode *vp; 55 register struct a { 56 char *fname; 57 struct ostat *sb; 58 } *uap = (struct a *)u.u_ap; 59 register struct nameidata *ndp = &u.u_nd; 60 61 ndp->ni_nameiop = LOOKUP | FOLLOW; 62 ndp->ni_segflg = UIO_USERSPACE; 63 ndp->ni_dirp = uap->fname; 64 if (u.u_error = namei(ndp)) 65 return; 66 ostat1(ndp->ni_vp, uap->sb); 67 vrele(ndp->ni_vp); 68 } 69 70 ostat1(vp, ub) 71 register struct vnode *vp; 72 struct ostat *ub; 73 { 74 struct ostat ds; 75 struct vattr vattr; 76 int error; 77 78 error = VOP_GETATTR(vp, &vattr, u.u_cred); 79 if (error) 80 return(error); 81 /* 82 * Copy from inode table 83 */ 84 ds.ost_dev = vattr.va_fsid; 85 ds.ost_ino = (short)vattr.va_fileid; 86 ds.ost_mode = (u_short)vattr.va_mode; 87 ds.ost_nlink = vattr.va_nlink; 88 ds.ost_uid = (short)vattr.va_uid; 89 ds.ost_gid = (short)vattr.va_gid; 90 ds.ost_rdev = (dev_t)vattr.va_rdev; 91 ds.ost_size = (int)vattr.va_size; 92 ds.ost_atime = (int)vattr.va_atime.tv_sec; 93 ds.ost_mtime = (int)vattr.va_mtime.tv_sec; 94 ds.ost_ctime = (int)vattr.va_atime.tv_sec; 95 return (copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds))); 96 } 97 98 /* 99 * Set IUPD and IACC times on file. 100 * Can't set ICHG. 101 */ 102 outime() 103 { 104 register struct a { 105 char *fname; 106 time_t *tptr; 107 } *uap = (struct a *)u.u_ap; 108 struct vattr vattr; 109 time_t tv[2]; 110 111 u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)); 112 if (u.u_error) 113 return; 114 vattr_null(&vattr); 115 vattr.va_atime.tv_sec = tv[0]; 116 vattr.va_atime.tv_usec = 0; 117 vattr.va_mtime.tv_sec = tv[1]; 118 vattr.va_mtime.tv_usec = 0; 119 u.u_error = namesetattr(uap->fname, FOLLOW, &vattr); 120 } 121 #endif 122