xref: /csrg-svn/sys/kern/vfs_xxx.c (revision 9984)
1 /*	vfs_xxx.c	4.3	82/12/28	*/
2 
3 #include "../h/param.h"
4 #include "../h/systm.h"
5 #include "../h/inode.h"
6 #include "../h/fs.h"
7 #include "../h/mount.h"
8 #include "../h/dir.h"
9 #include "../h/user.h"
10 #include "../h/buf.h"
11 #include "../h/conf.h"
12 
13 /*
14  * Return the next character fromt the
15  * kernel string pointed at by dirp.
16  */
17 schar()
18 {
19 	return (*u.u_dirp++ & 0377);
20 }
21 
22 /*
23  * Return the next character from the
24  * user string pointed at by dirp.
25  */
26 uchar()
27 {
28 	register c;
29 
30 	c = fubyte(u.u_dirp++);
31 	if (c == -1) {
32 		u.u_error = EFAULT;
33 		c = 0;
34 	}
35 	return (c);
36 }
37 
38 #ifndef NOCOMPAT
39 #include "../h/file.h"
40 #include "../h/nami.h"
41 #include "../h/descrip.h"
42 #include "../h/kernel.h"
43 
44 /*
45  * Oh, how backwards compatibility is ugly!!!
46  */
47 struct	ostat {
48 	dev_t	ost_dev;
49 	u_short	ost_ino;
50 	u_short ost_mode;
51 	short  	ost_nlink;
52 	short  	ost_uid;
53 	short  	ost_gid;
54 	dev_t	ost_rdev;
55 	int	ost_size;
56 	int	ost_atime;
57 	int	ost_mtime;
58 	int	ost_ctime;
59 };
60 
61 /*
62  * The old fstat system call.
63  */
64 ofstat()
65 {
66 	register struct file *fp;
67 	register struct a {
68 		int	fd;
69 		struct ostat *sb;
70 	} *uap;
71 
72 	uap = (struct a *)u.u_ap;
73 	fp = getf(uap->fd);
74 	if (fp == NULL)
75 		return;
76 	if (fp->f_type == DTYPE_SOCKET) {
77 		struct ostat ub;
78 
79 		bzero((caddr_t)&ub, sizeof (ub));
80 		(void) copyout((caddr_t)&ub, (caddr_t)uap->sb, sizeof (ub));
81 	} else
82 		ostat1(fp->f_inode, uap->sb);
83 }
84 
85 /*
86  * Old stat system call.  This version follows links.
87  */
88 ostat()
89 {
90 	register struct inode *ip;
91 	register struct a {
92 		char	*fname;
93 		struct ostat *sb;
94 	} *uap;
95 
96 	uap = (struct a *)u.u_ap;
97 	ip = namei(uchar, LOOKUP, 1);
98 	if (ip == NULL)
99 		return;
100 	ostat1(ip, uap->sb);
101 	iput(ip);
102 }
103 
104 ostat1(ip, ub)
105 	register struct inode *ip;
106 	struct ostat *ub;
107 {
108 	struct ostat ds;
109 
110 	IUPDAT(ip, &time, &time, 0);
111 	/*
112 	 * Copy from inode table
113 	 */
114 	ds.ost_dev = ip->i_dev;
115 	ds.ost_ino = (short)ip->i_number;
116 	ds.ost_mode = (u_short)ip->i_mode;
117 	ds.ost_nlink = ip->i_nlink;
118 	ds.ost_uid = (short)ip->i_uid;
119 	ds.ost_gid = (short)ip->i_gid;
120 	ds.ost_rdev = (dev_t)ip->i_rdev;
121 	ds.ost_size = (int)ip->i_size;
122 	ds.ost_atime = (int)ip->i_atime;
123 	ds.ost_mtime = (int)ip->i_mtime;
124 	ds.ost_ctime = (int)ip->i_ctime;
125 	if (copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds)) < 0)
126 		u.u_error = EFAULT;
127 }
128 #endif
129