1/32
Vocabulary flashcards covering the core concepts, system calls, data structures, and permissions of UNIX File I/O from CSCE 313.
Unix File
An abstraction defined as an ordered sequence of bytes B0,B1,…,Bk,…,Bm−1, providing a uniform interface through which all input and output operations are performed.
Regular File
A common Unix file type that contains arbitrary user or application data, structured either as binary data or text.
Directory
A specialized Unix file containing the names and locations of other files as structured records of type dirent, which cannot be read directly as a standard byte stream.
Character Special File
A device file representing character-oriented I/O devices, such as terminal interfaces (e.g., /dev/tty2).
Block Special File
A device file representing block-oriented mass storage devices, such as disk partitions (e.g., /dev/sda2).
FIFO (Named Pipe)
A specific Unix file type used to facilitate inter-process communication (IPC).
Socket
A Unix file type used for network communication between processes; when configured as a Unix domain socket, it possesses a filesystem pathname.
struct dirent
A C directory entry structure containing directory record metadata: ino_t d_ino (file number/inode of entry), __uint16_t d_reclen (length of record), __uint8_t d_type (file type), __uint8_t d_namlen (length of name), and char d_name[255+1] (name of entry).
File Descriptor (FD)
A small, non-negative integer returned by the open() system call that serves as a process-level handle indexing into the process's descriptor table.
Standard Shell File Descriptors
The three default open file descriptors allocated by a shell for every newly created process: 0 for standard input (stdin), 1 for standard output (stdout), and 2 for standard error (stderr).
File Cursor (File Position)
A kernel-tracked byte offset (initialized to 0 upon opening) associated with an open file that indicates the next byte position to read from or write to, advancing automatically with each operation.
lseek()
A system call that explicitly modifies the current file position/offset on demand, overriding the default automatic sequential advancement tied to read and write calls.
open()
A system call that informs the kernel of a process's intent to access a file, establishes session state/permissions, and returns the smallest available non-negative file descriptor integer, or −1 on failure.
close()
A system call that informs the kernel a process has finished accessing a file, allowing the kernel to free associated data structures and restore the descriptor to the available descriptor pool; returns 0 on success or −1 on error.
read()
A system call with signature ssize_t read(int fd, void *buf, size_t num) that copies up to num bytes from the current file position into memory buffer buf, advancing the file cursor; returns the number of bytes read, 0 on EOF, or −1 on error.
write()
A system call with signature ssize_t write(int fd, void *buf, size_t num) that copies up to num bytes from buffer buf to the file cursor position and adjusts the offset; returns the number of bytes written or −1 on error.
Short Count
A condition in which read() or write() transfers fewer bytes than requested without encountering an error, caused by situations such as reaching EOF early, network buffering delays, terminal input limits, or signal interruptions.
O_RDONLY, O_WRONLY, O_RDWR
The three mutually exclusive access flags passed to open(), specifying access for read-only, write-only, or both read and write, respectively.
O_CREAT
An open() flag instructing the kernel to create the specified file if it does not already exist, which requires supplying the mode_t mode permission argument.
O_EXCL
An open() flag that, when bitwise OR-ed with O_CREAT, atomically returns an error if the specified file already exists.
O_TRUNC
An open() flag that truncates the target regular file's length to 0 bytes if it already exists and is opened for writing.
O_APPEND
An open() flag that automatically sets the file offset to the end of the file prior to each write operation.
Inode
An on-disk data structure identified by an integer index that stores a file's metadata (e.g., owner, mode, size, timestamps) and direct/indirect block pointers to disk data blocks.
Hard Link
A directory entry mapping a filename directly to an inode number; multiple entries in the same or different directories can point to the same inode, incrementing its link count (st_nlink).
Descriptor Table
A private per-process table maintained by the kernel, indexed by file descriptors, where each entry points to an entry in the system-wide File Table.
File Table
A kernel-wide table shared by all processes where each open file entry stores the current file cursor position, status flags, a reference count (refcnt), and a pointer to the corresponding v-node entry.
v-node Table
A kernel-wide table shared by all processes containing exactly one entry per active file, storing cached inode metadata such as file size, permissions, and file type.
Directory Read (r) Permission
A directory permission bit that allows a process to list the names of entries within the directory (e.g., via ls), though reading file metadata still requires execute (x) permission.
Directory Write (w) Permission
A directory permission bit that allows creating, deleting, or renaming file entries inside the directory, requiring concurrent execute (x) permission to succeed.
Directory Execute (x) Permission
A directory permission bit (the search bit) required to traverse into the directory, access a file inside it by name (e.g., cd or cat), or retrieve entry inode metadata.
S_ISUID
The set-user-ID mode bit (octal 04000), which causes a process executing the file to temporarily assume the effective user ID (euid) of the file owner.
S_ISGID
The set-group-ID mode bit (octal 02000), which causes an executing process to assume the effective group ID (egid) of the file's owning group.
S_ISVTX
The sticky bit (octal 01000) applied to directories to restrict the deletion or renaming of contained files exclusively to the file owner, directory owner, or root user.