Operating System Concepts (XII) - file system interface

This chapter speaks quickly, I am here to not be able to get the whole, I hope you can supplement

First, the concept of file

1, the operating system provides a uniform logical interface information storage
2, the file name is a set of records having information on the external memory
3, the operating system for abstracting various attributes of the storage device and defines the logical unit (file) and then mapped onto the physical device file.
4. In general, the file indicates that the program and data

(A), file attributes

1, Name: OS some case-sensitive (e.g., Linux, Unix), some are not distinguished (e.g., the DOS, the Windows)
2, Type: defined by the OS and a program
3, location: file location pointing device and a pointer device
4, the size of the : the current file size (in bytes, words, or blocks to represent)
5, protection: decide who read, write, execute access control information such as
6, the time, date and user identification: the file is created, last modified and last You may have access to that information. For the protection, safety and use of track
7, the information file is stored in the directory structure, and directory structure stored on external memory, all the contents of the file system are stored on external memory

(Two), file operations

1, create a file
① to find the file in the file system space
② create a new entry for the file in the directory
2, write files
3, read the file, the current general operating position each process can be used as the current file position pointer
4, in the file relocation
5, truncates the file: delete only the contents of the file while retaining its properties, rather than forcing the user to delete the file again to create the file.
6, delete the file: After searching for files in a given directory name, find the relevant directory entry, file space for the release of all other files, and delete the corresponding directory entry.
7, open the file needs the following information:
① file pointer: The system must track the location of the last read and write operations as the current file pointer position
② file open counter: tracking number of files opened and closed, at the end of closing time counter is zero, at this time, the system may delete the entry
③ disk file location: means for positioning the disk file location information stored in memory for each operation to avoid read information from the disk
④ access: each process opens a file access mode, table stored in the file open in a single process, so the operating system can allow or deny subsequent I / O request

(Three), file type

1, if the OS to identify the file type, then it will be able to file a reasonable way to operate.
2, file types commonly used technology is included in the file name type, such as: name and extension
3, there is a file creator property that contains the name of the program that created it. When the file's icon to open the file the user double representation, it will automatically call the appropriate program.
4, unix system uses magic number to indicate file types: executable, batch file (shell script), postscript files. But not all files have the magic number.

(Iv), the file structure

1, each application must have its own code input file appropriate explanation. But all the OS must support at least one structure, you can perform file structure, in order to be able to load and run the program.
2, by inserting an appropriate representation control characters in the first method to simulate two representations
3, the structure of the file is determined by the following two:
①OS
② Program

Second, access methods

1, a sequential access: The easiest way to access file information sequentially, followed by a record a record to be processed, the editor and compiler often use this access to the file, is called the tape models . Read operation to read the next file location, and automatically advances the file pointer, the write operation will increase as the tail of the file contents, the file pointer to the corresponding data is added after
2, Direct Access: file logical records of fixed length by a composition, in allow rapid reading and writing of the program in any order, is called disk model , the file can be used as a sequence number or a block of records, typically using this database. The operating system provides the user wants to block number is generally the relative block numbers , with respect to the beginning of the index file.
3, other access methods: usually based on direct access manner, usually involves creating a file index , each block contains pointers. To find records in the file, the first search index, and then directly access the file according to the pointer.

Third, the directory structure

1, the entire disk can be used as a file system, but it is sometimes necessary or sheet into a plurality of regions, referred to as mini-disc. A large storage space to store the file system can be used as a volume , the volume can store multiple operating systems, the system is up and running multiple operating systems.
2, each volume containing the file system must also contain information on the file system, the directory stored in the device (referred to as a directory) or volume table.
3, the directory that contains all the nodes file information collection
4, device directory contains information: name, type, address, current length, maximum length, Last Visit, Last updated, user identification number, to protect information
5, the directory can seen as a symbol table, he can convert the file name of the directory entry, there are related operations:
① search for files: the ability to search for specific entries in the directory structure to find files
② create a file: You can create new files added to the directory and
③ delete files
④ traversal entry: can traverse all of the files and the contents of its directory entry for each file in the directory
⑤ trace file system: every file access each directory and each directory

