diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/init/fs/misc.c | 2 | ||||
-rw-r--r-- | src/init/tar.c | 19 |
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 + } } } |