Skip to content

Commit

Permalink
Added tarball reading!
Browse files Browse the repository at this point in the history
  • Loading branch information
pradosh-arduino committed Dec 30, 2023
1 parent e634ab8 commit ffef81a
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ all:
@cp -v \
source/wing_kernel.elf \
source/boot/limine.cfg \
source/boot/test-icon.tga \
source/boot/init_ramdisk.tar \
limine/limine-bios.sys \
limine/limine-bios-pxe.bin \
limine/limine-bios-cd.bin \
Expand Down
Binary file added source/boot/init_ramdisk.tar
Binary file not shown.
4 changes: 2 additions & 2 deletions source/boot/limine.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TERM_FONT=boot:///iso.f16

# Path to the kernel to boot. boot:/// represents the partition on which limine.cfg is located.
KERNEL_PATH=${WING_KERNEL}
MODULE_PATH=boot:///test-icon.tga
MODULE_PATH=boot:///init_ramdisk.tar

# Same thing, but without KASLR.
:FrostWing
Expand All @@ -32,4 +32,4 @@ TERM_FONT=boot:///iso.f16
KASLR=no

KERNEL_PATH=${WING_KERNEL}
MODULE_PATH=boot:///test-icon.tga
MODULE_PATH=boot:///init_ramdisk.tar
34 changes: 34 additions & 0 deletions source/includes/archive/tarball.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @file tarball.h
* @author Pradosh ([email protected])
* @brief
* @version 0.1
* @date 2023-12-30
*
* @copyright Copyright (c) Pradosh 2023
*
*/
#include <basics.h>

#define block_size 512

struct tarball_header {
char name[100];
char mode[8];
char owner[8];
char group[8];
char size[12];
char mtime[12];
char checksum[8];
char type;
char linkname[100];
char magic[6];
char version[2];
char owner_name[32];
char group_name[32];
char dev_major[8];
char dev_minor[8];
char prefix[155];
};

void extract_tarball(int64* tarball_addr);
43 changes: 43 additions & 0 deletions source/kernel/C/archive/tarball.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @file tarball.c
* @author Pradosh ([email protected])
* @brief
* @version 0.1
* @date 2023-12-30
*
* @copyright Copyright (c) Pradosh 2023
*
*/
#include <archive/tarball.h>

char* filenames[2 KiB];
char* file_datas[2 KiB];

int counter;

void extract_tarball(int64* tarball_addr) {
uintptr_t addr = (uintptr_t)tarball_addr;

while (1) {
if(counter >= 2 KiB){
error("You reached number of file limits of 2 KiB!", __FILE__);
break;
}
struct tarball_header *header = (struct tar_header *)addr;

if (header->name[0] == '\0') {
break;
}

unsigned int size = strtol(header->size, NULL, 8);

char *filename = header->name;
char *contents = (char *)(addr + block_size);

filenames[counter] = filename;
file_datas[counter] = file_datas;

addr += block_size + ((size + block_size - 1) / block_size) * block_size;
counter++;
}
}
2 changes: 1 addition & 1 deletion source/kernel/C/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void main(void) {
// list_clear(&my_list);
// printf("list size: %d", my_list.size);

// extract_tarball(module_request.response->modules[1]->address);
extract_tarball(module_request.response->modules[0]->address);

// decode_targa_image(module_request.response->modules[0]->address, (uvec2){500, 100});

Expand Down

0 comments on commit ffef81a

Please sign in to comment.