stat.c revision d3e55dcdc881b833a707e39ae1e12d8d5d35ad2d
/*
* 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 2007 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* 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
*/
/*
* nmflag has the following values
*
* 1 - Always do lookup. i.e. stat, lstat.
* 2 - Name is optional i.e. fstatat
* 0 - Don't lookup name, vp is in file_p. i.e. fstat
*
*/
static int
{
int error;
int estale_retry = 0;
/*
* Only return EFAULT for fstatat when fd == AT_FDCWD && name == NULL
*/
} else
return (EFAULT);
} else {
char startchar;
return (EFAULT);
} else {
startchar = '\0';
}
return (EBADF);
}
} else {
}
}
if (audit_active)
goto lookup;
return (error);
}
} else {
}
return (0);
}
/*
* Native syscall interfaces:
*
* N-bit kernel, N-bit applications, N-bit file offsets
*/
int
{
}
int
{
}
/*
* fstat can and should be fast, do an inline implementation here.
*/
{ \
int error; \
\
if (audit_active) \
audit_setfsat_path(1); \
if (error) \
return (0); \
}
int
{
}
int
{
}
#if defined(__i386) || defined(__i386_COMPAT)
/*
* Handle all the "extended" stat operations in the same way;
* validate the version, then call the real handler.
*/
#endif /* __i386 || __i386_COMPAT */
#if defined(__i386)
/*
* Syscalls for i386 applications that issue {,l,f}xstat() directly
*/
int
{
}
int
{
}
int
{
}
#endif /* __i386 */
/*
* 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;
out:
if (error != 0) {
goto lookup;
}
return (0);
}
#if defined(_SYSCALL32_IMPL)
/*
* 64-bit kernel, 32-bit applications, 32-bit file offsets
*/
int
{
}
int
{
}
int
{
}
int
{
}
#if defined(__i386_COMPAT)
/*
* Syscalls for i386 applications that issue {,l,f}xstat() directly
*/
int
{
}
int
{
}
int
{
}
#endif /* __i386_COMPAT */
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;
out:
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
{
}
int
{
}
static int
{
int error;
return (error);
}
return (EFAULT);
return (0);
}
static int
{
int error;
int link_follow;
int estale_retry = 0;
out:
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 *, int, struct stat64_32 *, int, int);
int
{
}
int
{
}
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;
out:
if (error != 0) {
goto lookup;
}
return (0);
}
#endif /* _SYSCALL32_IMPL */