What is this all about:
Spoiler
- This program creates a "virtual hard drive" with 3 "sectors":
- bootSector: here is the "bios.lua". Once you create a "hard drive", it is empty. The "hard drive" won't boot if there is no boot.lua injected.
- sector0: here is the disk. Currently not implemented but will later be used to mount folders as disks.
- sector1: This is the main part, the actual "virtual" filesystem. This stores every folder, file and their data (files).
- The program loads the "hard drive" and tries to boot bios.lua from the bootSector (again, if there is no injected bios, it won't boot). If it succeeds, it will basically remove every api loaded by CraftOS, modify os API and modify the fs API specificly for the HD
- The thing is:
- My current method with the filesystem is not THAT nice: It (temporarely) creates a folder in /tmp/ and "extracts" every file and folder from the actual HD file, which practically leads to decreasing your free space. (Whole drive is in the HD file AND extracted in /tmp/) But it gets deleted if the VM shuts down. So I'd need to think of a way of redirecting every FS function to interact directly with the HD file.
- The bios works similar to the real bios.lua in CC: The VM shuts down, once the bios finishes.
Spoiler
Master:- Uses the inefficient way of FS, by saving every file, folder and their data in a table and when you start the VM, it unpacks EVERYTHING in /tmp/[nameofHD]/, which practically decreases your available space.
- BUT: The FS API is completely working and the same as the original
- Uses a custom version of FS, by making a complete "virtual" filesystem, using inodes and "bllocks", which are all inside that HD file, leaving you that free space you've got.
- BUT: The custom FS API has SOME function working differently, but I think these function don't get used very often (e.g. fs.find() )
Code:
GitHub
An example HD and Bios (Bios already injected) and the usage is written in the README (GitHub)
Don't expect something AMAZING, like an exact VirtualBox imitation O.o Also I don't think this way of doing it is perfect….buuuut it works