xref: /csrg-svn/sys/kern/vfs_xxx.c (revision 14229)
1 /*	vfs_xxx.c	6.1	83/07/29	*/
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 #ifdef COMPAT
39 #include "../h/file.h"
40 #include "../h/nami.h"
41 #include "../h/kernel.h"
42 
43 /*
44  * Oh, how backwards compatibility is ugly!!!
45  */
46 struct	ostat {
47 	dev_t	ost_dev;
48 	u_short	ost_ino;
49 	u_short ost_mode;
50 	short  	ost_nlink;
51 	short  	ost_uid;
52 	short  	ost_gid;
53 	dev_t	ost_rdev;
54 	int	ost_size;
55 	int	ost_atime;
56 	int	ost_mtime;
57 	int	ost_ctime;
58 };
59 
60 /*
61  * The old fstat system call.
62  */
63 ofstat()
64 {
65 	register struct file *fp;
66 	register struct a {
67 		int	fd;
68 		struct ostat *sb;
69 	} *uap = (struct a *)u.u_ap;
70 	extern struct file *getinode();
71 
72 	fp = getinode(uap->fd);
73 	if (fp == NULL)
74 		return;
75 	ostat1((struct inode *)fp->f_data, uap->sb);
76 }
77 
78 /*
79  * Old stat system call.  This version follows links.
80  */
81 ostat()
82 {
83 	register struct inode *ip;
84 	register struct a {
85 		char	*fname;
86 		struct ostat *sb;
87 	} *uap;
88 
89 	uap = (struct a *)u.u_ap;
90 	ip = namei(uchar, LOOKUP, 1);
91 	if (ip == NULL)
92 		return;
93 	ostat1(ip, uap->sb);
94 	iput(ip);
95 }
96 
97 ostat1(ip, ub)
98 	register struct inode *ip;
99 	struct ostat *ub;
100 {
101 	struct ostat ds;
102 
103 	IUPDAT(ip, &time, &time, 0);
104 	/*
105 	 * Copy from inode table
106 	 */
107 	ds.ost_dev = ip->i_dev;
108 	ds.ost_ino = (short)ip->i_number;
109 	ds.ost_mode = (u_short)ip->i_mode;
110 	ds.ost_nlink = ip->i_nlink;
111 	ds.ost_uid = (short)ip->i_uid;
112 	ds.ost_gid = (short)ip->i_gid;
113 	ds.ost_rdev = (dev_t)ip->i_rdev;
114 	ds.ost_size = (int)ip->i_size;
115 	ds.ost_atime = (int)ip->i_atime;
116 	ds.ost_mtime = (int)ip->i_mtime;
117 	ds.ost_ctime = (int)ip->i_ctime;
118 	u.u_error = copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds));
119 }
120 
121 /*
122  * Set IUPD and IACC times on file.
123  * Can't set ICHG.
124  */
125 outime()
126 {
127 	register struct a {
128 		char	*fname;
129 		time_t	*tptr;
130 	} *uap = (struct a *)u.u_ap;
131 	register struct inode *ip;
132 	time_t tv[2];
133 	struct timeval tv0, tv1;
134 
135 	if ((ip = owner(1)) == NULL)
136 		return;
137 	u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
138 	if (u.u_error == 0) {
139 		ip->i_flag |= IACC|IUPD|ICHG;
140 		tv0.tv_sec = tv[0]; tv0.tv_usec = 0;
141 		tv1.tv_sec = tv[1]; tv1.tv_usec = 0;
142 		iupdat(ip, &tv0, &tv1, 0);
143 	}
144 	iput(ip);
145 }
146 #endif
147