sys/time.h struct timeval { time_t tv_sec //seconds suseconds_t tv_usec //microseconds }; struct fd_set { long fds_bits[] //bit mask for open file descriptions }; void FD_CLR(int fd, fd_set *fdset) Clears the bit for the file descriptor fd in the file descriptor set fdset. int FD_ISSET(int fd, fd_set *fdset) Returns a non-zero value if the bit for the file descriptor fd is set in the file descriptor set by fdset, and 0 otherwise. void FD_SET(int fd, fd_set *fdset) Sets the bit for the file descriptor fd in the file descriptor set fdset. void FD_ZERO(fd_set *fdset) Initialises the file descriptor set fdset to have zero bits for all file descriptors. FD_SETSIZE Maximum number of file descriptors in an fd_set structure. int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout); Indicates which of the specified file descriptors is ready for reading, ready for writing, or has an error condition pending. If the specified condition is false for all of the specified file descriptors, select() blocks, up to the specified timeout interval, until the specified condition is true for at least one of the specified file descriptors. fcntl.h int open(const char *path, int oflag, ...); Opens a file specified by path according to opening mode specified by oflag and return the file descriptor of the opened file. Opening flag can be any of these: O_EXEC, O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_APPEND, O_TRUNC, O_CLOEXEC, O_DIRECTORY, O_EXCL, O_SEARCH, O_NONBLOCK, O_NOFOLLOW, O_RSYNC, O_SYNC, O_NOCTTY, O_TTY_INIT unistd.h int gethostname(char *name, size_t namelen); Places the standard host name of the machine into name string. off_t lseek(int fd, off_t offset, int whence); Sets the file offset for the open file description associated with the file descriptor fd, depending on whence If whence is SEEK_SET, the file offset shall be set to offset bytes. If whence is SEEK_CUR, the file offset shall be set to its current location plus offset. If whence is SEEK_END, the file offset shall be set to the size of the file plus offset. ssize_t read(int fd, void *buf, size_t nbyte); Reads nbyte bytes from the file associated with the open file descriptor, fd, into the buffer pointed to by buf. ssize_t write(int fildes, const void *buf, size_t nbyte); Writes nbyte bytes from the buffer pointed to by buf to the file associated with the open file descriptor, fd. int close(int fd); Closes file descriptor fd. int access(const char *path, int amode); Checks the file named by the pathname pointed to by the path argument for accessibility according to the bit pattern contained in amode (F_OK, R_OK, W_OK, X_OK). char *getcwd(char *buf, size_t size); Places an absolute pathname of the current working directory in the array pointed to by buf. unsigned sleep(unsigned seconds); Suspends the execution of the thread for given number of seconds. pid_t getpid(void); Returns the process ID of the calling process. dirent.h struct dirent { ino_t d_ino //File serial number. char d_name[] //Name of entry. }; typedef struct __dirstream DIR; DIR* opendir(const char* dirname); Opens a directory named by dirname struct dirent* readdir(DIR* dirp); Returns a pointer to a structure representing the directory entry at the current position in the directory stream specified by the argument dirp int closedir(DIR *dirp); Closes the directory stream referred to by the argument dirp sys/stat.h struct stat { dev_t st_dev //Device ID of device containing file. ino_t st_ino //File serial number. mode_t st_mode //Mode of file (see below). nlink_t st_nlink //Number of hard links to the file. uid_t st_uid //User ID of file. gid_t st_gid //Group ID of file. dev_t st_rdev //Device ID (if file is character or block special). off_t st_size //For regular files, the file size in bytes. //For symbolic links, the length in bytes of the //pathname contained in the symbolic link. //For a shared memory object, the length in bytes. //For a typed memory object, the length in bytes. //For other file types, the use of this field is //unspecified. struct timespec st_atim //Last data access timestamp. struct timespec st_mtim //Last data modification timestamp. struct timespec st_ctim //Last file status change timestamp. blksize_t st_blksize //A file system-specific preferred I/O block size //for this object. In some file system types, this //may vary from file to file. blkcnt_t st_blocks //Number of blocks allocated for this object. }; int stat (const char *filename, struct stat *buf); Returns information about the attributes of the file named by filename in the structure pointed to by buf. int fstat (int fd, struct stat *buf); The fstat function is like stat, except that it takes an open file descriptor (filedes)as an argument instead of a file name.