tar_list
This commit is contained in:
@@ -13,5 +13,6 @@ int initfs_init(struct limine_file* tar_file);
|
||||
int tar_lookup(unsigned char* archive, char* filename, char** out);
|
||||
int tar_exists(const char* filename);
|
||||
int tar_read(char* filename, char* out, int count, int offset);
|
||||
void tar_list();
|
||||
|
||||
#endif
|
||||
@@ -59,6 +59,22 @@ int tar_lookup(unsigned char* archive, char* filename, char** out)
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/*
|
||||
* tar_list - list all files present in archive
|
||||
*/
|
||||
void tar_list()
|
||||
{
|
||||
printf("++ Contents of initial filesystem ++\r\n\r\n");
|
||||
unsigned char *ptr = archive_start_addr;
|
||||
|
||||
while (!memcmp(ptr + 257, "ustar", 5)) {
|
||||
int filesize = tar_oct2bin(ptr + 0x7c, 11);
|
||||
char* filename = (char*)ptr;
|
||||
printf("file: %s\r\n", filename);
|
||||
ptr += (((filesize + 511) / 512) + 1) * 512;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* tar_read - read a file in the TAR archive
|
||||
* @filename: file to read (absolute path)
|
||||
|
||||
+16
-11
@@ -4,6 +4,7 @@
|
||||
* @license GPL-3.0-only
|
||||
*/
|
||||
|
||||
#include "fs/initfs.h"
|
||||
#include <io/term/term.h>
|
||||
#include <config.h>
|
||||
#include <io/kbd/ps2.h>
|
||||
@@ -42,17 +43,16 @@ void pedicel_main(void* arg)
|
||||
keyboard_getline(input_buf, PEDICEL_INPUT_SIZE);
|
||||
|
||||
if (strncmp(input_buf, "help", 4) == 0) {
|
||||
printf("\r\nYou are currently running the test kernel shell. This is not\r\n"
|
||||
"a fully-fledged shell like you'd find in a complete operating system,\r\n"
|
||||
"but rather a toy to play around in the meantime.\r\n\r\n"
|
||||
"clear - clear the screen\r\n"
|
||||
"panic - trigger a test panic\r\n"
|
||||
"syscall - trigger int 0x80\r\n"
|
||||
"pf - trigger a page fault\r\n"
|
||||
"now - get current date\r\n"
|
||||
"smash - smash the stack\r\n"
|
||||
"mem - get used heap info\r\n"
|
||||
"load - load an user executable\r\n");
|
||||
printf("++ shell builtins ++\r\n\r\n"
|
||||
"\tclear - clear the screen\r\n"
|
||||
"\tpanic - trigger a test panic\r\n"
|
||||
"\tsyscall - trigger int 0x80\r\n"
|
||||
"\tpf - trigger a page fault\r\n"
|
||||
"\tnow - get current date\r\n"
|
||||
"\tsmash - smash the stack\r\n"
|
||||
"\tmem - get used heap info\r\n"
|
||||
"\tload - load an user executable\r\n"
|
||||
"\tlist - list initfs.tar contents\r\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -102,6 +102,11 @@ void pedicel_main(void* arg)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(input_buf, "list", 4) == 0) {
|
||||
tar_list();
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("%s: command not found\r\n", input_buf);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user