diff --git a/fs/vfs/initcpio.c b/fs/vfs/initcpio.c index 2b689ca..6444f80 100644 --- a/fs/vfs/initcpio.c +++ b/fs/vfs/initcpio.c @@ -53,7 +53,7 @@ static ssize_t read_next(fs_t *fs, const char *file, rbtree_t *list, dirent_t ** return -ENAMETOOLONG; const char *cursor = file + sizeof(struct cpio_newc_header); - size_t data_offset = sizeof(struct cpio_newc_header) + ALIGN_UP(name_len, 4); + size_t data_offset = ALIGN_UP(sizeof(struct cpio_newc_header) + name_len, 4); if (!strncmp(cursor, "./", 2)) { cursor += 2; @@ -66,6 +66,10 @@ static ssize_t read_next(fs_t *fs, const char *file, rbtree_t *list, dirent_t ** memcpy(name, cursor, name_len); cursor = file + data_offset; + if(file_len == 0 && !strcmp(name, CPIO_TRAILER)) { + return 0; + } + char *parent_path = dirname(name); char *leaf = basename(name);