jprendes / emception

Run Emscripten in the browser
Other
285 stars 35 forks source link

[Question] How does SHAREDFS work? #3

Closed NovaAndrom3da closed 2 years ago

NovaAndrom3da commented 2 years ago

Out of curiosity, how does the sharedfs work? Is it a temporary virtualized filesystem? Or is that saved to an indexedDB? Or is it the user's local filesystem?

jprendes commented 2 years ago

Hi!

SHAREDFS is intended to share a filesystem between different Emscripten modules. You need a first module with a "normal" FS, and then you can share it with other modules using SHAREDFS. It is inspired by Emscripten's PROXYFS.

SHAREDFS will share the whole root, except for a few directories, like /proc and /dev since those contain module specific files (like stdin and stdout).

In the case of Emception, there's a root module that "owns" the filesystem. The root of that filesystem is a MEMFS, which is an in memory virtualized filesystem in JavaScript. However, the /emscripten/cache directory is mounted using IDBFS, which persists the data in an IndexedDB.

Hope that helps!

Do you have another application in mind for it?

NovaAndrom3da commented 2 years ago

Sorry for the late response, I'm working on getting a linux environment running entirely in the browser - BrowserLinux - and was intrigued by emception. I am working on adding a "complete filesystem" in IndexedDB with pre-written methods of reading and writing pseudo-"files" that would be accessible to the programs compiled to wasm. If I am able to combine that "filesystem" with SHAREDFS, that would be highly beneficial.