Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the principle of file reading based on linux0.11 system?

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about the principle of file reading based on linux0.11 system. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.

The editor is the file system tree, we know that the file system data is stored in the hard disk, here to see how the data is organized into a tree, and how to traverse. This is the tree below.

Let's take a look at the process by reading the file as a clue.

1 We need to find the inode node corresponding to the file according to the file path. Suppose it's an absolute path. The file path is / a/b/c.txt. We have already got the inode corresponding to the root directory when the system is initialized. From the structure of inode, we know that inode has a field that holds the contents of the file. So at this time, the contents of the root directory file are read in, which is a series of dir_entry structures. Then iterate through it one by one, compare whether the file name is equal to a, and finally get a dir_entry corresponding to directory a.

2 according to the dir_entry structure, we know that there is not only the file name, but also the corresponding inode number. We also read the contents of the a directory file according to the inode number. and so on. Finally, the dir_entry corresponding to c is obtained.

3 read the contents of dir_entry from the hard disk according to the inode number of inode corresponding to c. Found him to be an ordinary document. At this point, we have found the inode node corresponding to this file. Complete the assignment of fd- > file structure-> inode structure.

4 then we start to read the contents of the file. According to fd, we find the corresponding inode node. Based on the pos field of the file structure, we know the offset of the data to be read in the file. Based on this offset, you can calculate which index of the i_zone [9] field should be taken. The first 7 blocks of the file correspond to index 0-6, and the first 7 to 7 to 512 correspond to index 7, etc. After getting the index, read the value of the i_zone array in the index, that is, the data we want to read in the data block of the hard disk. Then read this block of data from the hard drive. Return to the user.

5 so far, the search and reading of the file have been completed.

These are the principles of file reading based on linux0.11 system shared by Xiaobian. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report