Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: How to represent the filesystem in DS?by Fletch (Bishop) |
on Mar 26, 2022 at 18:21 UTC ( [id://11142429]=note: print w/replies, xml ) | Need Help?? |
I'd try and track down a copy of The Design and Implementation of the 4.4BSD Operating System ( ISBN 9780768684940 ), specifically Chapter 7: Local Filesystems. While that's (probably) more than you're trying to do, understanding how UFS actually is implemented and the data structures they used can't hurt and should give relevant inspiration. For instance WRT to your last question of different files with the same name the way I'd approach that would be similar to how most *NIX FSen do it: separate directory entries and naming references from content stored in inodes. You'd have one inode with id XYZ that the name /a/b/c/file1 points to (however), and a different inode of contents DEF that's referenced from the name /x/y/z/file1. If you really wanted to get kind of fancy you could (maybe) use a hash (e.g. sha1 of the contents) as your "inode number" and then you could (for instance) deduplicate things by just creating links to the same underlying storage (instantiated by creating hard links in your real FS when you actually create whatever you're modeling). Edit: tweaked phrasing about hash. Also another reference for ext2 from Linux.
The cake is a lie.
In Section
Seekers of Perl Wisdom
|
|