Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python Virtual PC

Name: Anonymous 2008-04-23 9:35

I'm trying to make a virtual PC in python and need some help.  This virtual PC will be a console and you would be able to mess around a virtual file system.  I need some help on how to make this virtual file system.  So far I defined some files like this:

files = [
['page.txt','this is a test'],
['test.txt','another test'],
['lol.html','<html>\n</html>']
]

Where the first item would be the name of the file, and the second would be the contents.  I need some help on how to print it to the screen and how to make directory's.  Would this even be the right way of doing this or should I make files classes?

Name: Anonymous 2008-04-24 0:26

You could create a virtual disk as an array of blocks, where each block is just an array of bytes of a fixed size (say 256 bytes).

Then make a simple file table, with a fixed number of entries, where each entry is a block number (ie. an index into the disk's block array). Make each file occupy 1 block, with say 32 bytes for the name, 4 bytes for the size, and the rest used to store the file contents. This gives you a simple 1-level filesystem, where 1 file = 1 block = 256 bytes.

From there, you could introduce some indirection by making the files contain pointers to other blocks instead of directly storing data. That increases the maximum filesize.

Then you could introduce a flag into files that indicate whether they represent a directory. If the flag is true, then the file's data pointers point to the files contained in the directory.

You could also think about how your virtual disk is going to track which blocks are used and which are free, how you're going to handle deletions, etc.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List