File System Interface (13) Flashcards
File characteristics
- Contiguos inside the logical addr. space
- Type:
- Data:
- Numeric
- Character
- Binary
- Program
- Data:
- Contents are defined by creator
- Many different types available
File attributues
The informations about the file are stored/kept in the directory structure.
- Name: human readable
- Identifier: unique tag to identify the file inside fs
- type: needed for the system to identify the program with which to open the file
- location: pointer to location on device
- Size
- Protection: permissions
- Time, date and user id
- used for permissions, security and for computing statistics.
File Operations/Primitives
Here we mean file as ADT, not the physical object made of electrons.
- Create
- Write: at the address specified by the pointer
- Read: at the address specified by the pointer
- Reposition: seek
- Delete
- Truncate
- Open(Fi): search che cwd for the file Fi and move the content to memory
- Close(Fi): move content loaded in memory to disk
Managing Open Files
Structures needed:
- Open-file table
- File pointer: pointer to last address of memory written to file
- File-open count: how many processes have this file opened?
- Removed open-file table entry when count = 0
- Disk location of file:
- Access rights: changes based on process request and the protection attribute of the file
Open file locking
Lock types:
- Shared lock
- Exclusive lock
Can be mandatory or advisory:
- Mandatory: system enforces rules
- Advisory: system advertises rules but doesn’t inforce them, process decide what to do if they see a lock
Kinds of file structures
- None: flat
- SImple record structure
- Lines
- Fixed len
- variable len
- Complex structure
- Formatted document
- Relocatable document
Systems can simulate last two using the first method and control characters.
Decision makers:
- OS
- Program
Access methods
Files store information used to access their content.
Methods:
- Sequential
- Primitives:
- read next
- write next
- reset (go to beginning)
- Impossible to read
- Works well on sequential access devices as well as random access ones.
Simulation on random access device:- reset: cp = 0;
- read next: read cp; cp++;
- write next: write cp; cp++;
- Primitives:
- Direct
- File contains X fixed length records that allow programs to jump between the file in constant time.
- Primitives (n = relative block n.)
- read (n)
- write (n)
- position to (n)
- rewrite (n)
Derived access methods
- Other access methods can be built upon direct-access methods
- usually this involves making and index for the file to keep in memory for fast access
- Options for large files: index of index stored on secondary memory
- IBM indexed sequential access method
- Small master index, points to disk blocks of secondary index
- All done by OS
- File kept sorted
Directory structure
- Collection of nodes containing info about all files and their structure
- Both residing on disk
Disk structure
- Disk can be organized in partitions
- Partitions AKA minidisks, slices
- Partitions and disks can be protected through RAID
- Disk and parititions can be used without file system or without being formatted: RAW
- Volume: entity containing fs
- Each volume tracks fs statistics and properties inside either:
- device directory
- volume table of contents
- There exist special purpose fs, many fs can coexist on the same machine
Operations on Directory
- Search file
- Create file
- Delete file
- List a directory
- Rename file
- Traverse file system
Directory organization
Objectives:
- Efficient file search
- Convenient file naming
- Grouping capabilities: by different attributes.
Types:
- One level
- One dir for each user
- Problems:
- Naming
- Grouping
- Two level
- Separate dir for each user
- Efficient searching
- Can have same file name for different users
- No grouping
- Tree structured
- Efficient searching
- Grouping capability
Acyclic graph directories
- Have shared subdirs and files
- Dangling pointer:
- Happens if dict deletes list
- Solutions:
- Backpointers
- Backpointers using daisy chain
- Entry-hold-count
- New directory entry type:
- Link: another name pointer to an existing file
- Resolve the link follow pointer to locate the file
General graph directory
How do we guarantee no cycles?
- Allow only links to file not subdirectories
- Garbage collection
- Use cycle detection everytime a new link is created
Mounting and Mount point
OS is given the name of the device and the mount point.
Typically a mount point is an empty directory.
OS verifies that device has valid file system, by asking the device driver to read the directory and verysing that it has the expected format.
Finally the OS notes in its directory that a file system is mounted at the specified mount point.