1*16695Smckusick /* vfs_xxx.c 6.2 84/07/08 */ 28720Sroot 38720Sroot #include "../h/param.h" 48720Sroot #include "../h/systm.h" 58720Sroot #include "../h/inode.h" 68720Sroot #include "../h/fs.h" 78720Sroot #include "../h/mount.h" 88720Sroot #include "../h/dir.h" 98720Sroot #include "../h/user.h" 108720Sroot #include "../h/buf.h" 118720Sroot #include "../h/conf.h" 128720Sroot 1313229Ssam #ifdef COMPAT 149880Ssam #include "../h/file.h" 159880Ssam #include "../h/kernel.h" 169880Ssam 179880Ssam /* 189880Ssam * Oh, how backwards compatibility is ugly!!! 199880Ssam */ 209880Ssam struct ostat { 219880Ssam dev_t ost_dev; 229984Ssam u_short ost_ino; 239880Ssam u_short ost_mode; 249880Ssam short ost_nlink; 259880Ssam short ost_uid; 269880Ssam short ost_gid; 279880Ssam dev_t ost_rdev; 289880Ssam int ost_size; 299880Ssam int ost_atime; 309880Ssam int ost_mtime; 319880Ssam int ost_ctime; 329880Ssam }; 339880Ssam 349880Ssam /* 359880Ssam * The old fstat system call. 369880Ssam */ 379880Ssam ofstat() 389880Ssam { 399880Ssam register struct file *fp; 409880Ssam register struct a { 419880Ssam int fd; 429880Ssam struct ostat *sb; 4312757Ssam } *uap = (struct a *)u.u_ap; 4412757Ssam extern struct file *getinode(); 459880Ssam 4612757Ssam fp = getinode(uap->fd); 479880Ssam if (fp == NULL) 489880Ssam return; 4912757Ssam ostat1((struct inode *)fp->f_data, uap->sb); 509880Ssam } 519880Ssam 529880Ssam /* 539880Ssam * Old stat system call. This version follows links. 549880Ssam */ 559880Ssam ostat() 569880Ssam { 579880Ssam register struct inode *ip; 589880Ssam register struct a { 599880Ssam char *fname; 609880Ssam struct ostat *sb; 61*16695Smckusick } *uap = (struct a *)u.u_ap; 62*16695Smckusick register struct nameidata *ndp = &u.u_nd; 639880Ssam 64*16695Smckusick ndp->ni_nameiop = LOOKUP | FOLLOW; 65*16695Smckusick ndp->ni_segflg = UIO_USERSPACE; 66*16695Smckusick ndp->ni_dirp = uap->fname; 67*16695Smckusick ip = namei(ndp); 689880Ssam if (ip == NULL) 699880Ssam return; 709880Ssam ostat1(ip, uap->sb); 719880Ssam iput(ip); 729880Ssam } 739880Ssam 749880Ssam ostat1(ip, ub) 759880Ssam register struct inode *ip; 769880Ssam struct ostat *ub; 779880Ssam { 789880Ssam struct ostat ds; 799880Ssam 809880Ssam IUPDAT(ip, &time, &time, 0); 819880Ssam /* 829880Ssam * Copy from inode table 839880Ssam */ 849880Ssam ds.ost_dev = ip->i_dev; 859880Ssam ds.ost_ino = (short)ip->i_number; 869880Ssam ds.ost_mode = (u_short)ip->i_mode; 879880Ssam ds.ost_nlink = ip->i_nlink; 889880Ssam ds.ost_uid = (short)ip->i_uid; 899880Ssam ds.ost_gid = (short)ip->i_gid; 909880Ssam ds.ost_rdev = (dev_t)ip->i_rdev; 919880Ssam ds.ost_size = (int)ip->i_size; 929880Ssam ds.ost_atime = (int)ip->i_atime; 939880Ssam ds.ost_mtime = (int)ip->i_mtime; 949880Ssam ds.ost_ctime = (int)ip->i_ctime; 9510002Ssam u.u_error = 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 */ 10212850Ssam outime() 10312850Ssam { 10412850Ssam register struct a { 10512850Ssam char *fname; 10612850Ssam time_t *tptr; 10712850Ssam } *uap = (struct a *)u.u_ap; 10812850Ssam register struct inode *ip; 10912850Ssam time_t tv[2]; 11012850Ssam struct timeval tv0, tv1; 11112850Ssam 112*16695Smckusick if ((ip = owner(uap->fname, FOLLOW)) == NULL) 11312850Ssam return; 11412850Ssam u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)); 11512850Ssam if (u.u_error == 0) { 11612850Ssam ip->i_flag |= IACC|IUPD|ICHG; 11712850Ssam tv0.tv_sec = tv[0]; tv0.tv_usec = 0; 11812850Ssam tv1.tv_sec = tv[1]; tv1.tv_usec = 0; 11912850Ssam iupdat(ip, &tv0, &tv1, 0); 12012850Ssam } 12112850Ssam iput(ip); 12212850Ssam } 1239880Ssam #endif 124