summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordzwdz2021-11-20 16:28:43 +0100
committerdzwdz2021-11-20 16:28:43 +0100
commit54bb6ae93e92c7ed93e6ae8aa10a136b350e7b72 (patch)
treede501e9ab83e31b0572e804b8af8d03970493069
parentbb1abf9e6eaee879d399ff3dde6cf6baf9caddaa (diff)
init/fs: fix non-prefix fs_passthrough
-rw-r--r--src/init/fs/misc.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c
index f98259f..8c8967c 100644
--- a/src/init/fs/misc.c
+++ b/src/init/fs/misc.c
@@ -76,19 +76,27 @@ void fs_passthru(const char *prefix) {
if (prefix) prefix_len = strlen(prefix);
while (!_syscall_fs_wait(buf, buf_size, &res)) {
- if (prefix && res.op == VFSOP_OPEN) {
- /* the only special case: rewriting the path */
- if (prefix_len + res.len <= buf_size) {
- // TODO memmove
- char tmp[64];
- memcpy(tmp, buf, res.len);
- memcpy(buf, prefix, prefix_len);
- memcpy(buf + prefix_len, tmp, res.len);
- ret = _syscall_open(buf, res.len + prefix_len);
- } else ret = -1;
- _syscall_fs_respond(NULL, ret);
- } else {
- fs_respond_delegate(&res, res.id);
+ switch (res.op) {
+ case VFSOP_OPEN:
+ if (prefix) {
+ /* special case: rewriting the path */
+ if (prefix_len + res.len <= buf_size) {
+ // TODO memmove
+ char tmp[64];
+ memcpy(tmp, buf, res.len);
+ memcpy(buf, prefix, prefix_len);
+ memcpy(buf + prefix_len, tmp, res.len);
+ ret = _syscall_open(buf, res.len + prefix_len);
+ } else ret = -1;
+ } else {
+ ret = _syscall_open(buf, res.len);
+ }
+ _syscall_fs_respond(NULL, ret);
+ break;
+
+ default:
+ fs_respond_delegate(&res, res.id);
+ break;
}
}
_syscall_exit(0);