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