diff --git a/kernel/initrd.cpp b/kernel/initrd.cpp index d1d456ab..18100398 100644 --- a/kernel/initrd.cpp +++ b/kernel/initrd.cpp @@ -261,6 +261,42 @@ static bool ExtractDir(struct initrd_context* ctx, initrd_inode_t* inode, Refmode) ) + { + size_t filesize; + uint8_t* data = initrd_inode_get_data(ctx, child, &filesize); + if ( !data ) + return false; + char* dest_path = new char[filesize + 1]; + if ( !dest_path ) + return false; + memcpy(dest_path, data, filesize); + dest_path[filesize] = '\0'; + // TODO: Currently only symbolic links to files inside the same + // directory are supported when converted to hardlinks. + if ( !strchr(dest_path, '/') ) + { + if ( Ref dest = dir->open(&ctx->ioctx, dest_path, O_READ, 0) ) + dir->link(&ctx->ioctx, name, dest); + } + delete[] dest_path; + ctx->amount_extracted += child->size; + initrd_progress(ctx); + } + } + ctx->amount_extracted += inode->size; initrd_progress(ctx); return true;