xref: /csrg-svn/usr.bin/f77/libU77/fstat_.c (revision 2579)
12514Sdlw /*
2*2579Sdlw char id_fstat[] = "@(#)fstat_.c	1.2";
32514Sdlw  *
42514Sdlw  * get file status
52514Sdlw  *
62514Sdlw  * calling sequence:
72514Sdlw  *	integer fstat, statb(11)
82514Sdlw  *	call fstat (name, statb)
92514Sdlw  * where:
102514Sdlw  *	'statb' will receive the stat structure for file 'name'.
112514Sdlw  */
122514Sdlw 
132514Sdlw #include <sys/types.h>
142514Sdlw #include <sys/stat.h>
152514Sdlw #include "../libI77/f_errno.h"
162514Sdlw #include "../libI77/fiodefs.h"
172514Sdlw 
182514Sdlw extern unit units[];
192514Sdlw 
202514Sdlw long fstat_(lunit, stbuf)
212514Sdlw long *lunit, *stbuf;
222514Sdlw {
232514Sdlw 	struct stat statb;
242514Sdlw 
252514Sdlw 	if (*lunit < 0 || *lunit >= MXUNIT)
26*2579Sdlw 		return((long)(errno=F_ERUNIT));
272514Sdlw 	if (!units[*lunit].ufd)
282514Sdlw 		return((long)(errno=F_ERNOPEN));
292514Sdlw 	if (fstat(fileno(units[*lunit].ufd), &statb) == 0)
302514Sdlw 	{
312514Sdlw 		*stbuf++ = statb.st_dev;
322514Sdlw 		*stbuf++ = statb.st_ino;
332514Sdlw 		*stbuf++ = statb.st_mode;
342514Sdlw 		*stbuf++ = statb.st_nlink;
352514Sdlw 		*stbuf++ = statb.st_uid;
362514Sdlw 		*stbuf++ = statb.st_gid;
372514Sdlw 		*stbuf++ = statb.st_rdev;
382514Sdlw 		*stbuf++ = statb.st_size;
392514Sdlw 		*stbuf++ = statb.st_atime;
402514Sdlw 		*stbuf++ = statb.st_mtime;
412514Sdlw 		*stbuf++ = statb.st_ctime;
422514Sdlw 		return(0L);
432514Sdlw 	}
442514Sdlw 	return ((long)errno);
452514Sdlw }
46