xref: /original-bsd/usr.bin/f77/libU77/fstat_.c (revision 1403a0cd)
1 /*
2 char id_fstat[] = "@(#)fstat_.c	1.3";
3  *
4  * get file status
5  *
6  * calling sequence:
7  *	integer fstat, statb(12)
8  *	call fstat (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 #include "../libI77/fiodefs.h"
17 
18 extern unit units[];
19 
20 long fstat_(lunit, stbuf)
21 long *lunit, *stbuf;
22 {
23 	struct stat statb;
24 
25 	if (*lunit < 0 || *lunit >= MXUNIT)
26 		return((long)(errno=F_ERUNIT));
27 	if (!units[*lunit].ufd)
28 		return((long)(errno=F_ERNOPEN));
29 	if (fstat(fileno(units[*lunit].ufd), &statb) == 0)
30 	{
31 		*stbuf++ = statb.st_dev;
32 		*stbuf++ = statb.st_ino;
33 		*stbuf++ = statb.st_mode;
34 		*stbuf++ = statb.st_nlink;
35 		*stbuf++ = statb.st_uid;
36 		*stbuf++ = statb.st_gid;
37 		*stbuf++ = statb.st_rdev;
38 		*stbuf++ = statb.st_size;
39 		*stbuf++ = statb.st_atime;
40 		*stbuf++ = statb.st_mtime;
41 		*stbuf++ = statb.st_ctime;
42 		*stbuf++ = statb.st_blksize;
43 		return(0L);
44 	}
45 	return ((long)errno);
46 }
47