POSIX I/O

On top of the C standard library, POSIX provides a large number of system calls to perform additional or low level file operations. Additionally, POSIX specifies some extensions to the standard i/o library to improve interoperability between the two interfaces. In POSIX, files are represented by a file descriptor number, which is a positive integer. Each process has its own file descriptor table which associates each file descriptor number with a particular file object.

As mentioned earlier, the POSIX file system consists of: a superblock that specifies various properties of the file system; a set of inodes that each contain file meta data and pointers to the file contents on disk; directory entries that each represent a (filename, inode) mapping; and file objects which represent currently open files.

Ultimately, the standard i/o library is implemented on top of these POSIX system calls–streams are simply wrappers around file descriptor numbers, and buffers are filled and flushed by calling the read and write system calls. One important task which requires the use of system calls is navigating and managing directories, something that is not possible in standard C; in fact, C provides only a limited interface for most types of special files such as soft links and device files, with many features requiring use of low-level POSIX system calls that extend the basic stream interface. Additionally, POSIX system calls can be used to access and modify additional file metadata such as access permissions, ownership, timestamps, file size, and so on.