Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions system/lib/wasmfs/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Backend {
virtual std::shared_ptr<Directory> createDirectory(mode_t mode) = 0;
virtual std::shared_ptr<Symlink> createSymlink(std::string target) = 0;

virtual bool shouldMountSpecialFiles() { return true; }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking maybe shouldPopulateRoot, but maybe your name is more explicit?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function name was mentioned in comment #24733 (comment). But I'd like shouldPopulateRoot as well.


virtual ~Backend() = default;
};

Expand Down
2 changes: 2 additions & 0 deletions system/lib/wasmfs/backends/node_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ class NodeBackend : public Backend {
std::shared_ptr<Symlink> createSymlink(std::string target) override {
WASMFS_UNREACHABLE("TODO: implement NodeBackend::createSymlink");
}

virtual bool shouldMountSpecialFiles() override { return false; }
};

// TODO: symlink
Expand Down
7 changes: 6 additions & 1 deletion system/lib/wasmfs/wasmfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,13 @@ std::shared_ptr<Directory> WasmFS::initRootDirectory() {
// The root directory is its own parent.
lockedRoot.setParent(rootDirectory);

// Don't mount special files if not needed (e.g. in NODERAWFS mode).
if (!rootBackend->shouldMountSpecialFiles()) {
return rootDirectory;
}

// If the /dev/ directory does not already exist, create it. (It may already
// exist in NODERAWFS mode, or if those files have been preloaded.)
// exist if those files have been preloaded.)
auto devDir = lockedRoot.insertDirectory("dev", S_IRUGO | S_IXUGO);
if (devDir) {
auto lockedDev = devDir->locked();
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_wasmfs.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 7023,
"a.out.js.gz": 3310,
"a.out.nodebug.wasm": 172714,
"a.out.nodebug.wasm.gz": 63316,
"total": 179737,
"total_gz": 66626,
"a.out.nodebug.wasm": 172741,
"a.out.nodebug.wasm.gz": 63348,
"total": 179764,
"total_gz": 66658,
"sent": [
"__cxa_throw",
"_abort_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_files_wasmfs.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 5465,
"a.out.js.gz": 2575,
"a.out.nodebug.wasm": 58418,
"a.out.nodebug.wasm.gz": 18067,
"total": 63883,
"total_gz": 20642,
"a.out.nodebug.wasm": 58443,
"a.out.nodebug.wasm.gz": 18094,
"total": 63908,
"total_gz": 20669,
"sent": [
"a (emscripten_date_now)",
"b (emscripten_err)",
Expand Down
4 changes: 4 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -5553,6 +5553,8 @@ def test_fsync(self, args):
def test_fs_dev_random(self):
if WINDOWS and self.get_setting('NODERAWFS'):
self.skipTest('Crashes on Windows and NodeFS')
if self.get_setting('NODERAWFS') and self.get_setting('WASMFS'):
self.skipTest('https://github.com/emscripten-core/emscripten/issues/24830')
self.do_runf('fs/test_fs_dev_random.c', 'success')

@parameterized({
Expand Down Expand Up @@ -13256,6 +13258,8 @@ def test_unistd_chown(self):

@wasmfs_all_backends
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Does wasmfs_getdents.c need to get re-written to handle the rawfs mabye?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just skip under NODERAWFS rather than removing wasmfs_all_backends completely?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-added the @wasmfs_all_backends decorator and skipped this only under NODERAWFS with commit f3b85c9.

See for details:

------------- Reading from /dev Directory via JS -------------
.
..
null
random
stderr
stdin
stdout
urandom

def test_wasmfs_getdents(self):
if self.get_setting('NODERAWFS'):
self.skipTest('test expectations assumes /dev is virtualized')
# Run only in WASMFS for now.
self.set_setting('FORCE_FILESYSTEM')
self.do_run_in_out_file_test('wasmfs/wasmfs_getdents.c')
Expand Down
Loading