Luna/kernel/include/init/InitRD.h
2022-09-05 16:13:51 +02:00

44 lines
1.2 KiB
C++

#pragma once
#define TAR_MAGIC "ustar"
#define TAR_BLOCKSIZE 512
namespace InitRD
{
struct TarHeader
{ /* byte offset */
char name[100]; /* 0 */
char mode[8]; /* 100 */
char uid[8]; /* 108 */
char gid[8]; /* 116 */
char size[12]; /* 124 */
char mtime[12]; /* 136 */
char chksum[8]; /* 148 */
char typeflag; /* 156 */
char linkname[100]; /* 157 */
char magic[6]; /* 257 */
char version[2]; /* 263 */
char uname[32]; /* 265 */
char gname[32]; /* 297 */
char devmajor[8]; /* 329 */
char devminor[8]; /* 337 */
char prefix[155]; /* 345 */
/* 500 */
} __attribute__((packed));
struct File
{
char name[100];
int size;
int size_in_blocks;
void* addr;
};
int get_total_blocks();
File get_file(TarHeader* header);
TarHeader* get_block(int block_index);
bool is_valid_header(TarHeader* header);
File find_file(const char* filename);
void for_each(void (*callback)(File& file));
}