File Systems Flashcards
What is the purpose of a file system?
Reliable long-term storage of significant quantities of data
How is the file system typically implemented?
Using disks
Are tapes suitable for general purpose file systems? Why/why not?
No, as they are too slow
Is main memory suitable for general purpose file systems? Why/why not?
No, as it is volatile and too small; however, main memory can be used for temp files (/tmp on unix)
What constitutes a file?
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)
What operations are available on files?
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 are files named and protected?
Usually named with an extension, separated by a dot (.)
Each have unique identifier (inode)
How is free space managed? What advantages/disadvantages are there? Which method do most modern OSs use?
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 can kernel ensure fast access to files?
Buffer cache
How can file system recover from crashes?
…
Why is a file a logical storage unit?
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 does UNIX view files?
As a sequence of bytes. Any structure on top of this is strictly for user programs.
What are some UNIX file types?
eg. executable, archive
What are the attributes of a file?
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
Where is information about files kept?
Directory structure, which is maintained on disk
What does the file extension do?
Indicates ‘purpose’ of the file
What was early directory structure like?
Fixed structure consisting of home directory and variable number of subdirectories - one for each project user is involved in
What is directory structure like now?
Subdirectories may have subdirectories - these form a tree structure. Uses . for self directory and .. for parent directory
What is an inode?
(information node) contains all information kernel has about a file EXCEPT its name
What do . and .. refer to at the root?
These refer to the same inode as each other
Do files have to have extensions in UNIX?
No
What is a UNIX filename?
Sequence of names separated by slashes (/). Kernel translates this to inode number by looking up each component in sequence
How does kernel translate UNIX filename into an inode number?
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
If a filename begins with a slash, where will the kernel start search for it? If not?
If file name begins with slash, start searching in root directory. Otherwise start at inode of current directory of the process
Explain the concept of pathname translation
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.
What classes of user are available in UNIX?
User (owner)
Group
Public (other)
What modes of access are available in UNIX?
Read, write, execute
Explain groups in UNIX
Each user is a member of one or more groups.
1 group is considered primary and the rest are secondary
What is gid?
Group ID
What is the relationship between a gid and a uid?
There isn’t any
What 2 files are information about users and groups stored in?
/etc/passwd and /etc/group
Explain UNIX file security
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
What does 751 rwxr-x–x u1 g1 do?
…
What does 705 rwx—r-x u2 g2 do?
…
What types of links are there?
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).
What happens when a symlink is opened?
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.
What happens when you link 2 files together?
Their inode number and contents will be the same
Are hard links allowed for directories?
No
What do open(fi) and close(fi) do?
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 does UNIX refer to a given input or output stream?
Via file descriptors (small int)
What is a unix program?
Given input or output stream by a file descriptor