s-macke / jor1k

Online OR1K Emulator running Linux
http://jor1k.com
BSD 2-Clause "Simplified" License
1.73k stars 196 forks source link

mount local folder using files api ( recent browser ). #68

Open trabitboy opened 9 years ago

trabitboy commented 9 years ago

Uploading a file and downloading a tar.gz is cool, but being able to mount a local directory would be interesting . On browsers supporting the files api, it is technically possible. I have no idea how to program a linux fs from scratch, but as jor1k already has a js based filesystem, probably changing its backend to target files api doesn't seem too far fetched ?

motivated

benjamincburns commented 9 years ago

If you go to work on this, perhaps you should consider writing it as a separate client-side npm module which translates 9p to the files API?

trabitboy commented 9 years ago

I'm a bit confused by the npm reference? I was thinking everything in browser ? ( my target is to get embedded linux to grep, process , local folders for instance, because I don't have the rights to install cygwin/exes ) Trying the html5 files api at the moment. I'll look into 9p ( I don't know anything on the inners of filesystems right now ) .

trabitboy commented 9 years ago

I was under the wrong assumption that the files apis was also able to write, so I know understand better your comment about node.

s-macke commented 9 years ago

trabitboy, you are not the first who is suggesting it. It is possible and would be a nice feature. However when I read the red boxes on the websites like https://developer.mozilla.org/en-US/docs/Web/API/File_System_API http://www.html5rocks.com/en/tutorials/file/filesystem/

my motivation drops to zero implementing it. With "some browsers" you mean basically Chrome.

A implementation on the server side is of course possible. Actually my "cloud" backup button is already a tiny step in this direction.

trabitboy commented 9 years ago

Well actually I also have access to an old-ish chrome in this restricted environment, and I don't mind to investigate. Knowing js and c , and absolutely nothing on filesystems , it sounds kind of fun to hack a backend; I will probably have questions though .

s-macke commented 9 years ago

You are free to do so. POSIX filesystems are not complicated. However, to support the current filesystem API, you have to modificate a lot of the current implementation. It begins with a message based interface to the main thread, because I think, that the filesystem API doesn't work in a worker thread.

trabitboy commented 9 years ago

Trying to look into "hacking" a hardcoded fs in the existing implementation to begin with; I was wondering what your development workflow was ?

I can run the "simple" demo locally in my browser, but I can't see or breakpoint the dynamically loaded js in either firefox or chrom or get easily debug messages from the worker thread. How do you work?

s-macke commented 9 years ago

For debug messages I use the following code message.Debug("This is my string"); The debug message is sent to the main thread and is then printed via console.log

To stop the current emlation you can use the message.Abort() function

benjamincburns commented 9 years ago

I was just suggesting writing an npm module because there's likely bits that are reusable. You can use npm as a package manager for client side code w/ request.js or browserify.

If you want to keep everything nice and modular and well encapsulated, you'll likely be writing a chunk of code which converts 9p messages to JS function calls, and then a separate module which registers a bunch of functions with that one, so that the 9p messages actually translate to something useful. The "9p to JS events" bit is ripe for being written as a reusable npm module. This could help @copy for instance, to reuse this code (should he want to).

trabitboy commented 9 years ago

Hi, I've been testing chrome local file api, but you can only write to a sand box, which I can't seem to find the location of, so usefulness is not very high ...