Detailed Description

Functions

int fcntl (int fildes, int cmd,...)
 
int fstat (int fildes, struct stat *buf)
 
int isatty (int fildes)
 
off_t lseek (int fildes, off_t offset, int whence)
 
int lstat (const char *path, struct stat *buf)
 

Function Documentation

int fcntl ( int  fildes,
int  cmd,
  ... 
)

This function performs various operations on open files such as:

  • F_DUPFD: duplicate a file descriptor
  • F_GETFD: get the file descriptor flags
  • F_SETFD: set the file descriptor flags
  • F_GETOWN: get the file descriptor owner process ID.
Parameters
fildesThe file descriptor
cmdThe operation to perform
Returns
Zero on success or -1 on error with errno (see Error Numbers) set to:
  • EBADF: invalid file descriptor
  • ENOTSUP: cmd is not supported for the file descriptor
int fstat ( int  fildes,
struct stat buf 
)

This function gets various file statistics for the specified file descriptor.

Returns
Zero on success or -1 on error with errno (see Error Numbers) set to:
  • EBADF: fildes is invalid
  • EINVAL: buf is NULL
int isatty ( int  fildes)

This function checks to see if fildes is associated with a terminal device.

Returns
Zero on success or -1 on error with errno (see Error Numbers) set to:
  • ENOTTY: fildes is not associated with a terminal device
  • EBADF: fildes is invalid
off_t lseek ( int  fildes,
off_t  offset,
int  whence 
)

This function sets the file offset for fildes using the following values of whence:

  • SEEK_SET: set the offset to offset
  • SEEK_CUR: set the offset to current location plus offset
  • SEEK_END: set the offset to the size of the file plus offset
Returns
Zero on success or -1 on error with errno (see Error Numbers) set to:
  • EBADF: fildes is invalid
  • EINVAL: whence is invalid
int lstat ( const char *  path,
struct stat buf 
)

This function is equivalent to stat() except path refers to a symbolic link.

Returns
Zero on success or -1 on error with errno (see Error Numbers) set to:
  • ENAMETOOLONG: path exceeds PATH_MAX or a component of path exceeds NAME_MAX
  • ENOENT: path does not exist
  • EACCES: search permission is denied for a component of path
Parameters
pathThe path the to symbolic link
bufThe destination buffer