Syntax
#include <sys/stat.h>
int fstat(int descriptor,
struct stat *buffer)
|
The fstat() function is used to retrieve information about a file or socket.
Parameters
struct stat {
mode_t st_mode;
ino_t st_ino;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
dev_t st_dev;
size_t st_blksize;
long st_blocks;
qp0l_objtype_t st_objtype;
};
The st_mode, st_dev, and st_blksize fields are the only fields set for socket descriptors. The st_mode field is set to a value that indicates the descriptor is a socket descriptor, the st_dev field is set to -1, and the st_blksize field is set to an optimal value determined by the system.
Authorities
No authorization is required.
Return Value
fstat() returns an integer. Possible values are:
Error Conditions
If fstat() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.
An attempt was made to access an object in a way forbidden by its object access permissions.
The thread does not have access to the specified file, directory, component, or path.
If you are accessing a remote file through the Network File System, update operations to file permissions at the server are not reflected at the client until updates to data that is stored locally by the Network File System take place. (Several options on the Add Mounted File System (ADDMFS) command determine the time between refresh operations of local data.) Access to a remote file may also fail due to different mappings of user IDs (UID) or group IDs (GID) on the local and remote systems.
A given file descriptor or directory pointer is not valid for this operation. The specified descriptor is incorrect, or does not refer to an open file.
The file ID table is missing or damaged.
To recover from this error, run the Reclaim Storage (RCLSTG) command as soon as possible.
An attempt was made to use a system resource that is not available at this time.
A referenced object is damaged. The object cannot be used.
In attempting to use an argument in a call, the system detected an address that is not valid.
While attempting to access a parameter passed to this function, the system detected an address that is not valid. [EFAULT] is returned if this function is passed a pointer parameter that is not valid.
A parameter passed to this function is not valid.
This error code may be returned when the underlying object represented by the descriptor is unable to fill the stat structure (for example, if the function was issued against a socket descriptor that had its connection reset).
A physical I/O error occurred.
A referenced object may be damaged.
You must have appropriate privileges or be the owner of the object or other resource to do the requested operation.
If you are accessing a remote file through the Network File System, the file may have been deleted at the server.
The operation failed because of an unknown system state. See any messages in the job log and correct any errors that are indicated, then retry the operation.
Error Messages
Usage Notes
For connection-oriented sockets with an address family of AF_NS, the value returned for st_blksize is set to the MTU size that is in effect once the connection is established.
Note: IBM reserves the right to change the calculation of the optimal send size.
Related Information
| Top | Sockets APIs | APIs by category |
| [Information Center Home Page | Feedback ] | [Legal | AS/400 Glossary] |