xref: /csrg-svn/sys/stand.att/stat.c (revision 63370)
149182Sbostic /*-
2*63370Sbostic  * Copyright (c) 1991, 1993
3*63370Sbostic  *	The Regents of the University of California.  All rights reserved.
449182Sbostic  *
549182Sbostic  * %sccs.include.redist.c%
649182Sbostic  *
7*63370Sbostic  *	@(#)stat.c	8.1 (Berkeley) 06/11/93
849182Sbostic  */
949182Sbostic 
1049182Sbostic #include <sys/param.h>
1149182Sbostic #include <sys/stat.h>
1260328Smckusick #include <stand.att/saio.h>
1349182Sbostic 
1449182Sbostic #ifndef SMALL
fstat(fd,sb)1549182Sbostic fstat(fd, sb)
1649182Sbostic 	int fd;
1749182Sbostic 	struct stat *sb;
1849182Sbostic {
1949182Sbostic 	register struct iob *io;
2049182Sbostic 
2149182Sbostic 	fd -= 3;
2249182Sbostic 	if (fd < 0 || fd >= SOPEN_MAX ||
2349182Sbostic 	    ((io = &iob[fd])->i_flgs & F_ALLOC) == 0) {
2449182Sbostic 		errno = EBADF;
2549182Sbostic 		return (-1);
2649182Sbostic 	}
2749182Sbostic 	/* only important stuff */
2849182Sbostic 	sb->st_mode = io->i_ino.di_mode;
2949182Sbostic 	sb->st_uid = io->i_ino.di_uid;
3049182Sbostic 	sb->st_gid = io->i_ino.di_gid;
3149182Sbostic 	sb->st_size = io->i_ino.di_size;
3249182Sbostic 	return (0);
3349182Sbostic }
3449182Sbostic 
stat(str,sb)3549182Sbostic stat(str, sb)
3649182Sbostic 	const char *str;
3749182Sbostic 	struct stat *sb;
3849182Sbostic {
3949182Sbostic 	int fd, rv;
4049182Sbostic 
4149182Sbostic 	fd = open(str, 0);
4249182Sbostic 	if (fd < 0)
4349182Sbostic 		return(-1);
4449182Sbostic 	rv = fstat(fd, sb);
4549182Sbostic 	close(fd);
4649182Sbostic 	return(rv);
4749182Sbostic }
4860357Sbostic #endif /* SMALL */
49