xref: /csrg-svn/usr.bin/f77/libU77/stat_.c (revision 2513)
1*2513Sdlw /*
2*2513Sdlw char id_stat[] = "@(#)stat_.c	1.1";
3*2513Sdlw  *
4*2513Sdlw  * get file status
5*2513Sdlw  *
6*2513Sdlw  * calling sequence:
7*2513Sdlw  *	integer stat, statb(11)
8*2513Sdlw  *	call stat (name, statb)
9*2513Sdlw  * where:
10*2513Sdlw  *	'statb' will receive the stat structure for file 'name'.
11*2513Sdlw  */
12*2513Sdlw 
13*2513Sdlw #include <sys/types.h>
14*2513Sdlw #include <sys/stat.h>
15*2513Sdlw #include "../libI77/f_errno.h"
16*2513Sdlw 
17*2513Sdlw long stat_(name, stbuf, namlen)
18*2513Sdlw char *name; long *stbuf, namlen;
19*2513Sdlw {
20*2513Sdlw 	char buf[128];
21*2513Sdlw 	struct stat statb;
22*2513Sdlw 
23*2513Sdlw 	if (namlen >= sizeof buf)
24*2513Sdlw 		return((long)(errno=F_ERARG));
25*2513Sdlw 	g_char(name, namlen, buf);
26*2513Sdlw 	if (stat(buf, &statb) == 0)
27*2513Sdlw 	{
28*2513Sdlw 		*stbuf++ = statb.st_dev;
29*2513Sdlw 		*stbuf++ = statb.st_ino;
30*2513Sdlw 		*stbuf++ = statb.st_mode;
31*2513Sdlw 		*stbuf++ = statb.st_nlink;
32*2513Sdlw 		*stbuf++ = statb.st_uid;
33*2513Sdlw 		*stbuf++ = statb.st_gid;
34*2513Sdlw 		*stbuf++ = statb.st_rdev;
35*2513Sdlw 		*stbuf++ = statb.st_size;
36*2513Sdlw 		*stbuf++ = statb.st_atime;
37*2513Sdlw 		*stbuf++ = statb.st_mtime;
38*2513Sdlw 		*stbuf++ = statb.st_ctime;
39*2513Sdlw 		return(0L);
40*2513Sdlw 	}
41*2513Sdlw 	return ((long)errno);
42*2513Sdlw }
43