stat.c revision 005d3feb53a9a10272d4a24b03991575d6a9bcb3
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
/*
* Get file attribute information through a file name or a file descriptor.
*/
#include <sys/isa_defs.h>
#include <sys/sysmacros.h>
#include <sys/pathname.h>
/*
* Get the vp to be stated and the cred to be used for the call
* to VOP_GETATTR
*/
static int
{
int error;
int estale_retry = 0;
/*
* Only return EFAULT for fstatat when fd == AT_FDCWD && name == NULL
*/
} else {
char startchar;
return (EFAULT);
if (startchar != '/') {
return (EBADF);
}
} else {
}
}
if (AU_AUDITING())
goto lookup;
return (error);
}
return (0);
}
/*
* Native syscall interfaces:
*
* N-bit kernel, N-bit applications, N-bit file offsets
*/
/*
* fstat can and should be fast, do an inline implementation here.
*/
{ \
int error; \
\
if (AU_AUDITING()) \
audit_setfsat_path(1); \
if (error) \
return (0); \
}
int
{
}
int
{
int followflag;
int csflags;
if (followflag == 0)
}
int
{
}
int
{
}
/*
* Common code for stat(), lstat(), and fstat().
* (32-bit kernel, 32-bit applications, 32-bit files)
* (64-bit kernel, 64-bit applications, 64-bit files)
*/
static int
{
int error;
return (error);
#ifdef _ILP32
/*
* (32-bit kernel, 32-bit applications, 32-bit files)
* NOTE: 32-bit kernel maintains a 64-bit unsigend va_size.
*
* st_size of devices (VBLK and VCHR special files) is a special case.
* POSIX does not define size behavior for special files, so the
* following Solaris specific behavior is not a violation. Solaris
* returns the size of the device.
*
* For compatibility with 32-bit programs which happen to do stat() on
* a (mknod) bigger than 2GB we suppress the large file EOVERFLOW and
* instead we return the value MAXOFF32_T (LONG_MAX).
*
* 32-bit applications that care about the size of devices should be
* built 64-bit or use a large file interface (lfcompile(5) or lf64(5)).
*/
/* OVERFLOW | UNKNOWN_SIZE */
}
#endif /* _ILP32 */
return (EOVERFLOW);
}
return (EFAULT);
return (0);
}
static int
{
int error;
int link_follow;
int estale_retry = 0;
if (error != 0) {
goto lookup;
}
return (0);
}
#if defined(_SYSCALL32_IMPL)
/*
* 64-bit kernel, 32-bit applications, 32-bit file offsets
*/
int
{
}
int
{
int followflag;
int csflags;
if (followflag == 0)
}
int
{
}
int
{
}
static int
{
int error;
return (error);
/* devices are a special case, see comments in cstat */
/* OVERFLOW | UNKNOWN_SIZE */
}
/* check for large values */
return (EOVERFLOW);
}
return (EFAULT);
return (0);
}
static int
{
int error;
int link_follow;
int estale_retry = 0;
if (error != 0) {
goto lookup;
}
return (0);
}
#endif /* _SYSCALL32_IMPL */
#if defined(_ILP32)
/*
* 32-bit kernel, 32-bit applications, 64-bit file offsets.
*
* These routines are implemented differently on 64-bit kernels.
*/
int
{
}
int
{
int followflag;
int csflags;
if (followflag == 0)
}
int
{
}
int
{
}
static int
{
int error;
return (error);
}
return (EFAULT);
return (0);
}
static int
{
int error;
int link_follow;
int estale_retry = 0;
if (error != 0) {
goto lookup;
}
return (0);
}
#endif /* _ILP32 */
#if defined(_SYSCALL32_IMPL)
/*
* 64-bit kernel, 32-bit applications, 64-bit file offsets.
*
* We'd really like to call the "native" stat calls for these ones,
* but the problem is that the 64-bit ABI defines the 'stat64' structure
* differently from the way the 32-bit ABI defines it.
*/
static int cstatat64_32(int, char *, struct stat64_32 *, int, int);
int
{
}
int
{
int followflag;
int csflags;
if (followflag == 0)
}
int
{
}
int
{
}
static int
{
int error;
return (error);
return (EOVERFLOW);
}
return (EFAULT);
return (0);
}
static int
{
int error;
int link_follow;
int estale_retry = 0;
if (error != 0) {
goto lookup;
}
return (0);
}
#endif /* _SYSCALL32_IMPL */