1*49182Sbostic /*- 2*49182Sbostic * Copyright (c) 1991 The Regents of the University of California. 3*49182Sbostic * All rights reserved. 4*49182Sbostic * 5*49182Sbostic * %sccs.include.redist.c% 6*49182Sbostic * 7*49182Sbostic * @(#)stat.c 7.1 (Berkeley) 05/05/91 8*49182Sbostic */ 9*49182Sbostic 10*49182Sbostic #include <sys/param.h> 11*49182Sbostic #include <sys/stat.h> 12*49182Sbostic #include "saio.h" 13*49182Sbostic 14*49182Sbostic #ifndef SMALL 15*49182Sbostic fstat(fd, sb) 16*49182Sbostic int fd; 17*49182Sbostic struct stat *sb; 18*49182Sbostic { 19*49182Sbostic register struct iob *io; 20*49182Sbostic 21*49182Sbostic fd -= 3; 22*49182Sbostic if (fd < 0 || fd >= SOPEN_MAX || 23*49182Sbostic ((io = &iob[fd])->i_flgs & F_ALLOC) == 0) { 24*49182Sbostic errno = EBADF; 25*49182Sbostic return (-1); 26*49182Sbostic } 27*49182Sbostic /* only important stuff */ 28*49182Sbostic sb->st_mode = io->i_ino.di_mode; 29*49182Sbostic sb->st_uid = io->i_ino.di_uid; 30*49182Sbostic sb->st_gid = io->i_ino.di_gid; 31*49182Sbostic sb->st_size = io->i_ino.di_size; 32*49182Sbostic return (0); 33*49182Sbostic } 34*49182Sbostic 35*49182Sbostic stat(str, sb) 36*49182Sbostic const char *str; 37*49182Sbostic struct stat *sb; 38*49182Sbostic { 39*49182Sbostic int fd, rv; 40*49182Sbostic 41*49182Sbostic fd = open(str, 0); 42*49182Sbostic if (fd < 0) 43*49182Sbostic return(-1); 44*49182Sbostic rv = fstat(fd, sb); 45*49182Sbostic close(fd); 46*49182Sbostic return(rv); 47*49182Sbostic } 48*49182Sbostic #endif SMALL 49