File Systems Flashcards
what is a file?
a variable length sequence of bytes
what attributes do files have? (7)
- name
- identifier
- type
- location
- size
- protection
- creation/modification time, date and user id
name 6 file operations
- creation/opening
- reading
- writing
- repositioning
- deletion
- truncation
what is an open file table? what are two types?
- the open() system call will return a pointer to an entry in the open file table
- this acts as an identifier for the open tile
- used as a parameter to all subsequent file operation
system-wide file table:
- all currently open files
- a count of how many processes have the file open
- contains copies of FCBs of all open files
per-process open file table:
- files that a process currently has open
- entries point to a systemwide entry
- current file pointer values for the process
- the access mode
remember that file locking is the same as database locking
shared locks and exclusive locks
what is a file extension and what’s the point?
infers a file’s use. a file ending in .pdf should be opened in a reader
difference between sequential and direct access?
sequential - a linked list. have to read or write from the current position in the file and advance the pointer
direct access - an array. allows random access. supported by disks
what is partitioning?
splitting a device into multiple storage volumes
describe the acyclic structure
- there can be multiple names/paths for the same file or directory
- space allocated to a file can be reclaimed only when the last reference is deleted, by maintaining a reference count. incremented when a reference is added
- need to prevent cycles. in Linux symbolic linking to an already existing directory is forbidden
what is a file control block (FCB)?
fcb contains information for individual files. these are inodes in unix
what is a VFS?
a virtual file system allows unix to support the use of multiple different file systems
the same system call interface can be used for different types of file system
the os provides a single API and so an os can use different file systems for different disks or on the network
local files are distinguished from remote ones
describe contiguous allocation
- files are on the disk contiguously
- there is no additional head movement, no seeking
- move one track when switching cylinders
- can be direct access, access i starting from b saying b
problems:
- allocating dynamic space
- when files expand they may run up against other files, and have to be copied to larger spaces
- external fragmentation issues
describe the read operation steps
- read is called at index i
- the process is found in the per-process open file table at i
- that entry points to the system wide file table
- the inode in the system wide table points to the data block
described linked allocation, pros and cons
- files in the style of a linked list (not really a linked list)
- can have variable file sizes
- no fragmentation
cons: - not resistant to data loss
- only sequential access, direct access is impossible
- head movement may be great, because the blocks aren’t contiguous
- requires overhead for pointers
describe a FAT
file allocation table
a variantion on linked allocation
- section of the disk holds the FAT
- – one entry per disk block
- – indexed by block number
- used like a linked list
- directory contains block number of first block of file
- like a linked list of list heads
describe indexed allocation
- index blocks are allocated on file creation
- contain a list of file locations
- a hybrid, because we can sequentially access but also direct access by calculating the index
- can have internal fragmentation because there is unused space in the index block
- expansion is easy, we just find a free block and update the index block. if the index block is full we can extend it
- can have multi-level indexes to expand maximum file size
describe the unix inode system
inodes are stored in a ssytem inode table and addressed by their index
uses a combination of standard indexing and multi-level indexing
- the first 15 pointers of index block stored in the file’s inode
- first 12 of those point to direct blocks, small files that dont require multi-level
- the other 3 are indirect
- 1 single, 1 double, 1 triple
must by acyclic so no links to already existing directories
what is a hard link?
more than one directory entry may exist for a single inode
this is known as linking or hard links
what is a soft/symbolic link?
a file containing the path to the link target
a shortcut
what can cause inconsistencies when writing? how to we combat this?
write back is delayed and cached for performance. if the system crashes there may be consistency problems.
use this algorithm:
- create a table with one record per disk block
- records have two count fields
- – how many times the block is in a file
- – how many times the block is in the free list
- scan is made all inodes and the free list
- the system is consistent if there is a 1 in exactly one of the fields for each block
- – a block with two 0s is added to the free list
- – a block with two 1s is removed from the free list
- a block with a use count greater than one is copied
what is journaling?
- a log is created of what happened, stores meta-data
- operations are atomic
- transactions written to the log are committed when the system call returns
- log entries are replayed across the actual file system structures
- completed transactions are removed from the log
- after a crash, the journal is replayed
- undo changes made by partially executed transactions
overheads:
- write the meta-data twice