Luna/kernel/include/init/InitRD.h

52 lines
1.3 KiB
C
Raw Normal View History

2022-09-05 14:13:51 +00:00
#pragma once
2022-09-23 14:41:43 +00:00
#include <stdint.h>
2022-09-05 14:13:51 +00:00
#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];
2022-10-06 15:13:34 +00:00
uint64_t size;
uint64_t size_in_blocks;
2022-09-05 14:13:51 +00:00
void* addr;
};
2022-10-06 15:13:34 +00:00
uint64_t get_total_blocks();
2022-09-05 14:13:51 +00:00
File get_file(TarHeader* header);
2022-09-10 20:15:19 +00:00
void free_file(File& file);
2022-10-06 15:13:34 +00:00
TarHeader* get_block(uint64_t block_index);
2022-09-05 14:13:51 +00:00
bool is_valid_header(TarHeader* header);
2022-09-23 14:41:43 +00:00
uint64_t get_file_physical_address(File& file);
2022-09-10 20:15:19 +00:00
File open(const char* filename);
2022-09-05 14:13:51 +00:00
void for_each(void (*callback)(File& file));
2022-09-19 15:06:08 +00:00
bool is_initialized();
2022-09-19 15:06:08 +00:00
void init();
2022-09-05 14:13:51 +00:00
}