Skip to content

Commit 4f20a95

Browse files
committed
Replace isVirtualized() with mount-path-based check
1 parent f04892c commit 4f20a95

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

system/lib/wasmfs/backend.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ class Backend {
2121
virtual std::shared_ptr<Directory> createDirectory(mode_t mode) = 0;
2222
virtual std::shared_ptr<Symlink> createSymlink(std::string target) = 0;
2323

24-
virtual bool isVirtualized() { return true; }
24+
// Returns true if this backend is mounted under a path prefix and therefore
25+
// requires path resolution within WasmFS (i.e. paths must be split/traversed).
26+
// Returns false if the backend operates on full paths directly.
27+
virtual bool hasMountPath() { return true; }
2528

2629
virtual ~Backend() = default;
2730
};

system/lib/wasmfs/backends/node_backend.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ class NodeDirectory : public Directory {
183183

184184
private:
185185
std::string getChildPath(const std::string& name) {
186+
// If state.path is empty, this backend represents the real root and paths
187+
// should be passed through unchanged.
186188
if (state.path.empty()) {
187189
return name;
188190
}
@@ -301,7 +303,7 @@ class NodeBackend : public Backend {
301303
WASMFS_UNREACHABLE("TODO: implement NodeBackend::createSymlink");
302304
}
303305

304-
virtual bool isVirtualized() override { return false; }
306+
virtual bool hasMountPath() override { return !mountPath.empty(); }
305307
};
306308

307309
// TODO: symlink

system/lib/wasmfs/paths.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ ParsedParent doParseParent(std::string_view path,
7171

7272
auto root = wasmFS.getRootDirectory();
7373

74-
// If the root backend is not virtualized, we assume there is only a single
75-
// backend, making parent traversal unnecessary. Simply return the current
76-
// directory along with the full path.
77-
if (!root->getBackend()->isVirtualized()) {
74+
// If the root backend has no mount path, it operates on full paths directly.
75+
// In that case, skip WasmFS path traversal and pass the full path through.
76+
if (!root->getBackend()->hasMountPath()) {
7877
return {std::make_pair(std::move(curr), path)};
7978
}
8079

0 commit comments

Comments
 (0)