Storage & File systems Flashcards
What’s better to use FD or filename?
FD versions are more secure in some sense
• Because association of FD to underlying file is immutable
– Once an FD exists, it will always point to the same file
• Whereas association between file & its name is mutable
• Using names might lead to TOCTTOU (time of check to time of use)
races
What are the 6 types of POSIX files?
– Regular file – Directory – Symbolic link (= shortcut), a.k.a. soft link – FIFO (named pipe) – Socket – Device file
What is Access control list (ACL)?
Most OSes/filesystems support some form of ACLs
– Many groups/users can be associated with a file
– Each group/user can be associated with the 3 attributes (r/w/x)
– Or more, finer attributes (“can delete”, “can rename”, etc.)
CON: not part of POSIX
Is there a difference between a filename and filepath in UNIX?
No, filename = filepath = path
Is the file and filename the same thing in UNIX?
No.
– In fact, the name is not even part of the file’s metadata
– A file can have many names, which appear in unrelated places in the
filesystem hierarchy
– Creating another name => creating another “hard link”
Can we have hard links to directories?
– Hard links to directories are usually disallowed & unsupported by the
filesystem (though POSIX does allow directory hard links)
– => Acyclic graph (no circles)
Still, all filesystems that adhere to POSIX provide at least
some support to directory hard links
– Due to the special directory names “.” and “..”
– What’s the minimum number of hard links for directory?
• 2 (due to “.”)
– What’s the maximum?
• Depends on how many subdirectories nest in it (due to “..”)
What’s the difference between a hardlink and a soft link?
Unlike hard links
– Which point to the actual underlying file object
• Symlinks (“shortcuts” in Windows terms)
– Point to a name of a “target” file (their content is typically this name)
– They’re not counted in the file’s ref count
– They can be “broken” / “dangling” (point to a nonexistent path)
– They can refer to a directory (unlike hard links in most cases)
– They can refer to files outside of the filesystem / mount point
(whereas hard links must point to files within the same filesystem)
What does the unlink function removes?
Will remove the symlink, not the target file
What’s the inode?
The OS data structure that represents the file
nternally, file names “point” to inodes
• This inode is determined via the path-resolution algorithm
The inode contains all the metadata of the file
What’s a directory file?
A simple flat file comprised of directory entries (dirents).
Where is the name of the file stored?
In the directory file, not the inode.
Do symlinks have there own inode?
POSIX doesn’t specify whether a symlink should have an
inode.
But filesystems often define an inode per symlink, it then points to the files “real” inode, or if the name is to long then to a data block where a pointer to the “real” inode lays.
What is the lower bound for the time complexity of Path resolution process?
n. Because finding each individual directory component
along the path may also be a linear process
What’s the block/sector size in VSFS?
4kB.
What is the layout of VSFS?
0 block = superblock 1 block = inode bitmap 2 block = data blocks bitmap blocks 3 - 7 = Inode table blocks 8 - 63 = Data blocks