verbose ls + docs #6
@@ -114,6 +114,10 @@ Makes a cow speak!
|
||||
|
||||
Computes Pi up to a couple of digits using the Leibniz series; takes one integer argument, the number of terms of the series to compute.
|
||||
|
||||
#### `bmp <file>`
|
||||
|
||||
Shows information about a 24-bit BMP image and renders it in the terminal.
|
||||
|
||||
### Initrd utilities
|
||||
|
||||
You can browse the (really) simple TAR filesystem with the following commands:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -6,10 +6,16 @@
|
||||
#include "../kernel/initrd.h"
|
||||
#include "../kernel/kmain.h"
|
||||
#include "../libc/stdio.h"
|
||||
#include "../libc/string.h"
|
||||
|
||||
void program_ls()
|
||||
void program_ls(int argc, char* argv[])
|
||||
{
|
||||
ls_initrd((uint8_t*)initrd_addr);
|
||||
if (argc == 1)
|
||||
{
|
||||
ls_initrd((uint8_t*)initrd_addr, 0);
|
||||
} else if (argc == 2 && strcmp(argv[1], "-l") == 0) {
|
||||
ls_initrd((uint8_t*)initrd_addr, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Basic cat just to read, no concatenation here
|
||||
|
||||
Reference in New Issue
Block a user