This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
KillaVanilla's profile picture

Virtualfslayer - Virtual File Systems (And Programs To Manage Them) - Now With Network Filesystem Support!

Started by KillaVanilla, 25 July 2013 - 06:42 PM
KillaVanilla #1
Posted 25 July 2013 - 08:42 PM
Hello all.

This program/API creates "fake" filesystems that are mapped to files, RAM, or even other computers. These folders can optionally be encrypted.
It also comes with a set of utilities to help you make and use these folders.

Programs:
  • mount - Mount a file to a folder, creating the file if it doesn't already exist.
  • unmount - write the filesystem to disk (if applicable) and remove it from the "base" filesystem.
  • sync - write the filesystem to disk
  • setFSMode - set the filesystem's settings: the file it resides in and its encryption key.
  • getMountedFile - get the name of the currently mounted file and its mount point.
  • NFS_server - The Network Filesystem server. Comes separate from the other programs.
Further details concerning these can be found by simply running them with no arguments, though unmount, sync, and getMountedFile take no parameters.

API calls:
  • mount(mountPoint, file, key) - Mount a filesystem, creating a "fake" folder at mountPoint. The file and key parameters are optional.
    • Calling this with no file and key results in the filesystem becoming a RAM drive.
    • Calling this with a file but no key results in the filesystem being written to an unencrypted file.
    • Finally, calling this with both a file and a key results in the filesystem being written to an encrypted file.
    • If you want to mount a network filesystem, set file to "c:[computer id]", and key to your password.
      • Example: "mount c:9 mypassword".
  • unmount() - Unmount the active filesystem, saving it to disk beforehand.
  • flush() - write the contents of this filesystem to disk, encrypting it if necessary.
    • When a NFS server is loaded, this also gets the latest files from the server.
  • makeNFS(server, password) - Connect to a network filesystem server.
  • makeEncrypted(key) - Enable encryption on the currently loaded filesystem.
    • If the active filesystem was a RAM drive or NFS server, then you will also have to set the file to save to (see below).
  • makeUnencrypted() - Disable encryption and enable writing to disk on the currently loaded filesystem.
    • Again, you will need to set the file to save to if the active filesystem was a RAM drive or NFS server.
  • makeMemdisk() - Disable encryption and writing to disk on the currently loaded filesystem.
  • setLoadedFile(file) - Set the file to save the filesystem to.
  • getLoadedFile() - Get the file to save the filesystem to.
  • getMountPath() - Get the folder the active filesystem is mounted to.
  • getMode() - Get the current filesystem's mode as a number:
    • -1: No filesystem has been loaded.
    • 0: The current filesystem is a RAM drive.
    • 1: The current filesystem is an unencrypted file.
    • 2: The current filesystem is an encrypted file.
    • 3: The current filesystem is an NFS server.
  • unload() - Unmount the current filesystem (if applicable) and remove the hooks this API installs into the FS API.
    • The caller is responsible for unloading the VirtualFSLayer API though!
Notes:
  • Mounting an encrypted filesystem takes a really long time right now.
  • Only one filesystem can be mounted at a time.
  • This API requires my base64 library.
    • In addition, in order to use encrypted filesystems, the AES library is required.
    • The SHA2 library is recommended as well, to provide a higher level of security. It is not required, however.
      • It is required to use password authentication with network filesystems.
    • To use network filesystems, both the client and server must have the SHA1 library.
If you only want the base API, click here. (Pastebin code: knR5v4QU)
If you want the utilities set as well, click here. (Pastebin code: H1RfxFxX)
If you want the NFS server, click here. (Pastebin code: VPGizvU7)
Zudo #2
Posted 26 July 2013 - 11:29 AM
:o/> this is cool
jesusthekiller #3
Posted 27 July 2013 - 10:50 AM
Pretty neat!
KillaVanilla #4
Posted 27 July 2013 - 05:50 PM
I'm working on two more features:
  • Sync-on-write: Primarily to make encrypted filesystems more efficient, though this ties in with below:
  • Networked Filesystems (mode 3): A filesystem that's hosted on a server. Operates similarly to dropbox. May or may not be encrypted.
EDIT: NFS is done! Still not encrypted, though. It functions like dropbox or rsync.
Sxw #5
Posted 28 July 2013 - 03:33 PM
This looks awesome. Would networked file systems be encrypted?
KillaVanilla #6
Posted 29 July 2013 - 02:18 PM
This looks awesome. Would networked file systems be encrypted?

As soon as I find a fast way to encrypt filesystems, yes.

On that note, what's the average size of files in CC?