Changeset View
Changeset View
Standalone View
Standalone View
stand/libsa/fstat.c
Show All 31 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "stand.h" | #include "stand.h" | ||||
int | int | ||||
fstat(fd, sb) | fstat(int fd, struct stat *sb) | ||||
int fd; | |||||
struct stat *sb; | |||||
{ | { | ||||
struct open_file *f = &files[fd]; | struct open_file *f; | ||||
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { | f = fd2open_file(fd); | ||||
if (f == NULL || f->f_flags == 0) { | |||||
errno = EBADF; | errno = EBADF; | ||||
return (-1); | return (-1); | ||||
} | } | ||||
/* operation not defined on raw devices */ | /* operation not defined on raw devices */ | ||||
if (f->f_flags & F_RAW) { | if (f->f_flags & F_RAW) { | ||||
errno = EOPNOTSUPP; | errno = EOPNOTSUPP; | ||||
return (-1); | return (-1); | ||||
} | } | ||||
errno = (f->f_ops->fo_stat)(f, sb); | errno = (f->f_ops->fo_stat)(f, sb); | ||||
if (errno) | if (errno) | ||||
return (-1); | return (-1); | ||||
return (0); | return (0); | ||||
} | } |