xref: /csrg-svn/usr.bin/f77/libU77/lstat_.c (revision 47944)
1*47944Sbostic /*-
2*47944Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic  * All rights reserved.
412028Sdlw  *
5*47944Sbostic  * %sccs.include.proprietary.c%
623037Skre  */
723037Skre 
8*47944Sbostic #ifndef lint
9*47944Sbostic static char sccsid[] = "@(#)lstat_.c	5.2 (Berkeley) 04/12/91";
10*47944Sbostic #endif /* not lint */
11*47944Sbostic 
1223037Skre /*
1312028Sdlw  * get file status
1412028Sdlw  *
1512028Sdlw  * calling sequence:
1612028Sdlw  *	integer lstat, statb(12)
1712028Sdlw  *	external lstat
1812028Sdlw  *	ierr = lstat (name, statb)
1912028Sdlw  * where:
2012028Sdlw  *	'statb' will receive the stat structure for file 'name'.
2112028Sdlw  */
2212028Sdlw 
2312148Sdlw #include <sys/param.h>
2412148Sdlw #ifndef	MAXPATHLEN
2512148Sdlw #define MAXPATHLEN	128
2612148Sdlw #endif
2712028Sdlw #include <sys/stat.h>
2812028Sdlw #include "../libI77/f_errno.h"
2912028Sdlw 
lstat_(name,stbuf,namlen)3012028Sdlw long lstat_(name, stbuf, namlen)
3112028Sdlw char *name; long *stbuf, namlen;
3212028Sdlw {
3312148Sdlw 	char buf[MAXPATHLEN];
3412028Sdlw 	struct stat statb;
3512028Sdlw 
3612028Sdlw 	if (namlen >= sizeof buf)
3712028Sdlw 		return((long)(errno=F_ERARG));
3812028Sdlw 	g_char(name, namlen, buf);
3912028Sdlw 	if (lstat(buf, &statb) == 0)
4012028Sdlw 	{
4112028Sdlw 		*stbuf++ = statb.st_dev;
4212028Sdlw 		*stbuf++ = statb.st_ino;
4312028Sdlw 		*stbuf++ = statb.st_mode;
4412028Sdlw 		*stbuf++ = statb.st_nlink;
4512028Sdlw 		*stbuf++ = statb.st_uid;
4612028Sdlw 		*stbuf++ = statb.st_gid;
4712028Sdlw 		*stbuf++ = statb.st_rdev;
4812028Sdlw 		*stbuf++ = statb.st_size;
4912028Sdlw 		*stbuf++ = statb.st_atime;
5012028Sdlw 		*stbuf++ = statb.st_mtime;
5112028Sdlw 		*stbuf++ = statb.st_ctime;
5212028Sdlw 		*stbuf++ = statb.st_blksize;
5312028Sdlw 		return(0L);
5412028Sdlw 	}
5512028Sdlw 	return ((long)errno);
5612028Sdlw }
57