20. Files Flashcards
What does a file have to do to be useful?
Reliably store data and be locatable (usually via a name)
What are the two minimum expectations we hold for basic files?
- File contents should not change unexpectedly
2. File contents should change when requested and change as requested
What are a few causes of data loss/corruption?
Power outages and sudden ejects of devices.
These make file system design difficult and expose tradeoffs between durability and performance.
What are the fundamental performance differences between memory and disk storage?
Memory is fast, but transient.
Disk is stable, but slow.
What metadata might we want to know about a file?
When the last file was created, last accessed, or last modified.
Who is allowed to read/write/rename/etc a file
Where should metadata (attributes) for an audio file be stored?
Three options:
- In the file itself
- In another file
- In attributes associated with the file and maintained by the file system
What are the pros and cons of storing file metadata in the file itself?
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
What are the pros and cons of storing file metadata in another file?
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)
What are the pros and cons of storing file metadata in attributes?
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
What are attributes?
???
What do most file systems provide to the process and a file?
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”
Why does the file system want to establish process-file relationships?
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 do UNIX semantics simplify reads and writes to files?
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.
Describe the 5 major components of the UNIX file interface.
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