initial commit

This commit is contained in:
2025-03-11 05:17:34 +08:00
commit e906741ee9
27 changed files with 924 additions and 0 deletions

46
include/initrd.h Normal file
View File

@@ -0,0 +1,46 @@
#pragma once
#include <stddef.h>
typedef struct {
char c_magic[6];
char c_ino[8];
char c_mode[8];
char c_uid[8];
char c_gid[8];
char c_nlink[8];
char c_mtime[8];
char c_filesize[8];
char c_devmajor[8];
char c_devminor[8];
char c_rdevmajor[8];
char c_rdevminor[8];
char c_namesize[8];
char c_check[8];
}__attribute__((packed)) cpio_newc_header_t;
typedef struct file_node {
struct file_node *l, *r;
int rand;
int node_size;
int ino;
int mode;
int uid;
int gid;
int nlink;
int mtime;
int filesize;
int devmajor;
int devminor;
int rdevmajor;
int rdevminor;
int namesize;
char *filename;
byte_t *filecontent;
} file_node_t;
file_node_t *initrd_init(void);
int initrd_ls(void);
file_node_t *initrd_get(file_node_t *root, const char *filename);