xref: /csrg-svn/sys/kern/vfs_xxx.c (revision 9880)
1*9880Ssam /*	vfs_xxx.c	4.2	82/12/23	*/
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 
138720Sroot /*
148720Sroot  * Return the next character fromt the
158720Sroot  * kernel string pointed at by dirp.
168720Sroot  */
178720Sroot schar()
188720Sroot {
198720Sroot 	return (*u.u_dirp++ & 0377);
208720Sroot }
218720Sroot 
228720Sroot /*
238720Sroot  * Return the next character from the
248720Sroot  * user string pointed at by dirp.
258720Sroot  */
268720Sroot uchar()
278720Sroot {
288720Sroot 	register c;
298720Sroot 
308720Sroot 	c = fubyte(u.u_dirp++);
318720Sroot 	if (c == -1) {
328720Sroot 		u.u_error = EFAULT;
338720Sroot 		c = 0;
348720Sroot 	}
358720Sroot 	return (c);
368720Sroot }
37*9880Ssam 
38*9880Ssam #ifndef NOCOMPAT
39*9880Ssam #include "../h/file.h"
40*9880Ssam #include "../h/nami.h"
41*9880Ssam #include "../h/descrip.h"
42*9880Ssam #include "../h/kernel.h"
43*9880Ssam 
44*9880Ssam /*
45*9880Ssam  * Oh, how backwards compatibility is ugly!!!
46*9880Ssam  */
47*9880Ssam struct	ostat {
48*9880Ssam 	dev_t	ost_dev;
49*9880Ssam 	u_int	ost_ino;
50*9880Ssam 	u_short ost_mode;
51*9880Ssam 	short  	ost_nlink;
52*9880Ssam 	short  	ost_uid;
53*9880Ssam 	short  	ost_gid;
54*9880Ssam 	dev_t	ost_rdev;
55*9880Ssam 	int	ost_size;
56*9880Ssam 	int	ost_atime;
57*9880Ssam 	int	ost_mtime;
58*9880Ssam 	int	ost_ctime;
59*9880Ssam };
60*9880Ssam 
61*9880Ssam /*
62*9880Ssam  * The old fstat system call.
63*9880Ssam  */
64*9880Ssam ofstat()
65*9880Ssam {
66*9880Ssam 	register struct file *fp;
67*9880Ssam 	register struct a {
68*9880Ssam 		int	fd;
69*9880Ssam 		struct ostat *sb;
70*9880Ssam 	} *uap;
71*9880Ssam 
72*9880Ssam 	uap = (struct a *)u.u_ap;
73*9880Ssam 	fp = getf(uap->fd);
74*9880Ssam 	if (fp == NULL)
75*9880Ssam 		return;
76*9880Ssam 	if (fp->f_type == DTYPE_SOCKET) {
77*9880Ssam 		struct ostat ub;
78*9880Ssam 
79*9880Ssam 		bzero((caddr_t)&ub, sizeof (ub));
80*9880Ssam 		(void) copyout((caddr_t)&ub, (caddr_t)uap->sb, sizeof (ub));
81*9880Ssam 	} else
82*9880Ssam 		ostat1(fp->f_inode, uap->sb);
83*9880Ssam }
84*9880Ssam 
85*9880Ssam /*
86*9880Ssam  * Old stat system call.  This version follows links.
87*9880Ssam  */
88*9880Ssam ostat()
89*9880Ssam {
90*9880Ssam 	register struct inode *ip;
91*9880Ssam 	register struct a {
92*9880Ssam 		char	*fname;
93*9880Ssam 		struct ostat *sb;
94*9880Ssam 	} *uap;
95*9880Ssam 
96*9880Ssam 	uap = (struct a *)u.u_ap;
97*9880Ssam 	ip = namei(uchar, LOOKUP, 1);
98*9880Ssam 	if (ip == NULL)
99*9880Ssam 		return;
100*9880Ssam 	ostat1(ip, uap->sb);
101*9880Ssam 	iput(ip);
102*9880Ssam }
103*9880Ssam 
104*9880Ssam ostat1(ip, ub)
105*9880Ssam 	register struct inode *ip;
106*9880Ssam 	struct ostat *ub;
107*9880Ssam {
108*9880Ssam 	struct ostat ds;
109*9880Ssam 
110*9880Ssam 	IUPDAT(ip, &time, &time, 0);
111*9880Ssam 	/*
112*9880Ssam 	 * Copy from inode table
113*9880Ssam 	 */
114*9880Ssam 	ds.ost_dev = ip->i_dev;
115*9880Ssam 	ds.ost_ino = (short)ip->i_number;
116*9880Ssam 	ds.ost_mode = (u_short)ip->i_mode;
117*9880Ssam 	ds.ost_nlink = ip->i_nlink;
118*9880Ssam 	ds.ost_uid = (short)ip->i_uid;
119*9880Ssam 	ds.ost_gid = (short)ip->i_gid;
120*9880Ssam 	ds.ost_rdev = (dev_t)ip->i_rdev;
121*9880Ssam 	ds.ost_size = (int)ip->i_size;
122*9880Ssam 	ds.ost_atime = (int)ip->i_atime;
123*9880Ssam 	ds.ost_mtime = (int)ip->i_mtime;
124*9880Ssam 	ds.ost_ctime = (int)ip->i_ctime;
125*9880Ssam 	if (copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds)) < 0)
126*9880Ssam 		u.u_error = EFAULT;
127*9880Ssam }
128*9880Ssam #endif
129