C191-Terms-Chapter-10 Flashcards
file system (FS)
an integral part of every OS, whose function is to implement the concept of files.
file
a named collection of information managed on secondary storage by the FS. The user can view a file as a single abstract unit of data storage and access the file’s contents using high-level operations provided by the FS’s interface, without knowing the specific characteristics of the underlying storage devices. Depending on the FS, a file can be viewed as an unstructured stream of bytes or a series of records.
record
a structure of related data items, possibly of different data types, identified within a file by a record number or a unique key field. Ex: A student ID would uniquely distinguish all student records in a file.
access method
a set of operations provided by the OS as part of the user interface to access files. The most common access method is sequential.
The FS maintains the current position within the file and each read/write operation accesses the next n bytes or the next record of the file. Some OSs (Ex: most IBM systems) support also direct access methods, where a record can be accessed directly by specifying a record number or a key value.
Metadata
information about the format and organization of a file’s data and is generally stored in a file header
file header
a portion of the file preceding the actual data and is visible to only the FS itself.
magic number
a short sequence of characters at the start of the file header, which identifies the file type. The file type, in turn, determines which programs are allowed to access and interpret the file. Ex: The OS will allow only properly compiled and linked binary files to be loaded into memory for execution.
file extension
Another way to represent file types is to use file extensions. A file extension is a sequence of one or more characters following the file name.
A file extension, unlike a magic number, is not hidden within the file header and thus can conveniently be examined by the user. The drawback is that a file extension can easily be changed without changing the file’s type.
Thus file extensions support only a weak form of file typing by providing convenient hints about a file’s type but do not rigorously enforce which operations are valid for a given file type.
file directory (or folder)
a special-purpose file that records information about other files and possibly other directories. The directory consists of a set of entries, each containing the name of a file followed by other information necessary to access the file.
tree-structured directory hierarchy
An approach to organizing the individual file directories into a global directory structure.
A tree-structured directory hierarchy is a collection of directories organized such that (1) every directory points to zero or more files or directories at the next lower level, and (2) every file and directory except the root is pointed to by exactly one parent directory at the next higher level.
The root of a tree-structured directory hierarchy is the highest level directory, which does not have a parent directory.
Every file and every directory has a unique ID, assigned by the FS at the time of creation. This ID is used only by the FS for internal management purposes and is not visible to the users.
Instead, users assign arbitrary ASCII names to files and directories, which become part of path names.
absolute path name
An absolute path name of a file, uniquely identified by an internal ID, f, is the concatenation of the directory and file names leading from the root to the file f. The individual names are separated by an agreed-upon delimiter, typically a forward slash or a backslash.
To avoid using long path names, the FS allows the user to designate one directory as the current working directory.
relative path name
a concatenation of file names starting with the current directory.
To be able to navigate the hierarchy both up and down, the FS provides a special convention, generally “..”, to refer to a parent directory.
Operations on directories
The FS provides a set of operations to allow the user to manipulate and use the directory hierarchy. The operations include:
Change: change the current working directory to another directory specified by a path name.
Create: create a new named directory and a new entry in the current working directory, which points to the new directory.
Delete: delete directory d specified by a path name. Delete also all files and directories reachable using any path name starting from d.
Move: move a file or directory from one directory to another.
Rename: change the name of a file or directory specified by a path name.
List: list the file names and optionally other attributes of all files contained in a directory specified by a path name.
Find: find a file or directory specified by a name.
Main drawback of a tree-structured directory hierarchy
is that file sharing is asymmetric. Only one directory can be the parent of any file or another directory. Other users must refer to the file by first navigating up to a common directory and then down to the desired location.
directed acyclic directory hierarchy
organizes directories such that any directory at a given level may point to zero or more files or other directories at lower levels but also permits any file or directory to have more than one parent directory.
To permit the creation of multiple parents, the FS provides an additional operation of the form “link path1 path2”, which creates a new link from the directory identified by the path name path1 to the directory or file identified by path2.
Since any file, including any directory, can now be pointed to by more than one directory, the semantics of file deletion must be extended.
reference count
a non-negative integer associated with a file f, which indicates how many directories are pointing to the file. The file is deleted only when the reference count is 1, indicating that f has only a single parent directory.
Otherwise only the pointer to f is deleted from the parent directory and the reference count of f is decremented.
A general graph structure with symbolic links
If a directory is allowed to point to a file or another directory at a higher level, then a cycle can form in the hierarchy.
A cycle, if undetected, can lead to an infinite loop in algorithms that search the hierarchy for a given file. File deletion also becomes more difficult.
A reference count is not sufficient to prevent the creation of unreachable subgraphs in the directory hierarchy, which can only be removed using a garbage collection algorithm.
A compromise solution is to allow only a single parent directory for any file or directory but to provide symbolic links to support file sharing.
A symbolic link (or shortcut) is a directory entry that points to a file or directory just like a regular entry but is treated differently with respect to deletion. A delete operation only removes the link but not the file itself.
symbolic link (or shortcut)
a directory entry that points to a file or directory just like a regular entry but is treated differently with respect to deletion. A delete operation only removes the link but not the file itself.
Contents of file directories
The typical file attributes include:
Size: The current size in bytes or words.
Type: Information to differentiate directories, regular files, executable files, and other types of files supported by the system.
Location: Information necessary to locate the file’s physical blocks on disk.
Protection: Information about who can access the file and the permitted type of access (Ex: read only or execute only).
Use: The date and time of file creation, last access, or last modification.
Where to keep file attributes?
One approach is to keep all attributes together with the file name inside each file directory.
The main drawback is that file directories can become very long, which slows down the search.
Another approach is to keep only the file name inside the directory and provide a pointer to a separate data structure to store the file attributes.
File control block (FCB)
a data structure associated with a filename that contains all relevant attributes of the file. FCBs are stored apart from file directories and are pointed to by the corresponding directory entries. In Unix and other OSs an FCB is called an i-node.
Internal structure of file directories
The FS must be able to efficiently (1) search directories for a file name, (2) find and allocate an entry when a new file is created, (3) free an entry when a file is deleted, and (4) change the file name, which may shorten or lengthen the name length. Several approaches exist to organizing directory entries.