News for hackers. Stuff that matters.
Re:Writing a file system from scratch in Rust by SairajK19 on Sunday December 03, 2023 @09:52PM (#38513212)
Hi, I did not understand the arithmetic behind indirect pointers and the file size it can store.

It says "A single indirect pointer can point - (12 + 1024) * 4 KiB" that is 4MiB file.

My question is, what does 1024 represent. I understand 12 is the number of direct pointers and we are multiplying it by 4 considering a pointer takes 4 bytes of space. Would help if anyone explains it.

Might be a silly question, sorry about that. But ya, thanks for the help!

Re:Writing a file system from scratch in Rust by deathanatos on Sunday December 03, 2023 @10:09PM (#38513298)
We're pointing to a block of data; that's the 4 KiB. You have 12 direct pointers — that's the "12".

The "1024" appears to be the single indirect pointers: it seems like the inode only has 1 "single indirect pointer", so that points to a block's worth of pointers. (Hence the "indirect" part.) A block in this design is 4 KiB, and a pointer in this design is 4 B, so the block of pointers will hold 4 KiB / (4 B/pointer) = 1024 pointers — that's the "1024".

Re:Writing a file system from scratch in Rust by SairajK19 on Sunday December 03, 2023 @10:26PM (#38513410)
That explains it well. It's the number of pointers that a 4KiB block can hold. I got it.

Many thanks.