gpt4 book ai didi

unix - 理解 inode 的概念

转载 作者:行者123 更新时间:2023-12-02 16:30:05 25 4
gpt4 key购买 nike

我指的是the link关于Inode的概念

我对部分感到困惑:

  1. 12 个直接 block 指针
  2. 1 个单个间接 block 指针
  3. 1 个双间接 block 指针
  4. 1 个三重间接 block 指针

现在该图显示每个指针都是 32/64 位。

  • [查询]:为什么以及如何推断这些值?我的意思是为什么专门只有 32 位或 64 位指针?

该图表示,每个指针 {4 字节/8 字节} 一个数据 block {8 KB}

  • [查询]:这实际上是如何实现的?即 8*1024 字节/8 字节 = 1024 字节? 8KB block 的 8 字节指针背后的逻辑是什么?

最佳答案

最大文件大小的计算示例

* Assume that there are 10 direct pointers to data blocks, 1 indirect pointer, 1 double indirect pointer, and 1 triple indirect pointer
* Assume that the size of the data blocks is 1024 bytes = 1Kb, i.e., BlockSize = 1Kb
* Assume that the block numbers are represented as 4 byte unsigned integers, i.e., BlockNumberSize = 4b
* Some data blocks are used as index blocks. They store 1024 bytes / 4 bytes/entry = 256 entries
* Maximum number of bytes addressed by 10 direct pointers is

= Number of direct pointers * Blocksize
= 10 * 1Kb
= 10Kb


* Maximum number of bytes addressed by single indirect pointer is

= NumberOfEntries * BlockSize
= (Blocksize / BlockNumberSize) * BlockSize
= (1Kb / 4b) * 1Kb
= 256 * 1Kb
= 256Kb


* Maximum number of bytes addressed by double indirect pointer is

= NumberOfEntries^2 * BlockSize
= (Blocksize / BlockNumberSize)^2 * BlockSize
= (1Kb / 4b)^2 * 1Kb
= (2^10 / 2^2)^2 * (2^10b)
= (2^8)^2 * (2^10)b
= (2^16) * (2^10)b
= 2^6 * 2^20 b
= 64 Mb


* Maximum number of bytes addressed by triple indirect pointer is

= NumberOfEntries^3 * BlockSize
= (Blocksize / BlockNumberSize)^3 * BlockSize
= (1Kb / 4b)^3 * 1Kb
= (2^10 / 2^2)^3 * (2^10b)
= (2^8)^3 * (2^10)b
= (2^24) * (2^10)b
= 2^4 * 2^30 b
= 16 Gb


* Maximum file size is 16Gb + 64Mb + 266Kb

关于unix - 理解 inode 的概念,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2755006/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com