fstat.c revision 84221
1116742Ssam/* $NetBSD: fstat.c,v 1.1 1996/01/13 22:25:38 leo Exp $ */ 2116904Ssam 3139530Ssam/*- 4116742Ssam * Copyright (c) 1993 5116742Ssam * The Regents of the University of California. All rights reserved. 6116742Ssam * 7116742Ssam * Redistribution and use in source and binary forms, with or without 8116742Ssam * modification, are permitted provided that the following conditions 9116742Ssam * are met: 10116904Ssam * 1. Redistributions of source code must retain the above copyright 11116904Ssam * notice, this list of conditions and the following disclaimer. 12116904Ssam * 2. Redistributions in binary form must reproduce the above copyright 13116904Ssam * notice, this list of conditions and the following disclaimer in the 14116904Ssam * documentation and/or other materials provided with the distribution. 15116904Ssam * 3. All advertising materials mentioning features or use of this software 16116742Ssam * must display the following acknowledgement: 17116742Ssam * This product includes software developed by the University of 18116742Ssam * California, Berkeley and its contributors. 19116742Ssam * 4. Neither the name of the University nor the names of its contributors 20116742Ssam * may be used to endorse or promote products derived from this software 21116904Ssam * without specific prior written permission. 22116904Ssam * 23116904Ssam * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24116904Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25116904Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26116904Ssam * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27116904Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28116904Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29116904Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30116904Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31116742Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32116742Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33116742Ssam * SUCH DAMAGE. 34116742Ssam * 35116742Ssam * @(#)stat.c 8.1 (Berkeley) 6/11/93 36116742Ssam */ 37116742Ssam 38116742Ssam#include <sys/cdefs.h> 39116742Ssam__FBSDID("$FreeBSD: head/lib/libstand/fstat.c 84221 2001-09-30 22:28:01Z dillon $"); 40116742Ssam 41116742Ssam#include "stand.h" 42116742Ssam 43138568Ssamint 44116742Ssamfstat(fd, sb) 45116742Ssam int fd; 46116742Ssam struct stat *sb; 47116742Ssam{ 48116742Ssam register struct open_file *f = &files[fd]; 49116742Ssam 50116742Ssam if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { 51116742Ssam errno = EBADF; 52116742Ssam return (-1); 53116742Ssam } 54139502Ssam 55116742Ssam /* operation not defined on raw devices */ 56116742Ssam if (f->f_flags & F_RAW) { 57116742Ssam errno = EOPNOTSUPP; 58116742Ssam return (-1); 59124543Sonoe } 60138568Ssam 61138568Ssam errno = (f->f_ops->fo_stat)(f, sb); 62116742Ssam return (0); 63116742Ssam} 64138568Ssam