copy / v86

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

upload files (custom liveCD) #605

Closed m-asyua closed 2 years ago

m-asyua commented 2 years ago

I created a custom CentOS-Based Live CD and it works. Is there a way to upload a file on my linux by the custom LiveCD, like demos of Arch Linux and Buildroot which can upload a file? Is a tool needed for LiveCD?

SuperMaxusa commented 2 years ago

If your Centos LiveCD supports 9pfs, then you can add this line to the V86Starter configuration, as done in Buildroot:

filesystem: {},

To upload files in v86 use the function create_file(): https://github.com/copy/v86/issues/596#issuecomment-1008208368

If the system supports 9pfs, then it will be visible in df, for example, like this: image

The easiest way to check that 9pfs is working properly is to run this in the DevTools console:

emulator.create_file("/hello_world", "");

image

(This example is not suitable for file uploads. To upload and download files to 9pfs, use the code from main.js) https://github.com/copy/v86/blob/229310e6864ac8c271e629782cf03597c9b9d372/src/browser/main.js#L1751-L1796

https://github.com/copy/v86/blob/229310e6864ac8c271e629782cf03597c9b9d372/index.html#L251-L259

copy commented 2 years ago

In addition to what @SuperMaxusa wrote, you'll need to run mount host9p -t 9p /mnt/ in the guest to mount the filesystem.

m-asyua commented 2 years ago

Thank you for your information. I could prepare the system that supports 9pfs, and I will try to create a LiveCD.

9p
m-asyua commented 2 years ago

It works. I can send a sample file. Thank you very much! I need the option to run. mount -t 9p -o trans=virtio,version=9p2000.L host9p /mnt

test9p