Repository navigation
Mount root fs via NODEFS - #3152
coolwanglu wants to merge 2 commits into
Conversation
|
Can we do something like this? |
|
@kripken what do you think about this? |
|
Hmm, does this just allow the root to be mounted using node, as opposed to a subdirectory? Is there a significant benefit to allowing that? |
|
Devices are actually why that support was never added. |
|
@kripken It could be just easier to mount everything, in order to access everything. Or do you suggest 'to mount all the subdirs in the root except for /dev' ? |
|
It seems potentially confusing if we only mount some things (not devices). And it doesn't seem so bad to mount the real filesystem under a subdir. Overall I am inclined to think that this is unnecessary complexity. |
|
OK I see. :) |
|
@kripken Do you have a recommendation for transpiling C cli apps that allow a user-supplied filename to be accessed? Mapping to the same filesystem would be a lot more convenient than changing the C code in all the places where the file is accessed to add the |
|
How about setting the user-supplied filename to |
|
I was hoping to not have to modify the source code so much. I'm compiling a 3rd party CLI program to JS and not knowing the internals of the code, and having Emscripten "just work" in this case seems like it would be a worthwhile feature. But from what I gather this project is more focused on the browser side of things then the terminal / Node.js, so I understand that it's not much of a priority at this time. |
|
Just opened #5266 to discuss about this. |
See also #2040.
This WIP patch introduces a new option
Module['MOUNT_ROOT_NODEFS'], which allows the js file to mount the real filesystem into the emscripten user-space via node.jsAn immediate use case is adapting the output of emscripten into frameworks like node-webkit, which allows a complete environment for web native apps.
Currently standard streams
/dev/std{in,out,err}do not work. I'm not quite familiar with the implementation of fs in nodes.js, and here are my observations.fs.writeFileSync('/dev/stdout', 'hello')does not work in node.js, where I got an ENXIO error, maybe because/dev/stdoutis a special device.fs.writeSync(1, 'hello')does work.ofstream fout('/dev/stdout'); fout << "hello";does work in C++ -- not sure if this is undefined behavior, as some says that opening standard streams is undefined behavior.Some ideas of making standard streams work:
FS.createStreamandTTY) and store the fd's to FSSTDOUT, but not/dev/stdoutopen()calls/dev/std*in FS, i.e., to create our own/dev/std*devices even when/is mounted from NODEFSNone of them seems elegant thought...
So I would like to know whether if this would be interesting to emscripten. And if there are better ideas than hacking FS/NODEFS to support standard streams.