File Systems Flashcards

(103 cards)

1
Q

What is the purpose of a file system?

A

Reliable long-term storage of significant quantities of data

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

How is the file system typically implemented?

A

Using disks

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

Are tapes suitable for general purpose file systems? Why/why not?

A

No, as they are too slow

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

Is main memory suitable for general purpose file systems? Why/why not?

A

No, as it is volatile and too small; however, main memory can be used for temp files (/tmp on unix)

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

What constitutes a file?

A

A named sequence or collection of bytes stored on disk.
This abstract data type has the following operations defined for it:
1) create
2) write
3) read
4) reposition within file
5) delete
6) truncate
7) open(fi): search directory structure on disk for entry fi and move contents of it to memory
8) close(fi): move content of entry fi to directory on disk (from memory)

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

What operations are available on files?

A

1) create
2) write
3) read
4) reposition within file
5) delete
6) truncate
7) open(fi): search directory structure on disk for entry fi and move contents of it to memory
8) close(fi): move content of entry fi to directory on disk (from memory)

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

How are files named and protected?

A

Usually named with an extension, separated by a dot (.)

Each have unique identifier (inode)

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

How is free space managed? What advantages/disadvantages are there? Which method do most modern OSs use?

A

Free lists: list of free disk blocks pointing to next.
Disadvantage: free block must be read before it can be allocated

or

Bitmaps: 1 bit per block, 1 if free, 0 otherwise. These have the advantage of being able to search for free block within certain neighbourhood. Most modern OS use bitmaps for this reason.

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

How can kernel ensure fast access to files?

A

Buffer cache

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

How can file system recover from crashes?

A

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

Why is a file a logical storage unit?

A

Because the fact it is made up of a “bunch of blocks” stored on device (from OS standpoint) means that it is a good abstraction

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

How does UNIX view files?

A

As a sequence of bytes. Any structure on top of this is strictly for user programs.

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

What are some UNIX file types?

A

eg. executable, archive

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

What are the attributes of a file?

A

1) Name: only info kept in human readable form
2) Identifier: unique tag to identify file in file system
3) Type: needed for systems that support different types
4) Location: pointer to file location on device
5) Size: current file size
6) Protection: controls who can do reading, writing, executing
7) Time, date and user identification: data for protection, security and usage monitoring

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

Where is information about files kept?

A

Directory structure, which is maintained on disk

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

What does the file extension do?

A

Indicates ‘purpose’ of the file

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

What was early directory structure like?

A

Fixed structure consisting of home directory and variable number of subdirectories - one for each project user is involved in

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

What is directory structure like now?

A

Subdirectories may have subdirectories - these form a tree structure. Uses . for self directory and .. for parent directory

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

What is an inode?

A

(information node) contains all information kernel has about a file EXCEPT its name

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

What do . and .. refer to at the root?

A

These refer to the same inode as each other

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

Do files have to have extensions in UNIX?

A

No

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

What is a UNIX filename?

A

Sequence of names separated by slashes (/). Kernel translates this to inode number by looking up each component in sequence

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

How does kernel translate UNIX filename into an inode number?

A

Looks up each component in the sequence. If file name begins with slash, start searching in root directory. Otherwise start at inode of current directory of the process

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

If a filename begins with a slash, where will the kernel start search for it? If not?

A

