diff options
author | dzwdz | 2022-07-29 16:16:24 +0200 |
---|---|---|
committer | dzwdz | 2022-07-29 16:16:24 +0200 |
commit | c6424fbc55298399f133ca1ede11e1f0b4a5c824 (patch) | |
tree | d8dd1c160a7184a99ea3c72779dce95b4bbee692 /src/user/bootstrap | |
parent | a0b16620e1699504e8d21a481e019dec40d7ee1b (diff) |
use a shared fs_normslice() function to handle offsets
Diffstat (limited to 'src/user/bootstrap')
-rw-r--r-- | src/user/bootstrap/tar.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/user/bootstrap/tar.c b/src/user/bootstrap/tar.c index 75883e6..c690f2c 100644 --- a/src/user/bootstrap/tar.c +++ b/src/user/bootstrap/tar.c @@ -1,5 +1,6 @@ #include "tar.h" #include <camellia/flags.h> +#include <camellia/fsutil.h> #include <camellia/syscalls.h> #include <shared/mem.h> #include <stdint.h> @@ -68,17 +69,17 @@ static void tar_read(struct fs_wait_response *res, void *base, size_t base_len) case '\0': case '0': /* normal files */ size = tar_size(meta); - if (res->offset < 0 || res->offset > size) { - // TODO support negative offsets - _syscall_fs_respond(NULL, -1, 0); - } else { - _syscall_fs_respond(meta + 512 + res->offset, size - res->offset, 0); - } + fs_normslice(&res->offset, &res->len, size, false); + _syscall_fs_respond(meta + 512 + res->offset, res->len, 0); break; case '5': /* directory */ - meta_len = strlen(meta); + if (res->offset < 0) { + _syscall_fs_respond(NULL, -1, 0); + break; + } size_t to_skip = res->offset; + meta_len = strlen(meta); /* find files in dir */ for (size_t off = 0; off < base_len;) { |