Linux File System Flashcards

1
Q

What’s the basic definition of a linux file

A

A sequence of 0 or more bytes, arbitrary information. No distinction is made between any kind of file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does linux handle race conditions in read / write operations to files?

A

Using locks. The locking algorithm requires the caller to specify the file to be locked, the starting byte and the number of bytes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can a file be created?

A

Through the creat system call. The file is created and opened for writing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is returned by the creat system call?

A

A file descriptor, file is configured in open mode.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are file descriptors 0, 1 and 2?

A

These are standard input, output and error. When used as part of pipes these are redirected to the corresponding pipes (buffers).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Explain what’s an i-node

A

Representation of a file (including directories and special files) under the linux virtual file system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How are paths represented in the virtual file system?

A

As D-entries in the central dentry data structure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What information is contained in the Superblock

A

Critical information about the layout of the file system; number of i-nodes, number of disk blocks and the start of the list of free disk blocks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the components of an ext2 block group and their roles?

A

Superblock: a copy of the file system’s superblock. Group descriptor table: information about the group itself, such as location of bitmaps, number of free blocks and i-nodes in the group. Block bitmap: bitmap that tracks usage status of the blocks in the block group. I-node bitmap: tracks usage status of the nodes in the block group. I-node table: table containing i-nodes for files and directories stored in the block group. Data blocks: the actual blocks that contain data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a block?

A

Fixed-size unit of data storage. Basic unit of data management in a file system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe what a disk request looks like

A

First stage: software queue (device driver), second stage: hardware controller, third stage actual disk movement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Name a few characteristics a FS must provide

A

Naming, organizing fine names with directories, organization (map files to blocks), protection (enforcing access restrictions) and reliability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Where does protection for a certain file reside?

A

In the I-node itself. Not in the block.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a sector in a hard disk?

A

It’s a physical portion of the disk.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What algorithm does the disk use for scheduling?

A

Elevator algorithm: it chooses a direction for the disk head to move, as the disk moves, it services all the read and write requests that it encounters along the way. If the disk reaches end of disk or there are no more requests, it changes direction. This continues indefinitely.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does t he filesystem need to work?

A

Track free disk blocks. Track a mapping of file -> blocks. Track what files are in a directory. All stored on disk

17
Q

What is the minimum read/write size?

A

It’s the size of the whole block (may be 1KB to 4KB)

18
Q

How does a file descriptor reference a file?

A

It stores the i-number NOT the file name.

19
Q

Give a high level definition of what is a directory

A

It’s a file containing file_name -> file_number mappings

20
Q

How can you read the contents of a directory?

A

By using readdir system call

21
Q

How many disk accesses to resolve “/my/book/count/

A

Read file header (lookup i-node for root dir), read first data block for root, find table of file name/index pairs, search table to find “my”. Repeat until “count”.

22
Q

What happens when you use mv to move a file?

A

It only changes the name and what directory is pointing to it. The file itself never changes.

23
Q

What does FAT stand for and how does it work in essence?

A

It stands for File Allocation Table. It’s essentially a collection of files with start indexes. Blocks in a file are stored as a linked list of blocks.

24
Q

What is the purpose of doubly indirect and triply indirect pointers in an i-node?

A

These are used y files thart are very large. It makes the usage of really small files efficient but also allows the existance of very large files.

25
Q

(ext2) What data structures are required for a process to write or read from a file?

A

The first data structure is the file descriptor table, it has a pointer to an entry in the open-file-description table, containing a file position (indicating what position we are reading / writing at in the file).

26
Q

How many addresses does an i-node hold?

A

12 direct disk blocks and then 3 indirect blocks. The 3 indirect blocks is first a single indirect block, that holds addresses for other blocks, and then a doubly and triply indirect block.

27
Q

What is a journaling file system? Provide an example and why they’re useful.

A

A journaling file system is one that maintain a journal describing all file-system operations in sequential order. Eventually, all operations are committed to the appropriate disk location and corresponding journal entries are discarded. On a crash or power failure, he system detects uncommitted changes and applies them.