fstat64()--Get File Information by Descriptor (Large File Enabled)
Syntax
#include <sys/stat.h> int fstat64(int fildes, struct stat64 *buf);Service Program Name: QP0LLIB1
Default Public Authority: *USE
Threadsafe: Conditional; see Usage Notes.
The fstat64() function gets status information about the file specified by the open file descriptor file_descriptor and stores the information in the area of memory indicated by the buf argument. The status information is returned in a stat64 structure, as defined in the <sys/stat.h> header file.
fstat64() is enabled for large files. It is capable of operating on files larger than 2GB minus 1 byte as long as the file has been opened by either of the following:
- Using the open64() function (see open64()--Open File (Large File Enabled)).
- Using the open() function (see open()--Open File) with O_LARGEFILE set in the oflag parameter.
The elements of the stat64 structure are described in stat64()--Get File Information (Large File Enabled).
For additional information about parameters, authorities required, and error conditions, see fstat()--Get File Information by Descriptor.
Usage Notes
- When you develop in C-based languages, the prototypes for the 64-bit APIs
are normally hidden. To use the fstat64() API and the
struct stat64 data type, you must compile the source with the
_LARGE_FILE_API macro defined.
When you develop in C-based languages and this function is compiled with _64_BIT_TIME defined, it will be mapped to fstat64_time64(). This mapping will occur whether or not _LARGE_FILES is also defined. Note that the type of the buffer parameter, struct stat *, also will be mapped to type struct stat64_time64 *. See stat64_time64() for more information about this structure.
- All of the usage notes for fstat() apply to fstat64(). See Usage Notes in the fstat() API.
Example
The following example gets status information.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
#define _LARGE_FILE_API #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <time.h> main() { char fn[]="temp.file"; struct stat64 info; int file_descriptor; if ((file_descriptor = creat64(fn, S_IWUSR)) < 0) perror("creat64() error"); else { if (ftruncate64(file_descriptor, 8589934662) != 0) perror("ftruncate64() error"); else { if (fstat64(file_descriptor, &info) != 0) perror("fstat64() error"); else { puts("fstat64() returned:"); printf(" inode: %d\n", (int) info.st_ino); printf(" dev id: %d\n", (int) info.st_dev); printf(" mode: %08x\n", info.st_mode); printf(" links: %d\n", info.st_nlink); printf(" uid: %d\n", (int) info.st_uid); printf(" gid: %d\n", (int) info.st_gid); printf(" size: %lld\n", (long long) info.st_size); } } close(file_descriptor); unlink(fn); } }
Output: Note that the output may vary from system to system.
fstat64() returned: inode: 3057 dev id: 1 mode: 03000080 links: 1 uid: 137 gid: 500 size: 8589934662
API introduced: V4R4