20. Files Flashcards

1
Q

What does a file have to do to be useful?

A

Reliably store data and be locatable (usually via a name)

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

What are the two minimum expectations we hold for basic files?

A
  1. File contents should not change unexpectedly

2. File contents should change when requested and change as requested

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

What are a few causes of data loss/corruption?

A

Power outages and sudden ejects of devices.

These make file system design difficult and expose tradeoffs between durability and performance.

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

What are the fundamental performance differences between memory and disk storage?

A

Memory is fast, but transient.

Disk is stable, but slow.

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

What metadata might we want to know about a file?

A

When the last file was created, last accessed, or last modified.

Who is allowed to read/write/rename/etc a file

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

Where should metadata (attributes) for an audio file be stored?

A

Three options:

  1. In the file itself
  2. In another file
  3. In attributes associated with the file and maintained by the file system
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the pros and cons of storing file metadata in the file itself?

A

Example: MPS ID3 tags are stored in a data container within an MP3 file in a prescribed format.

Pros: It travels along with the file from computer to computer, so it is always available

Cons: It requires all programs that access the file to understand the format of the embedded metadata

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

What are the pros and cons of storing file metadata in another file?

A

Example: iTunes database

Pros: The metadata file can be maintained separately by each application

Cons: It does not move with the file and the separate file must be kept in sync when the file it stores information about changes (location, contents, name, etc)

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

What are the pros and cons of storing file metadata in attributes?

A

Example: Attributes have been supported by a variety of file systems, including prominently by BFS, the BeOS file system.

Pros: Attributes are maintained by the file system, so they can be queried and queried quickly

Cons: Attributes do not move with the file, and creates compatibility problems with other file systems

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

What are attributes?

A

???

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

What do most file systems provide to the process and a file?

A

An interface for establishing a relationship between the process and a file.

Example interface:
“I (the process) have the file open. I am using this file.”

“I am finished using the file and will close it now”

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

Why does the file system want to establish process-file relationships?

A

It can improve performance if the OS knows what files are actively being used (by using caching or read-ahead functions)

The file system may provide guarantees to processes based on this relationship, such as exclusive access

Note: Some file systems, particularly networked file systems, don’t even bother to establish these relationships. One reason why is the consequences of a networked client opening a file exclusively, but then dying unexpectedly.

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

How do UNIX semantics simplify reads and writes to files?

A

UNIX semantics store the file position for processes, making reads and writes simpler.

Note: This is a convenience, not a requirement. Processes could be required to provide a position with every read and write.

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

Describe the 5 major components of the UNIX file interface.

A

open(“foo”): “I’d like to use the file named foo”

close(“foo”): “I’m finished with foo”

Those two are used to establish and end relationships.

read(2): “I’d like to perform a read from file handle 2 at the current position”

write(2): “I’d like to perform a write from file handle 2 at the current position”

lseek(2, 100): “Please move my saved position for file handle 2 to position 100

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