stat.c revision 165906
1109864Sjeff/*	$NetBSD: stat.c,v 1.4 1996/01/13 22:25:43 leo Exp $	*/
2113357Sjeff
3109864Sjeff/*-
4109864Sjeff * Copyright (c) 1993
5109864Sjeff *	The Regents of the University of California.  All rights reserved.
6109864Sjeff *
7109864Sjeff * Redistribution and use in source and binary forms, with or without
8109864Sjeff * modification, are permitted provided that the following conditions
9109864Sjeff * are met:
10109864Sjeff * 1. Redistributions of source code must retain the above copyright
11109864Sjeff *    notice, this list of conditions and the following disclaimer.
12109864Sjeff * 2. Redistributions in binary form must reproduce the above copyright
13109864Sjeff *    notice, this list of conditions and the following disclaimer in the
14109864Sjeff *    documentation and/or other materials provided with the distribution.
15109864Sjeff * 4. Neither the name of the University nor the names of its contributors
16109864Sjeff *    may be used to endorse or promote products derived from this software
17109864Sjeff *    without specific prior written permission.
18109864Sjeff *
19109864Sjeff * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20109864Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21109864Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22109864Sjeff * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23109864Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24109864Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25109864Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26109864Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27116182Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28116182Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29116182Sobrien * SUCH DAMAGE.
30109864Sjeff *
31109864Sjeff *	@(#)stat.c	8.1 (Berkeley) 6/11/93
32109864Sjeff */
33109864Sjeff
34109864Sjeff#include <sys/cdefs.h>
35109864Sjeff__FBSDID("$FreeBSD: head/lib/libstand/stat.c 165906 2007-01-09 01:02:06Z imp $");
36109864Sjeff
37112966Sjeff#include "stand.h"
38109864Sjeff
39109864Sjeffint
40109864Sjeffstat(str, sb)
41109864Sjeff	const char *str;
42109864Sjeff	struct stat *sb;
43109864Sjeff{
44109864Sjeff	int fd, rv;
45109864Sjeff
46109864Sjeff	fd = open(str, O_RDONLY);
47109864Sjeff	if (fd < 0)
48109864Sjeff		return (-1);
49109864Sjeff	rv = fstat(fd, sb);
50109864Sjeff	(void)close(fd);
51109864Sjeff	return (rv);
52109864Sjeff}
53121790Sjeff