copy / v86

x86 PC emulator and x86-to-wasm JIT, running in the browser
https://copy.sh/v86/
BSD 2-Clause "Simplified" License
19.62k stars 1.37k forks source link

API to interact with guest OS Filesystem #335

Open jcubic opened 4 years ago

jcubic commented 4 years ago

There is library BrowserFS that allow to use Node.js fs module in browser, you can build real file system using its functions.

It would be cool if v86 would support this FS instead of flat json and URLs file that allow to one way communication. With BrowserFS you can create FileSystem were you can share the files with host and guest and would work both ways.

jcubic commented 4 years ago

For the current API (to be able to send files from host to guest) you only need single function that is called in JS, that refresh the FS from ouside. Right now you need to unmount modify the FS and mount it again. Also change in FS from Linux is not reflected in BrowserFS because the API is read only you can only send files from host to guest the other way is not possible.

jcubic commented 4 years ago

To not break the API I would add events createDirectory/deleteDirectory/createFile/deleteFile/writeFile with this you can write layer on top to write to BrowserFS so you can have communication from guest to host.

imreallyliam commented 4 years ago

Well actually, BrowserFS may not be needed. Chrome/HTML5 is bringing support for a native file API system.

jcubic commented 4 years ago

@xeu100 I would prefer to have an API that will allow to build something like this with any FS, to actually interact with the system, I would not like to rely on something that is only in Chrome.

Right no you can't do any data passing, except poorly documented read only URL based file system that can't change from outside while the system is running.

imreallyliam commented 4 years ago

@xeu100 I would prefer to have an API that will allow to build something like this with any FS, to actually interact with the system, I would not like to rely on something that is only in Chrome.

Right no you can't do any data passing, except poorly documented read only URL based file system that can't change from outside while the system is running.

Actually it's being implemented on other browsers such as Firefox as well, with the same standards. The native file system API is read and write without a weird download system, it's about to become available in Chrome m86 and then newer versions of modern browsers. It's much more efficient than having a nodejs server be required.

jcubic commented 4 years ago

BrowserFS have bigger support if the library had the proper API you should be able to use any browser API you want. You don't need to use node.js with BrowserFS unless you mean current implementation.

imreallyliam commented 4 years ago

It's being implemented to all modern browsers as a standard. The maintainers should use standards over 3rd party tools.

jcubic commented 4 years ago

I don't want integration with 3rd party tool I want API build in, so I can use it to use whatever API I want, If API exist you can use file system API that will not work in every browser unless you wait few years and I can use whatever I want. Right now you can interact with the guest OS. I prefer something that will work in every browser.

copy commented 3 years ago

I think this request is reasonable. I'm probably not going to work on it, but pull requests are welcome.

ProgrammerIn-wonderland commented 1 year ago

my team is maintaining a version of v86 meant to be interacted with Filer, which is pretty similar to browserFS (simulate node fs in browser)

you should be able to make it use browserFS with minimal modifications https://github.com/MercuryWorkshop/v86

Do excuse the code quality, we are highschoolers doing this for a hobby project

jcubic commented 1 year ago

@ProgrammerIn-wonderland thanks I actually don't need BrowserFS only a way to interact with guest OS.

ProgrammerIn-wonderland commented 1 year ago

On that note, you may actually be better with the official v86, you should be able to do emulator.send_file when configured for plan9 and emulator.read_file