(A), a single layer structure directory

1, all files are contained in the consent directory, easy to support and understanding, but there is a problem with the group name issue
2, each file must have a unique name can not be duplicated
3, when too many entries in the file, it is difficult to remember the names of all files

(B), two-layer structure directory

1, to establish for different users different directories:
① file allows different users of the same name
② does not support grouping
③ easy to find
2, each user has their own user file directory UFD, each UFD have a similar structure, but only lists a single file of the user. When a user job or started a registered user, search the master file system directory MFD, find the location of a user name, and then directed to the user's UFD to locate the user's files

(C), the directory tree

1, allow users to create their own subdirectories, organize your files accordingly.
2, the system has a unique path for each file name
3, the path name in two ways:
① absolute path: Starting directory name is given on the path until the specified files from the root directory
② relative path: the definition from the current directory path
4, create files and directories are usually carried out in the current directory
5, personal understanding is that, a single-layer structure catalog is our time to write the operating system, beginning just put together all of the files, the file name at this time naturally not be the same; in fact almost two-layered structure, the structure will be equivalent we write the file in accordance with different properties (function name Ye Ye) is divided into a plurality of folders, each file folder when the mutual do not interfere; but the tree is our current operating system for the classification of files, there are multiple discs each have the following multiple folders, folders can also be nested folders.

(IV), acyclic graph directory

1, requires subdirectories can be shared, the shared directory or file can be located in two or a plurality of the file system.
2, the tree structure of directories and files shared prohibit, acyclic graphs allow the same file or subdirectory may occur in two different directories, it is to expand the tree structure.
3, a different file name may indicate the same file. Find statistics and for it may bring some problems
4, delete the time may be a problem

(V), General List of Figures

1, how to ensure that no ring?
① only allowed to occur in the link file, not a subdirectory on
② garbage collection: self-referenced file, its reference count is not equal to 0; garbage collection involves traversing the entire file system, and mark all accessible space. Then, all unmarked second portion to the free space list collected.
③ whenever a new link is established, on the use of the corresponding detection algorithm to avoid loops.

Fourth, the file system is installed

1, the file system must be installed before accessing good.
2, has not been installed file system must be mounted to the mounting point.
3, the directory structure may be built on a plurality of volumes, which must be installed so that they can be used in the file system namespace
4, until the operating system requires the installation position of the device and the file system name (installation point), typically mounted point empty directory and the root directory.
** 5, personal understanding: for file system, has realized the software side (mostly catalog), but also hardware support (primarily disk). The role of the file system is to provide an access path to a file a piece of a block set on the disk. Let's say a disk, the disk file system is divided into many different parts volumes and partitions, similar to the sub-disk and file our new folder. The operating system file to access the specified location on the disk according to the directory, so the directory can be understood as a pointer file.
**
6, personal understanding: We need to distinguish between installation and formatting. The so-called installation, is to a disk connected to the PC through a data line, called the installation. When we installed the file system, the file system is the process of two links (for example, directory and file system disk U disk file system link in a node), and the operating system, it is only based on file system cache data memory part of the guide block, looking for the corresponding file, then the file is passed as a DMA into memory by the guide block;
formatted not the same, according to the operating system formatted disk generate a reasonable partitioning software and create a new file system implementation (directory files), then you can go to access the OS hardware based on catalog file.

Fifth, file sharing

1, desires to share files on multi-user systems
2, sharing can be achieved through protection mechanisms
3, on distributed systems, files can be shared across the network.
4, NFS is a common distributed file-sharing method

PROTECT

1, the document owner / creator should be able to control
what ① do?
② by whom?
2, the type of access
① read
② written
③ execution
④ additional
⑤ delete
⑥ list
3, access mode: read, write, execute
4, ask the administrator to create a group G, and add some users to the group
5, access control lists: given to each user name and type of access they are allowed

Published 205 original articles · won praise 110 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_40851744/article/details/103632355