summaryrefslogtreecommitdiff
path: root/src/init
diff options
context:
space:
mode:
authordzwdz2022-05-01 19:25:22 +0200
committerdzwdz2022-05-01 19:25:22 +0200
commit7c62817193517f298bc566f3803c00d53a9a2b94 (patch)
tree8d6b95059e5f89be239e303ae53c847c88edea72 /src/init
parent681e6b45b6f22f30d29745fa9a400558fe6dada5 (diff)
init/fs: make directory listings respect offsets
Diffstat (limited to 'src/init')
-rw-r--r--src/init/fs/misc.c2
-rw-r--r--src/init/tar.c19
2 files changed, 15 insertions, 6 deletions
diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c
index f140910..64e3664 100644
--- a/src/init/fs/misc.c
+++ b/src/init/fs/misc.c
@@ -145,7 +145,7 @@ void fs_dir_inject(const char *path) {
case VFSOP_READ:
if (handles[res.id].inject) {
- // TODO check offset
+ if (res.offset > 0) _syscall_fs_respond(NULL, 0); // TODO working offsets
struct fs_dir_handle h = handles[res.id];
int out_len = 0;
diff --git a/src/init/tar.c b/src/init/tar.c
index 1f1c42e..c289edc 100644
--- a/src/init/tar.c
+++ b/src/init/tar.c
@@ -79,6 +79,7 @@ static void tar_read(struct fs_wait_response *res, void *base, size_t base_len)
case '5': /* directory */
meta_len = strlen(meta);
+ size_t to_skip = res->offset;
/* find files in dir */
for (size_t off = 0; off < base_len;) {
@@ -97,11 +98,19 @@ static void tar_read(struct fs_wait_response *res, void *base, size_t base_len)
while (*next && *next != '/') next++;
if (*next == '/') next++;
if (*next == '\0') {
- /* it doesn't - so let's add it to the result */
- memcpy(buf + buf_pos, suffix, suffix_len);
- buf[buf_pos + suffix_len] = '\0';
- buf_pos += suffix_len + 1;
- // TODO no buffer overrun check
+ if (to_skip > suffix_len) {
+ to_skip -= suffix_len;
+ } else {
+ suffix += to_skip;
+ suffix_len -= to_skip;
+ to_skip = 0;
+
+ /* it doesn't - so let's add it to the result */
+ memcpy(buf + buf_pos, suffix, suffix_len);
+ buf[buf_pos + suffix_len] = '\0';
+ buf_pos += suffix_len + 1;
+ // TODO no buffer overrun check
+ }
}
}