Minor fixes + docs

This commit is contained in:
xamidev
2024-09-06 21:16:23 +02:00
parent 247558669e
commit cacc042a5c
4 changed files with 26 additions and 6 deletions

View File

@@ -67,15 +67,25 @@ void tar_find_file(uint8_t *tar_start, const char* filename)
printf("[tar] file '%s' not found\n", filename);
}
void ls_initrd(uint8_t* initrd)
void ls_initrd(uint8_t* initrd, int verbose)
{
tar_header_t *header = (tar_header_t*)initrd;
if (verbose)
{
puts("Size Type Filename\n");
}
while (header->filename[0] != '\0')
{
printf("%s\n", header->filename);
uint32_t size = tar_parse_size(header->size);
if (!verbose)
{
printf("%s\n", header->filename);
} else {
printf("%7d\t%c\t %s\n", header->size, header->typeflag, header->filename);
}
uint32_t size = tar_parse_size(header->size);
uint32_t next_file_offset = ((size+TAR_BLOCK_SIZE-1)/TAR_BLOCK_SIZE)*TAR_BLOCK_SIZE;
header = (tar_header_t*)((uint8_t*)header + next_file_offset + TAR_BLOCK_SIZE);
}

View File

@@ -31,7 +31,7 @@ typedef struct
} tar_header_t;
void tar_find_file(uint8_t *tar_start, const char* filename);
void ls_initrd(uint8_t* initrd);
void ls_initrd(uint8_t* initrd, int verbose);
void cat_initrd(uint8_t* initrd, const char* filename);
int tar_file_to_buffer(uint8_t* initrd, const char* filename, char* buffer);