fstat(), fstat64(), lstat(), lstat64(), stat(), stat64()

get file information 

Function


SYNOPSIS

#include <sys/types.h>

#include <sys/stat.h>

int fstat(int fildes, struct stat *buf);

int lstat(const char *pathname, struct stat *buf);

int stat(const char *pathname, struct stat *buf);

int fstat64(int fildes, struct stat64 *buf);

int lstat64(const char *pathname, struct stat64 *buf);

int stat64(const char *pathname, struct stat64 *buf);


DESCRIPTION

The stat() function gets information about the named file and writes it to the area that buf points to. stat() updates any time-related fields before writing into the stat structure. The system must be able to search all directories leading to the file; however, read, write, or execute permission of the file is not required.

The fstat() function is identical to stat(), except that the file whose information is retrieved is specified by file descriptor rather than file name.

The lstat() function has the same effect as stat(), except when the specified path refers to a symbolic link. In that case, lstat() returns information about the link, while stat() returns information about the file the link references.

The fstat64(), lstat64(), and stat64() functions are identical to the fstat(), lstat() and stat() functions except that they take a pointer to struct stat64 instead of struct stat. This permits applications to determine the size of a file that is larger than 2 gigabyes.


PARAMETERS

pathname 

Points to a path name that names a file. The calling process must have at least search permissions on pathname.

fildes 

Is a file descriptor referring to a file for which status is returned.

buf 

Points to a stat or stat64 structure where status information about the file is to be placed.


RETURN VALUES

If successful, these functions return a value of zero. On failure, they return -1 and set errno to one of the following values:

EACCES 

The permissions that a mode specified are denied or search permission is denied on a component of the path name prefix.

EBADF 

fildes is not a valid open file descriptor.

EFAULT 

buf or pathname is an invalid pointer.

EINTR 

A signal interrupted the call.

EINVAL 

The file time returned by the system cannot be represented.

ENAMETOOLONG 

The length of the pathname parameter exceeds PATH_MAX or a path name component is longer than NAME_MAX.

ENOENT 

pathname points to an empty string or to the name of a file that does not exist.

ENOTDIR 

A component of the path name prefix is not a directory.

EOVERFLOW 

The file size, in bytes or the number of blocks allocated to the file, or the file serial number cannot be represented correctly in the structure pointed to by buf.


CONFORMANCE

fstat(), stat(): POSIX.1 (1996), with exceptions.

lstat(): UNIX 98, with exceptions.

fstat64(), lstat64(), stat64(): Large File Specification, revision 1.5.


MULTITHREAD SAFETY LEVEL

fstat(), stat(): Async-signal-safe.

lstat(): MT-Safe.


PORTING ISSUES

There are differences in how the NuTCRACKER Platform fills in the stat structure, compared to the referenced standard. Refer to the struct stat page, and to File Management in the Windows Concepts chapter of the PTC MKS Toolkit UNIX to Windows Porting Guide.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
_NutFastStat(), chmod(), chown(), creat(), link(), open(), read(), readlink(), symlink(), unlink(), utime(), write()

Miscellaneous:
lf64, struct stat


PTC MKS Toolkit 10.5 Documentation Build 40.