xref: /csrg-svn/sys/kern/vfs_xxx.c (revision 12757)
1*12757Ssam /*	vfs_xxx.c	4.5	83/05/27	*/
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 }
379880Ssam 
389880Ssam #ifndef NOCOMPAT
399880Ssam #include "../h/file.h"
409880Ssam #include "../h/nami.h"
419880Ssam #include "../h/kernel.h"
429880Ssam 
439880Ssam /*
449880Ssam  * Oh, how backwards compatibility is ugly!!!
459880Ssam  */
469880Ssam struct	ostat {
479880Ssam 	dev_t	ost_dev;
489984Ssam 	u_short	ost_ino;
499880Ssam 	u_short ost_mode;
509880Ssam 	short  	ost_nlink;
519880Ssam 	short  	ost_uid;
529880Ssam 	short  	ost_gid;
539880Ssam 	dev_t	ost_rdev;
549880Ssam 	int	ost_size;
559880Ssam 	int	ost_atime;
569880Ssam 	int	ost_mtime;
579880Ssam 	int	ost_ctime;
589880Ssam };
599880Ssam 
609880Ssam /*
619880Ssam  * The old fstat system call.
629880Ssam  */
639880Ssam ofstat()
649880Ssam {
659880Ssam 	register struct file *fp;
669880Ssam 	register struct a {
679880Ssam 		int	fd;
689880Ssam 		struct ostat *sb;
69*12757Ssam 	} *uap = (struct a *)u.u_ap;
70*12757Ssam 	extern struct file *getinode();
719880Ssam 
72*12757Ssam 	fp = getinode(uap->fd);
739880Ssam 	if (fp == NULL)
749880Ssam 		return;
75*12757Ssam 	ostat1((struct inode *)fp->f_data, uap->sb);
769880Ssam }
779880Ssam 
789880Ssam /*
799880Ssam  * Old stat system call.  This version follows links.
809880Ssam  */
819880Ssam ostat()
829880Ssam {
839880Ssam 	register struct inode *ip;
849880Ssam 	register struct a {
859880Ssam 		char	*fname;
869880Ssam 		struct ostat *sb;
879880Ssam 	} *uap;
889880Ssam 
899880Ssam 	uap = (struct a *)u.u_ap;
909880Ssam 	ip = namei(uchar, LOOKUP, 1);
919880Ssam 	if (ip == NULL)
929880Ssam 		return;
939880Ssam 	ostat1(ip, uap->sb);
949880Ssam 	iput(ip);
959880Ssam }
969880Ssam 
979880Ssam ostat1(ip, ub)
989880Ssam 	register struct inode *ip;
999880Ssam 	struct ostat *ub;
1009880Ssam {
1019880Ssam 	struct ostat ds;
1029880Ssam 
1039880Ssam 	IUPDAT(ip, &time, &time, 0);
1049880Ssam 	/*
1059880Ssam 	 * Copy from inode table
1069880Ssam 	 */
1079880Ssam 	ds.ost_dev = ip->i_dev;
1089880Ssam 	ds.ost_ino = (short)ip->i_number;
1099880Ssam 	ds.ost_mode = (u_short)ip->i_mode;
1109880Ssam 	ds.ost_nlink = ip->i_nlink;
1119880Ssam 	ds.ost_uid = (short)ip->i_uid;
1129880Ssam 	ds.ost_gid = (short)ip->i_gid;
1139880Ssam 	ds.ost_rdev = (dev_t)ip->i_rdev;
1149880Ssam 	ds.ost_size = (int)ip->i_size;
1159880Ssam 	ds.ost_atime = (int)ip->i_atime;
1169880Ssam 	ds.ost_mtime = (int)ip->i_mtime;
1179880Ssam 	ds.ost_ctime = (int)ip->i_ctime;
11810002Ssam 	u.u_error = copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds));
1199880Ssam }
1209880Ssam #endif
121