File Systems Flashcards

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
Q

Explain the concept of pathname translation

A

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.

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

What classes of user are available in UNIX?

A

User (owner)
Group
Public (other)

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

What modes of access are available in UNIX?

A

Read, write, execute

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

Explain groups in UNIX

A

Each user is a member of one or more groups.

1 group is considered primary and the rest are secondary

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

What is gid?

A

Group ID

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

What is the relationship between a gid and a uid?

A

There isn’t any

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

What 2 files are information about users and groups stored in?

A

/etc/passwd and /etc/group

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

Explain UNIX file security

A

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

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

What does 751 rwxr-x–x u1 g1 do?

A

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

What does 705 rwx—r-x u2 g2 do?

A

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

What types of links are there?

A

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

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

What happens when a symlink is opened?

A

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.

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

What happens when you link 2 files together?

A

Their inode number and contents will be the same

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

Are hard links allowed for directories?

A

No

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

What do open(fi) and close(fi) do?

A

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)

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

How does UNIX refer to a given input or output stream?

A

Via file descriptors (small int)

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

What is a unix program?

A

Given input or output stream by a file descriptor

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

What does the kernel use file descriptors for?

A

To index into table represent a process’ open files. This table is only visible to kernel.

43
Q

What is the current offset into a file?

A

This variable stores the distance in bytes between beginning of file and next byte to be read of written

44
Q

How can programs perform random access to a file?

A

Manipulate current offset through lseek system call

45
Q

What tables does unix kernel keep about files?

A

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
Q

What is the open file table?

A

global table containing 1 entry for each open without a close, with each entry containing current offset. Kept by kernel.

47
Q

What is the file descriptor table?

A

small per-process tables, each of which maps file descriptors of that process to open file table entries. Kept by kernel

48
Q

What is the active inode table?

A

global table containing information about every active file. Kept by kernel

49
Q

Where are the kernel tables relating to files kept?

A

System space

50
Q

Where does a read file system call occur from?

A

User space

51
Q

Where are inode list and data blocks kept?

A

Disk space

52
Q

Explain the process of reading a file?

A

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
Q

What happens to file descriptor tables when a fork occurs?

A

This is copied. Each operation by either process will advance the current offset.

54
Q

Can different processes have entries in their file descriptor tables that link to the same open file entry?

A

Yes

55
Q

What is stdin

A

Program can read what user types

56
Q

what is stdout?

A

program can send output to user’s screen

57
Q

What is stderr?

A

error output

58
Q

If a file is invoked by the shell, what file descriptors will definitely be open?

A

Stdin, stdout, stderr

59
Q

Explain disk drive in unix

A

This is divided into one or more partitions. The kernel uses each partition as a virtual disk?

60
Q

What does the kernel use a virtual disk?

A

Each partition that the disk drive is divided into

61
Q

What do disk drive partitions do?

A

Serve as a component of swap space or may hold file system

62
Q

What is a file system?

A

A tree hierarchy consisting of directories.

63
Q

What is mounting of a file system

A

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
Q

What file systems are mounted after start up?

A

Usually only removable media

65
Q

When may file systems be mounted and/or unmounted?

A

Any time when they are not used. Root file system must stay mounted when system is up

66
Q

How big must the disk partition with home directories be?

A

Big enough to store all file systems created by user

67
Q

Describe the structure of a file system

A

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
Q

What file allocation methods are available?

A
Contiguous allocation
Linked allocation
File allocation table
Indexed allocation
Multi level indexed allocation
69
Q

Explain contiguous file allocation

A

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
Q

Explain linked file allocation

A

Linked lists. Going from one block to another.

71
Q

Explain FAT

A

(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
Q

Explain indexed allocation and multilevel indexed allocation

A

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
Q

What are the 3 versions of FAT?

A

FAT 12
FAT 16
FAT 32
Differ in how many bits a disk address contains

74
Q

What is a virtual file system?

A

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
Q

How can we implement an alternative file system type?

A

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
Q

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?

A

(eg. seeking on terminal or pipe)

Procedure will return error indication

77
Q

Are we able to ‘seek’ on a terminal or pipe?

A

No, this will return error indication

78
Q

How does linux file system appear to user?

A

As a tree

79
Q

How does kernel manage file system?

A

Kernel hides implementation details and manages multiple different file systems via an abstraction layer - the VFS.

80
Q

What 2 components is linux VFS composed of?

A

1) set of definitions that define what a file object is allowed to look like
2) layer of software to manipulate file objects

81
Q

How does linux device-oriented file system access disk storage?

A

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
Q

How many classes does linux split all devices into? What are these?

A

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
Q

Explain buffer cache

A

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
Q

Explain I/O transfers in unix

A

Move data between disk and buffer cache

85
Q

What replacement strategy is generally used by buffer cache?

A

LRU (least recently used)

86
Q

Explain read-ahead

A

If recent file accesses were sequential, unix will prefetch the next block

87
Q

Explain write-behind

A

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
Q

When are blocks evicted from buffer cache?

A

Only when space is needed to cache another block

89
Q

How do write system calls work?

A

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
Q

Why would we want to use buffer cache?

A

Speak about temporal and spatial locality, quick access to files, read ahead, write behind

91
Q

What are the advantages of buffer cache?

A

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
Q

What are the disadvantages of buffer caches?

A

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
Q

What is a unix pipe?

A

IPC channel that can be accessed with read and write operations ‘file1 | file 2’. Each pipe has associated buffer

94
Q

What happens to read and write on broken pipes?

A

They fail

95
Q

What will happen with a read on an empty pipe or a write on a full pipe?

A

Suspend

96
Q

Explain Dekker’s algorithm

A

whoever setts shared/turn variable last has to wait, needs more expl

97
Q

What is a directory?

A

File maintained by the kernel

98
Q

What is a device directory?

A

Collection of nodes containing information about all files on partition. Both directory structure and files reside on disk

99
Q

What are solutions to the complexity caused by having a lot of files?

A

Break file systems into partitions

Hold info about files in partitions

100
Q

What is the access matrix/access control list?

A

Contains information are about which subjects can perform which actions on which objects

101
Q

Explain security of UNIX files

A

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
Q

What is a file descriptor?

A

Kernel uses this to index into table representing open files of process

103
Q

Name a benefit of small pipe size

A

Pipe data is rarely written to disk (kept in memory by normal block buffer cache)