If file name begins with slash, start searching in root directory. Otherwise start at inode of current directory of the process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Explain the concept of pathname translation
The kernel takes a UNIX filename and translates it into an inode number by looking up each component in the sequence. Kernel caches results of pathname translations for later reuse.
26
What classes of user are available in UNIX?
User (owner) Group Public (other)
27
What modes of access are available in UNIX?
Read, write, execute
28
Explain groups in UNIX
Each user is a member of one or more groups. | 1 group is considered primary and the rest are secondary
29
What is gid?
Group ID
30
What is the relationship between a gid and a uid?
There isn't any
31
What 2 files are information about users and groups stored in?
/etc/passwd and /etc/group
32
Explain UNIX file security
Unix files are protected by ACL of restricted form with three entries: 1) first applies to owner of file 2) second applies to members of the group associated with the file 3) third applies to everyone else
33
What does 751 rwxr-x--x u1 g1 do?
...
34
What does 705 rwx---r-x u2 g2 do?
...
35
What types of links are there?
Hard links: Points to file by inode number. Finding other files with the same name means having to compare inode numbers of files as this is the identifier. Symlinks: points to file by name (file doesn't have to exist).
36
What happens when a symlink is opened?
Symbolic links are those files that contain a file name. | The kernel sees the symbolic link in the inode and opens the named file instead. This named file may be a symlink.
37
What happens when you link 2 files together?
Their inode number and contents will be the same
38
Are hard links allowed for directories?
No
39
What do open(fi) and close(fi) do?
open(fi): search directory structure on disk for entry fi and move contents of it to memory close(fi): move content of entry fi to directory on disk (from memory)
40
How does UNIX refer to a given input or output stream?
Via file descriptors (small int)
41
What is a unix program?
Given input or output stream by a file descriptor
42
What does the kernel use file descriptors for?
To index into table represent a process' open files. This table is only visible to kernel.
43
What is the current offset into a file?
This variable stores the distance in bytes between beginning of file and next byte to be read of written
44
How can programs perform random access to a file?
Manipulate current offset through lseek system call
45
What tables does unix kernel keep about files?
1) open file table: global table containing 1 entry for each open without a close, with each entry containing current offset 2) file descriptor tables: small per-process tables, each of which maps file descriptors of that process to open file table entries 3) active inode table: global table containing information about every active file
46
What is the open file table?
global table containing 1 entry for each open without a close, with each entry containing current offset. Kept by kernel.
47
What is the file descriptor table?
small per-process tables, each of which maps file descriptors of that process to open file table entries. Kept by kernel
48
What is the active inode table?
global table containing information about every active file. Kept by kernel
49
Where are the kernel tables relating to files kept?
System space
50
Where does a read file system call occur from?
User space
51
Where are inode list and data blocks kept?
Disk space
52
Explain the process of reading a file?
The read call is made from user space. This traps into system space in order to access the file tables. The file descriptor links to open file table which links to inode table. . The inode table maps to appropriate data in disk space.
53
What happens to file descriptor tables when a fork occurs?
This is copied. Each operation by either process will advance the current offset.
54
Can different processes have entries in their file descriptor tables that link to the same open file entry?
Yes
55
What is stdin
Program can read what user types
56
what is stdout?
program can send output to user's screen
57
What is stderr?
error output
58
If a file is invoked by the shell, what file descriptors will definitely be open?
Stdin, stdout, stderr
59
Explain disk drive in unix
This is divided into one or more partitions. The kernel uses each partition as a virtual disk?
60
What does the kernel use a virtual disk?
Each partition that the disk drive is divided into
61
What do disk drive partitions do?
Serve as a component of swap space or may hold file system
62
What is a file system?
A tree hierarchy consisting of directories.
63
What is mounting of a file system
We can attach file systems by mounting them to other directories. The mount point should be an empty directory as the mounting operation will overwrite the sub tree of this mount point directory
64
What file systems are mounted after start up?
Usually only removable media
65
When may file systems be mounted and/or unmounted?
Any time when they are not used. Root file system must stay mounted when system is up
66
How big must the disk partition with home directories be?
Big enough to store all file systems created by user
67
Describe the structure of a file system
the boot block (block 0): contains code to bootstrap the system (to get system up and running) the super block (block 1): contains summary information for the file system (where to find everything else). master file table blocks for a fixed number of inodes (points off to data) blocks for file data. heap of index values (each block contains a fixed number of disk sectors)
68
What file allocation methods are available?
``` Contiguous allocation Linked allocation File allocation table Indexed allocation Multi level indexed allocation ```
69
Explain contiguous file allocation
Everything next to each other in array with start position and size. This will have a lot of fragmentation when files are deleted and empty spaces appear
70
Explain linked file allocation
Linked lists. Going from one block to another.
71
Explain FAT
(file allocation table) similar to linked list allocation but linked list is stored in a table called the DFAT which speeds up direct access. The FAT can be cached. Smarter approach to linked list allocation. Array of table of pointers. Each file maintains only linked list of where data blocks are, with pointer pointing to start of file
72
Explain indexed allocation and multilevel indexed allocation
This is similar to a page table. It has indexes to table which tell us location of files. Multilevel: inode consists of pointers to index blocks. The inode points to a second level index block. Each second level index block points to a data block. High levels of indirection are possible
73
What are the 3 versions of FAT?
FAT 12 FAT 16 FAT 32 Differ in how many bits a disk address contains
74
What is a virtual file system?
2d table mapping system calls (one of the dimensions) and file system types (other dimension) into a pointer to a procedure that implements appropriate variant of system call for files on that type of file system
75
How can we implement an alternative file system type?
VFS. Virtual file system switch. 2d table mapping system calls (one of the dimensions) and file system types (other dimension) into a pointer to a procedure that implements appropriate variant of system call for files on that type of file system
76
In the case of a VFS, what happens if the system call does not apply to that file system type? What is an example of when this might occur?
(eg. seeking on terminal or pipe) | Procedure will return error indication
77
Are we able to 'seek' on a terminal or pipe?
No, this will return error indication
78
How does linux file system appear to user?
As a tree
79
How does kernel manage file system?
Kernel hides implementation details and manages multiple different file systems via an abstraction layer - the VFS.
80
What 2 components is linux VFS composed of?
1) set of definitions that define what a file object is allowed to look like 2) layer of software to manipulate file objects
81
How does linux device-oriented file system access disk storage?
Through 2 caches: 1) data is cached in page cache, which is unified with virtual memory system 2) metadata is cached in buffer cache, a separate cache indexed by physical disk block
82
How many classes does linux split all devices into? What are these?
3. 1) block devices allow random access to completely independent, fixed size blocks of data 2) character devices include most other devices and don't need to support functionality of regular files 3) network devices are interfaced via the kernel's networking subsystem
83
Explain buffer cache
Disk block that was accessed recently is likely to be accessed in nearby future. Unix caches disk blocks in main memory for easy access.
84
Explain I/O transfers in unix
Move data between disk and buffer cache
85
What replacement strategy is generally used by buffer cache?
LRU (least recently used)
86
Explain read-ahead
If recent file accesses were sequential, unix will prefetch the next block
87
Explain write-behind
Copy data from user address space to buffer cache. Affected blocks are marked 'delayed write'. Daemon process that wakes up every 30s schedules these blocks to be written to disk. Mark is deleted when write is completed. This is write behind.
88
When are blocks evicted from buffer cache?
Only when space is needed to cache another block
89
How do write system calls work?
Copy data from user address space to buffer cache. Affected blocks are marked 'delayed write'. Daemon process that wakes up every 30s schedules these blocks to be written to disk. Mark is deleted when write is completed.
90
Why would we want to use buffer cache?
Speak about temporal and spatial locality, quick access to files, read ahead, write behind
91
What are the advantages of buffer cache?
Reduce number of disk reads required if references show locality No need to require read/write requests to be aligned Files with short lifetimes usually require no disk access If file is updated several times in short period, only the final version needs to be written to disk Scheduling more blocks at same time gives more scope for disk scheduler No need to lock user pages in memory during I/O transfers
92
What are the disadvantages of buffer caches?
Disk accesses require extra pass over data (eg. disk to buffer cache, then buffer cache to memory instead of disk to memory) Delayed writes may be lost in a crash
93
What is a unix pipe?
IPC channel that can be accessed with read and write operations 'file1 | file 2'. Each pipe has associated buffer
94
What happens to read and write on broken pipes?
They fail
95
What will happen with a read on an empty pipe or a write on a full pipe?
Suspend
96
Explain Dekker's algorithm
whoever setts shared/turn variable last has to wait, needs more expl
97
What is a directory?
File maintained by the kernel
98
What is a device directory?
Collection of nodes containing information about all files on partition. Both directory structure and files reside on disk
99
What are solutions to the complexity caused by having a lot of files?
Break file systems into partitions | Hold info about files in partitions
100
What is the access matrix/access control list?
Contains information are about which subjects can perform which actions on which objects
101
Explain security of UNIX files
Protected by an ACL of restricted form with 3 entries: 1) owner of file 2) members of group associated with file 3) everyone else The ACL is represented at a nine bit - usually octal number
102
What is a file descriptor?
Kernel uses this to index into table representing open files of process
103
Name a benefit of small pipe size
Pipe data is rarely written to disk (kept in memory by normal block buffer cache)