xref: /csrg-svn/sys/kern/vfs_xxx.c (revision 37622)
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*37622Smckusick  *	@(#)vfs_xxx.c	7.2 (Berkeley) 05/03/89
723415Smckusick  */
88720Sroot 
9*37622Smckusick #ifdef COMPAT
1017102Sbloom #include "param.h"
1117102Sbloom #include "user.h"
12*37622Smckusick #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  */
359880Ssam ofstat()
369880Ssam {
37*37622Smckusick 	struct file *fp;
389880Ssam 	register struct a {
399880Ssam 		int	fd;
409880Ssam 		struct ostat *sb;
4112757Ssam 	} *uap = (struct a *)u.u_ap;
429880Ssam 
43*37622Smckusick 	u.u_error = getvnode(uap->fd, &fp);
44*37622Smckusick 	if (u.u_error)
459880Ssam 		return;
46*37622Smckusick 	u.u_error = ostat1((struct inode *)fp->f_data, uap->sb);
479880Ssam }
489880Ssam 
499880Ssam /*
509880Ssam  * Old stat system call.  This version follows links.
519880Ssam  */
529880Ssam ostat()
539880Ssam {
54*37622Smckusick 	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;
64*37622Smckusick 	if (u.u_error = namei(ndp))
659880Ssam 		return;
66*37622Smckusick 	ostat1(ndp->ni_vp, uap->sb);
67*37622Smckusick 	vrele(ndp->ni_vp);
689880Ssam }
699880Ssam 
70*37622Smckusick ostat1(vp, ub)
71*37622Smckusick 	register struct vnode *vp;
729880Ssam 	struct ostat *ub;
739880Ssam {
749880Ssam 	struct ostat ds;
75*37622Smckusick 	struct vattr vattr;
76*37622Smckusick 	int error;
779880Ssam 
78*37622Smckusick 	error = vop_getattr(vp, &vattr, u.u_cred);
79*37622Smckusick 	if (error)
80*37622Smckusick 		return(error);
819880Ssam 	/*
829880Ssam 	 * Copy from inode table
839880Ssam 	 */
84*37622Smckusick 	ds.ost_dev = vattr.va_fsid;
85*37622Smckusick 	ds.ost_ino = (short)vattr.va_fileid;
86*37622Smckusick 	ds.ost_mode = (u_short)vattr.va_mode;
87*37622Smckusick 	ds.ost_nlink = vattr.va_nlink;
88*37622Smckusick 	ds.ost_uid = (short)vattr.va_uid;
89*37622Smckusick 	ds.ost_gid = (short)vattr.va_gid;
90*37622Smckusick 	ds.ost_rdev = (dev_t)vattr.va_rdev;
91*37622Smckusick 	ds.ost_size = (int)vattr.va_size;
92*37622Smckusick 	ds.ost_atime = (int)vattr.va_atime.tv_sec;
93*37622Smckusick 	ds.ost_mtime = (int)vattr.va_mtime.tv_sec;
94*37622Smckusick 	ds.ost_ctime = (int)vattr.va_atime.tv_sec;
95*37622Smckusick 	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  */
10212850Ssam outime()
10312850Ssam {
10412850Ssam 	register struct a {
10512850Ssam 		char	*fname;
10612850Ssam 		time_t	*tptr;
10712850Ssam 	} *uap = (struct a *)u.u_ap;
108*37622Smckusick 	struct vattr vattr;
10912850Ssam 	time_t tv[2];
11012850Ssam 
111*37622Smckusick 	u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
112*37622Smckusick 	if (u.u_error)
11312850Ssam 		return;
114*37622Smckusick 	vattr_null(&vattr);
115*37622Smckusick 	vattr.va_atime.tv_sec = tv[0];
116*37622Smckusick 	vattr.va_atime.tv_usec = 0;
117*37622Smckusick 	vattr.va_mtime.tv_sec = tv[1];
118*37622Smckusick 	vattr.va_mtime.tv_usec = 0;
119*37622Smckusick 	u.u_error = namesetattr(uap->fname, FOLLOW, &vattr);
12012850Ssam }
1219880Ssam #endif
122