Jump to content




VFS - Virtual File System


8 replies to this topic

#1 Mr. Bateman

  • Members
  • 98 posts
  • LocationAustralia

Posted 22 June 2014 - 04:14 AM

Virtual Filesystem


The VFS API hooks onto the fs API and allows "images" to be loaded into RAM and be treated as normal file systems. Any image that gets loaded will be given the "//" prefix instead of the normal "/" prefix. Example: If I loaded an image named "ext1", it will be accessible via "//ext1/".

Each image follows a certain format:
image = {

	name = "name",
	files = {

		file = {
			data = "",
			isDir = bool,
			isReadOnly = bool
		}
	}
}

name: The name of the image, ie. "ext1" in my example
files: A table of files.

Each file is a pair, the key is the relative name ("//ext1/directory/file" will be stored as "directory/file") and the value is table containing data associated with the file.

data: A string of hex (not pure ASCII) to preserve byte values due to LuaJ handling of strings
isDir: A boolean value representing if the file is a directory
isReadOnly: A boolean value representing if the file is readonly (most likely not)

Documentation:
Spoiler

Link: http://pastebin.com/ZT1euz3x
Or alternatively (preferred):
pastebin get ZT1euz3x vfs

Please tell me any bugs or suggestions, as I have vigorously bugtested this myself but I cannot find all of the bugs in every scenario!

Edited by ROFLCopter64bit, 14 August 2014 - 04:12 AM.


#2 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 22 June 2014 - 08:35 AM

The best first post I have ever seen :D (seriously)

Edited by ZudoHackz, 22 June 2014 - 08:35 AM.


#3 Mr. Bateman

  • Members
  • 98 posts
  • LocationAustralia

Posted 22 June 2014 - 09:01 AM

View PostZudoHackz, on 22 June 2014 - 08:35 AM, said:

The best first post I have ever seen :D (seriously)
Thanks, I had to fight with chrome since it would keep jumping to random positions in the text every time I wanted to backspace.

#4 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 22 June 2014 - 09:34 AM

I have to say, this looks pretty nifty!

#5 Mr. Bateman

  • Members
  • 98 posts
  • LocationAustralia

Posted 22 June 2014 - 12:26 PM

View Postoeed, on 22 June 2014 - 09:34 AM, said:

I have to say, this looks pretty nifty!
The original idea was to make a system that had the ability to use files on another computer (hence the "//" prefix), but this was a prerequisite.

#6 Mr. Bateman

  • Members
  • 98 posts
  • LocationAustralia

Posted 14 August 2014 - 04:14 AM

I've updated this API to use hex strings instead of a byte table for storing data, as it would cause serialized tables to be saved at a ratio of 1250% compared to 200% now (not to mention really long load times)
This means that all current images created are no longer compatible, so make sure to copy the data via fs.copy or the inbuilt program to preserve it.

#7 tenshae

  • Members
  • 66 posts

Posted 30 August 2014 - 04:44 AM

Can I use this to make a sandboxed filesystem for the kernel of my OS?

#8 Mr. Bateman

  • Members
  • 98 posts
  • LocationAustralia

Posted 30 August 2014 - 05:44 AM

View PostUtopastoo, on 30 August 2014 - 04:44 AM, said:

Can I use this to make a sandboxed filesystem for the kernel of my OS?
It doesn't really work like that, as it creates a new path at //[your drive name here], allowing memory to be used as disk space.
But if you want to make a sandbox to cut off access to paths that are not allowed, I can create a kernel that does that.

#9 tenshae

  • Members
  • 66 posts

Posted 03 September 2014 - 05:02 AM

View PostMr. Bateman, on 30 August 2014 - 05:44 AM, said:

View PostUtopastoo, on 30 August 2014 - 04:44 AM, said:

-snippety-
It doesn't really work like that, as it creates a new path at //[your drive name here], allowing memory to be used as disk space.
-snippety snippety-
I moved on to a different approach. Thanks for offering your services, but they won't be required! :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users