Skip to content

Commit bae0500

Browse files
authored
[WasmFS] Implement /tmp (#17237)
Also refactor the setup of /dev/* to use the newer backend API since we're touching that code anyway. For testing, add a WasmFS configuration to an arbitrary test that depends on /tmp. Fixes #17127.
1 parent 28020ed commit bae0500

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

system/lib/wasmfs/wasmfs.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,19 @@ std::shared_ptr<Directory> WasmFS::initRootDirectory() {
7575
// The root directory is its own parent.
7676
lockedRoot.setParent(rootDirectory);
7777

78-
auto devDirectory =
79-
std::make_shared<MemoryDirectory>(S_IRUGO | S_IXUGO, rootBackend);
80-
lockedRoot.mountChild("dev", devDirectory);
81-
auto lockedDev = devDirectory->locked();
82-
83-
lockedDev.mountChild("stdin", SpecialFiles::getStdin());
84-
lockedDev.mountChild("stdout", SpecialFiles::getStdout());
85-
lockedDev.mountChild("stderr", SpecialFiles::getStderr());
86-
lockedDev.mountChild("random", SpecialFiles::getRandom());
87-
lockedDev.mountChild("urandom", SpecialFiles::getURandom());
78+
auto devDir = lockedRoot.insertDirectory("dev", S_IRUGO | S_IXUGO);
79+
assert(devDir);
80+
{
81+
auto lockedDev = devDir->locked();
82+
lockedDev.mountChild("stdin", SpecialFiles::getStdin());
83+
lockedDev.mountChild("stdout", SpecialFiles::getStdout());
84+
lockedDev.mountChild("stderr", SpecialFiles::getStderr());
85+
lockedDev.mountChild("random", SpecialFiles::getRandom());
86+
lockedDev.mountChild("urandom", SpecialFiles::getURandom());
87+
}
88+
89+
[[maybe_unused]] auto tmpDir = lockedRoot.insertDirectory("tmp", S_IRWXUGO);
90+
assert(tmpDir);
8891

8992
return rootDirectory;
9093
}

tests/test_other.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4949,6 +4949,7 @@ def test_strftime_zZ(self):
49494949
def test_strptime_symmetry(self):
49504950
self.do_runf(test_file('strptime_symmetry.cpp'), 'TEST PASSED')
49514951

4952+
@also_with_wasmfs
49524953
def test_truncate_from_0(self):
49534954
create_file('src.cpp', r'''
49544955
#include <cerrno>

0 commit comments

Comments
 (0)