当前位置:网站首页>What is inode? It will help you understand inode and what help inode provides when creating and deleting files.
What is inode? It will help you understand inode and what help inode provides when creating and deleting files.
2022-07-25 23:52:00 【Rabbit 7】


Hello everyone , I am a rabbit 7 , A hard-working C++ Bloggers ~
If there is something wrong with the knowledge of the article , Please correct me. ! Learn with you , Progress together
If you have not understand , You can always ask me questions , I will try my best to explain ~
If you feel the blogger's article is good , I want you to pay attention 、 give the thumbs-up 、 Collect three companies to support bloggers ~!
Your support is the driving force of my creation !
🧸 I believe the hard work now , Are the best witness for the future !
🧸 People's attitude determines posture !
This article CSDN First episode !
Preface
For better understanding and observation , Here I use Linux Environment to test !
This blog is the information that bloggers will review in the future , So you can rest assured to learn , It's very comprehensive , Each piece of code has been sent to everyone , If you have any questions, you can try debugging .
We must look at the pictures carefully , The words in the picture are all essence , Many details are shown in the picture 、 It's written out , So we must be careful ~
Thank you for your support , Thank you for your love , rabbit 7 I wish you all a smooth journey in your study , Everything goes well on the way of life ~!
inode
In order to explain clearly inode Let's take a brief look at the file system :

Linux ext2 file system , The figure above shows the disk file system diagram ( The kernel memory image must be different ), Disk is a typical block device , Hard disk partitions are divided into one by one block. One block The size of is determined when formatting , And cannot be changed . for example mke2fs Of -b Options can be set block The size is 1024、2048 or 4096 byte . The startup block in the figure above (Boot Block) The size of is certain ,
- Block Group:ext2 The file system is divided into several partitions according to the size of the partition Block Group. And each Block Group All have the same structural composition .
- Superblock (Super Block): Store the structure information of the file system itself . The recorded information mainly includes :bolck and inode Total amount , That is not used block and inode The number of , One block and inode Size , Time of last mount , The last time data was written , Information about other file systems such as the time when the disk was last verified .Super Block The information is corrupted , It can be said that the entire file system structure is destroyed .
- GDT,Group Descriptor Table: Block group descriptor , Describes block group attribute information , Interested students can learn about .
- Block bitmap (Block Bitmap):Block Bitmap It's recorded in Data Block Which data block in is already occupied , Which data block is not occupied .
- inode Bitmap (inode Bitmap): Every bit It means a inode Whether it is free or not .
- i Node table : Storage file properties Such as file size , owner , Last modification time, etc .
- Data area : Contents of stored documents .

The idea of storing attributes and data separately seems simple , But how does it actually work ? We go through touch A new file to see how it works .

To illustrate , Let's simplify the figure above :

In order to understand this diagram , Next, I will introduce :

Then we can understand better now ls 、 ls -l 、 cat The order is what to do again :

Then we can explain the process of creating files :

Now that you have created the file , Then this file must have its inode Number , That is from inode Bitmap Apply for one inode Number , And then from inode Table The corresponding position in , Put the current file's inode Fill in the attribute , Then if there is data written in , Then in Block Bitmap Apply for block , And establish inode and block The correspondence between , Then write the data in , Then the file name of this file and inode No. is filled in the current directory inode Table in .
Creating a new file mainly includes the following 4 Operations :
- Storage attribute
The kernel first finds a free i node ( Here is 790231). The kernel records the file information .- Store the data
The file needs to be stored in three disk blocks , The kernel found a free block :300,500,800( Write casually ). The first piece of data in the kernel buffer Copied to the 300, Copy the next piece to 500, And so on .- Record the distribution
The contents of the documents are in order 300,500,800 Deposit . Kernel in inode The above block list is recorded in the disk distribution area on the .- Add the file name to the directory
New file name new.txt .
linux How to record this file in the current directory ? The kernel will enter (790231,new.txt ) Add to catalog file . File name and inode The correspondence between the file name and the contents and attributes of the file .

That's it inode All the knowledge of , If you like reading this article and have some harvest , You can support rabbit 7 , to rabbit 7 Pay more attention for three times , Your attention is my greatest encouragement , It is also my creative motivation ~!
Thank you again for watching , Thank you for your support !
边栏推荐
- Loading process such as reflection
- 死信队列 和消息TTL过期代码
- Graph traversal DFS, BFS (code explanation)
- sftp和ftp的区别
- Typescript TS basic knowledge and so on
- 【ManageEngine】ServiceDesk Plus荣获2022安全样板工程数据安全奖
- 从哪些维度评判代码质量的好坏?如何具备写出高质量代码的能力?
- Dead letter queue and message TTL expiration code
- Same origin strategy and cross domain
- What is parity? How to use C language?
猜你喜欢

红娘的话

Optimize the browsing experience of yandere/konachan site with user scripts

获取马蜂窝酒店数据

Inheritance (the child constructor inherits the attributes in the parent constructor)

SAP Message No. VG202 IDoc E1EDK18 中付款条款已经转移:检查数据
![[code case] blog page design (with complete source code)](/img/9e/0e7cab956515b9cc75a7567eb477d2.png)
[code case] blog page design (with complete source code)

Payment terms in SAP message No. vg202 IDoc e1edk18 have been transferred: check data

Program environment and pretreatment

Docker 安装 Redis-5.0.12(远程访问)

ShardingSphere数据分片
随机推荐
R语言安装教程 | 图文介绍超详细
initializer_list工具库学习
JS regular expression content:
Dead letter queue and message TTL expiration code
图的遍历-DFS,BFS(代码详解)
1223. 掷骰子模拟 范围DP
Numerical learning iota, accumulate
Get the data of Mafeng Hotel
抽丝剥茧C语言(高阶)程序环境和预处理
ES6 syntax (difference between let, const, VaR, deconstruction assignment, arrow function, residual parameters, extension method of array)
LeetCode 0919. 完全二叉树插入器:完全二叉树的数组表示
Key and difficult points of C language pointer
Reduce method of array
Nacos offline service times error errcode: 500
Imitating the magnifying glass effect of JD products -- JS Foundation
Promise resolve callback hell, async await modifier
[ManageEngine] servicedesk plus won the 2022 safety model engineering data safety award
C language implementation of three chess
Lua脚本编写Wireshark插件解析第三方私有协议
LeetCode 0135. 分发糖果