Now the diagram says that each pointer is 32/64 bits.
The diagram says, One data block for each pointer
Sample calculation of maximum file size
* 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
answered Jan 21, 2012 at 13:31
swapnil akolkar swapnil akolkar
151 1 1 silver badge 2 2 bronze badges
The pointers referred to are disk block addresses - each pointer contains the information necessary to identify a block on disk. Since each disk block is at least 512 bytes (sometimes 4096 or 8192 bytes), using 32-bit addresses the disk can address up to 512 * 4 * 1024 3 = 2 TiB (Tebibytes - more commonly called Terabytes) assuming 1/2 KiB blocks; correspondingly larger sizes as the block size grows (so 32 TiB at 8 KiB block size). For an addressing scheme for larger disks, you would have to move to larger block sizes or larger disk addresses - hence 48-bit or 64-bit addresses might be plausible.
So, to answer Q1, 32-bits is a common size for lots of things. Very often, when 32 bits are no longer big enough, the next sensible size is 64 bits.
So, the inode structure can handle files bigger than 32-bit disk addresses can handle.
I'll leave it as an exercise for the reader to see how things change with 64-bit disk addresses.
answered May 2, 2010 at 22:08 Jonathan Leffler Jonathan Leffler 748k 144 144 gold badges 939 939 silver badges 1.3k 1.3k bronze badgesThank you very much for the detailed response. Can you please explain me the computation: 32-bit addresses the disk can address up to 512 * 4 * 10243 = 2 TiB done above ??
Commented May 2, 2010 at 22:58@darkie15: assume that each disk address is a block number. With 32-bit numbers, you can address roughly 4 billion different blocks; each of those blocks is a 1/2 KiB, so you can address about 2 trillion bytes - aka 2 TiB.
Commented May 2, 2010 at 23:21Before giving the answers, you should understand how file system works:
Whenever a user or a program refers to a file by name, the operating system uses that name to look up the corresponding inode, which then enables the system to obtain the information it needs about the file to perform further operations. That is, a file name in a Unix-like operating system is merely an entry in a table with inode numbers, rather than being associated directly with a file (in contrast to other operating systems such as the Microsoft Windows systems). The inode numbers and their corresponding inodes are held in inode tables, which are stored in strategic locations in a filesystem, including near its beginning.
Answer for the first question is that bit space covers the total 32 or 64 bit. simply it makes 2^32 and it is large enough define the all these variables.Also, for further uses it has to know the size of the bits for operations.In your example they just defined in that way.
Second each pointer (size depends on your disk capacity) reference a data block(8KB on disk, disk has blocks) but keep in mind that unix file system has an hierarchical structure. A table that points many other tables and finally the last table point to the data block.
i offer you to go over this book, very useful to understand the Unix file system.