Skip to content

Commit dec3398

Browse files
authored
[WasmFS] Report an optional error from insertDirectory (#17771)
Also add a place with file creation that was missing error handling.
1 parent 3e388f5 commit dec3398

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

system/lib/wasmfs/syscalls.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,11 @@ static __wasi_fd_t doOpen(path::ParsedParent parsed,
442442
}
443443
} else {
444444
created = backend->createFile(mode);
445+
if (!created) {
446+
// TODO Receive a specific error code, and report it here. For now,
447+
// report a generic error.
448+
return -EIO;
449+
}
445450
bool mounted = lockedParent.mountChild(std::string(childName), created);
446451
assert(mounted);
447452
}
@@ -592,8 +597,18 @@ doMkdir(path::ParsedParent parsed, int mode, backend_t backend = NullBackend) {
592597
std::shared_ptr<File> created;
593598
if (backend == parent->getBackend()) {
594599
created = lockedParent.insertDirectory(childName, mode);
600+
if (!created) {
601+
// TODO Receive a specific error code, and report it here. For now, report
602+
// a generic error.
603+
return -EIO;
604+
}
595605
} else {
596606
created = backend->createDirectory(mode);
607+
if (!created) {
608+
// TODO Receive a specific error code, and report it here. For now, report
609+
// a generic error.
610+
return -EIO;
611+
}
597612
bool mounted = lockedParent.mountChild(childName, created);
598613
assert(mounted);
599614
}

0 commit comments

Comments
 (0)