CSCE 313: Introduction to Computer Systems - UNIX File I/O

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/32

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering the core concepts, system calls, data structures, and permissions of UNIX File I/O from CSCE 313.

33 Terms

1
New cards

Unix File

An abstraction defined as an ordered sequence of bytes B0,B1,…,Bk,…,Bm−1B_0, B_1, \dots, B_k, \dots, B_{m-1}, providing a uniform interface through which all input and output operations are performed.

2
New cards

Regular File

A common Unix file type that contains arbitrary user or application data, structured either as binary data or text.

3
New cards

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.

4
New cards

Character Special File

A device file representing character-oriented I/O devices, such as terminal interfaces (e.g., /dev/tty2).

5
New cards

Block Special File

A device file representing block-oriented mass storage devices, such as disk partitions (e.g., /dev/sda2).

6
New cards

FIFO (Named Pipe)

A specific Unix file type used to facilitate inter-process communication (IPC).

7
New cards

Socket

A Unix file type used for network communication between processes; when configured as a Unix domain socket, it possesses a filesystem pathname.

8
New cards

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+1255 + 1] (name of entry).

9
New cards

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.

10
New cards

Standard Shell File Descriptors

The three default open file descriptors allocated by a shell for every newly created process: 00 for standard input (stdin), 11 for standard output (stdout), and 22 for standard error (stderr).

11
New cards

File Cursor (File Position)

A kernel-tracked byte offset (initialized to 00 upon opening) associated with an open file that indicates the next byte position to read from or write to, advancing automatically with each operation.

12
New cards

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.

13
New cards

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-1 on failure.

14
New cards

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 00 on success or −1-1 on error.

15
New cards

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, 00 on EOF, or −1-1 on error.

16
New cards

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-1 on error.

17
New cards

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.

18
New cards

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.

19
New cards

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.

20
New cards

O_EXCL

An open() flag that, when bitwise OR-ed with O_CREAT, atomically returns an error if the specified file already exists.

21
New cards

O_TRUNC

An open() flag that truncates the target regular file's length to 00 bytes if it already exists and is opened for writing.

22
New cards

O_APPEND

An open() flag that automatically sets the file offset to the end of the file prior to each write operation.

23
New cards

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.

24
New cards

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).

25
New cards

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.

26
New cards

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.

27
New cards

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.

28
New cards

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 (xx) permission.

29
New cards

Directory Write (w) Permission

A directory permission bit that allows creating, deleting, or renaming file entries inside the directory, requiring concurrent execute (xx) permission to succeed.

30
New cards

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.

31
New cards

S_ISUID

The set-user-ID mode bit (octal 0400004000), which causes a process executing the file to temporarily assume the effective user ID (euid) of the file owner.

32
New cards

S_ISGID

The set-group-ID mode bit (octal 0200002000), which causes an executing process to assume the effective group ID (egid) of the file's owning group.

33
New cards

S_ISVTX

The sticky bit (octal 0100001000) applied to directories to restrict the deletion or renaming of contained files exclusively to the file owner, directory owner, or root user.