xref: /csrg-svn/sys/kern/vfs_xxx.c (revision 29123)
123415Smckusick /*
2*29123Smckusick  * 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*29123Smckusick  *	@(#)vfs_xxx.c	7.1 (Berkeley) 06/05/86
723415Smckusick  */
88720Sroot 
917102Sbloom #include "param.h"
1017102Sbloom #include "systm.h"
1117102Sbloom #include "inode.h"
1217102Sbloom #include "fs.h"
1317102Sbloom #include "mount.h"
1417102Sbloom #include "dir.h"
1517102Sbloom #include "user.h"
1617102Sbloom #include "buf.h"
1717102Sbloom #include "conf.h"
188720Sroot 
1913229Ssam #ifdef COMPAT
2017102Sbloom #include "file.h"
2117102Sbloom #include "kernel.h"
229880Ssam 
239880Ssam /*
249880Ssam  * Oh, how backwards compatibility is ugly!!!
259880Ssam  */
269880Ssam struct	ostat {
279880Ssam 	dev_t	ost_dev;
289984Ssam 	u_short	ost_ino;
299880Ssam 	u_short ost_mode;
309880Ssam 	short  	ost_nlink;
319880Ssam 	short  	ost_uid;
329880Ssam 	short  	ost_gid;
339880Ssam 	dev_t	ost_rdev;
349880Ssam 	int	ost_size;
359880Ssam 	int	ost_atime;
369880Ssam 	int	ost_mtime;
379880Ssam 	int	ost_ctime;
389880Ssam };
399880Ssam 
409880Ssam /*
419880Ssam  * The old fstat system call.
429880Ssam  */
439880Ssam ofstat()
449880Ssam {
459880Ssam 	register struct file *fp;
469880Ssam 	register struct a {
479880Ssam 		int	fd;
489880Ssam 		struct ostat *sb;
4912757Ssam 	} *uap = (struct a *)u.u_ap;
5012757Ssam 	extern struct file *getinode();
519880Ssam 
5212757Ssam 	fp = getinode(uap->fd);
539880Ssam 	if (fp == NULL)
549880Ssam 		return;
5512757Ssam 	ostat1((struct inode *)fp->f_data, uap->sb);
569880Ssam }
579880Ssam 
589880Ssam /*
599880Ssam  * Old stat system call.  This version follows links.
609880Ssam  */
619880Ssam ostat()
629880Ssam {
639880Ssam 	register struct inode *ip;
649880Ssam 	register struct a {
659880Ssam 		char	*fname;
669880Ssam 		struct ostat *sb;
6716695Smckusick 	} *uap = (struct a *)u.u_ap;
6816695Smckusick 	register struct nameidata *ndp = &u.u_nd;
699880Ssam 
7016695Smckusick 	ndp->ni_nameiop = LOOKUP | FOLLOW;
7116695Smckusick 	ndp->ni_segflg = UIO_USERSPACE;
7216695Smckusick 	ndp->ni_dirp = uap->fname;
7316695Smckusick 	ip = namei(ndp);
749880Ssam 	if (ip == NULL)
759880Ssam 		return;
769880Ssam 	ostat1(ip, uap->sb);
779880Ssam 	iput(ip);
789880Ssam }
799880Ssam 
809880Ssam ostat1(ip, ub)
819880Ssam 	register struct inode *ip;
829880Ssam 	struct ostat *ub;
839880Ssam {
849880Ssam 	struct ostat ds;
859880Ssam 
869880Ssam 	IUPDAT(ip, &time, &time, 0);
879880Ssam 	/*
889880Ssam 	 * Copy from inode table
899880Ssam 	 */
909880Ssam 	ds.ost_dev = ip->i_dev;
919880Ssam 	ds.ost_ino = (short)ip->i_number;
929880Ssam 	ds.ost_mode = (u_short)ip->i_mode;
939880Ssam 	ds.ost_nlink = ip->i_nlink;
949880Ssam 	ds.ost_uid = (short)ip->i_uid;
959880Ssam 	ds.ost_gid = (short)ip->i_gid;
969880Ssam 	ds.ost_rdev = (dev_t)ip->i_rdev;
979880Ssam 	ds.ost_size = (int)ip->i_size;
989880Ssam 	ds.ost_atime = (int)ip->i_atime;
999880Ssam 	ds.ost_mtime = (int)ip->i_mtime;
1009880Ssam 	ds.ost_ctime = (int)ip->i_ctime;
10110002Ssam 	u.u_error = copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds));
1029880Ssam }
10312850Ssam 
10412850Ssam /*
10512850Ssam  * Set IUPD and IACC times on file.
10612850Ssam  * Can't set ICHG.
10712850Ssam  */
10812850Ssam outime()
10912850Ssam {
11012850Ssam 	register struct a {
11112850Ssam 		char	*fname;
11212850Ssam 		time_t	*tptr;
11312850Ssam 	} *uap = (struct a *)u.u_ap;
11412850Ssam 	register struct inode *ip;
11512850Ssam 	time_t tv[2];
11612850Ssam 	struct timeval tv0, tv1;
11712850Ssam 
11816695Smckusick 	if ((ip = owner(uap->fname, FOLLOW)) == NULL)
11912850Ssam 		return;
12012850Ssam 	u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
12112850Ssam 	if (u.u_error == 0) {
12212850Ssam 		ip->i_flag |= IACC|IUPD|ICHG;
12312850Ssam 		tv0.tv_sec = tv[0]; tv0.tv_usec = 0;
12412850Ssam 		tv1.tv_sec = tv[1]; tv1.tv_usec = 0;
12512850Ssam 		iupdat(ip, &tv0, &tv1, 0);
12612850Ssam 	}
12712850Ssam 	iput(ip);
12812850Ssam }
1299880Ssam #endif
130