[Linux File System Detailed --- read it again, look at everything is a file !!!!!!!!!!!] [] [various configuration files is very good tutorial site [empty] &&& what tools files saved to look inside in the end what! ! ! ]

0, LINUX everything is a file

0.5 Talk standard Linux filesystem (Ext2 / Ext3 / Ext4)

Ext

The full name Linux Extended File System, extfs , namely Linux extended file system Ext2 file extension represents the second generation system, Ext3 / Ext4 and so on, they are an upgraded version of Ext2, but in order to quickly restore the file system, reduce consistency check the time, increased logging, so the index is known as Ext2 file system, and Ext3 / Ext4 file system is called a log.

1, [Tutorial] Linux everything is a file (containing the benefits and drawbacks)

2, Linux file system Detailed graphics easy to understand} { link

Then the space is how to manage it? unix / linux using a simple method.

It disk blocks divided into three sections:

  • Super block , the first block of the file system is called a super block. The block storage structure information file system itself (? Metadata metadata?) . For example, the size of each super block recording area, the information stored also superblock unused disk blocks.
  • I- cut point table (the inode). The next part of the superblock is i- node table. Each i- node is a correspondence file / directory structure (a data structure that contains all the basic information file) ,
    Here Insert Picture Description
    Here Insert Picture Description
    the structure that contains the length of a file, creation and modification time, permissions, affiliations, disk the location information . A file system maintains an array of index nodes , each file or directory corresponds to only one element of the index node array. System to each index node is assigned a number, which is the node index in the array, called inode numbers
  • Data area . The third part of the file system is a data area . Contents of the file stored in this area. All blocks are the same size on the disk. If the file contains more than one piece of content, the contents of the file will be stored in multiple disk block. A large file easily distributed thousands of independent production of disk blocks.

Orthodox Linux file system (e.g., ext2, ext3) file of a directory entry, inode data blocks and components.

  • Directory entry : including file name and the inode number.
  • Inode : also known as inode file, and is located to the data block pointer is stored the basic information file.
  • Data block : specific content of the file stored.

Orthodox Linux file system (e.g. ext2,3 etc.) will be divided into the hard disk partition directory blocks , the inode blocks the Table and the data block data areas . A directory entry of a file, inode blocks and a data area. Inode file contains the attributes (e.g., read-write property, owner, etc., and the pointer to the data block), the data block is the contents of the file area. When viewing a file, the file attributes and the isolated point data is stored in the inode table start, re-read data from the data block.

File storage structure roughly as follows:
Here Insert Picture Description
where the directory entry (dentry) structure is as follows (directory entries are stored in the file directory of the contents of the file belongs in each file):

Figure 4: The directory entry structure
Here Insert Picture Description
in which the file inode structure as follows (in the inode files included information obtained can be viewed through the stat filename):
Here Insert Picture Description
more than just reflect the general structure, linux file system itself is evolving. But more than the basic concept is unchanged. And as ext2, ext3, ext4 file system, there is a big difference, if you want to understand you can view a special file system introduction.

2. Create a file of procedure

From the foregoing we can know the contents and properties of files are stored separately, then is how to manage them? Now we have to create a file as an example to explain.
At the command line, type the command:
$ the WHO> UserList
upon completion of this command. File system adds a new file to store the contents of the output of the command who userlist, then this whole process in the end is how it happened?
There are file attributes, content, and file name three. Core contents of the file stored in the data area, file attributes stored in the i- node, the file name stored in the directory.

Successfully created a file mainly in the following four steps:

  • 1, which is stored in the storage attribute file attribute, the kernel first find an empty i- node. For example, the kernel finds i- node number 921,130. The kernel information file recording them. Such as file size, file owner, creation time, and so on.
  • 2, i.e., the stored data file stored content, since the file requires three pieces of data. Therefore, the kernel found three blocks from the free list of free blocks. Such as 600,200,992, a copy of data block 600 to the kernel buffer, the second and third copy 922 and 600, respectively.
  • 3, the distribution record, save the data to three data blocks. It is necessary to record up later to find the right data. The distribution of records in the file i- node in the number list disk inside. These three numbers are placed in three locations beginning.
  • 4, add the file name to the name of the directory, the new file is userlist kernel file entry (47, userlist) added to the catalog file. Correspondence between the file name and i- node number to the file name and content attributes of files and connect, locate the file name to find i- node number of the file, you can find properties and content files via i- node number.

Reference code for a specific implementation process:
http://blog.csdn.net/kai_ding/article/details/9206057

3. Create a directory of process

Published 349 original articles · won praise 2 · Views 2108

Guess you like

Origin blog.csdn.net/m0_37681589/article/details/100652934