Made 'ls' real and not just a bunch of hardcoded printf calls

This commit is contained in:
2024-08-16 08:19:01 +02:00
parent 3134c6196e
commit 1257ecc1cc
3 changed files with 26 additions and 11 deletions
BIN
View File
Binary file not shown.
+23 -10
View File
@@ -316,16 +316,29 @@ void main() {
}
void listFiles() {
// TODO: Make this real
printf("Total 8\n");
printf(". [dir]\n");
printf(".. [dir]\n");
printf("stage3.bin 2868B\n");
printf("kernel.bin 13536B\n");
printf("testfont.fnt 2048B\n");
printf("term16n.fnt 2048B\n");
printf("calc.bin 1724B\n");
printf("editor.bin 1280B\n");
inode_t* root = (inode_t*)impl_superblock->rootInodePtr;
diskRead(root->extent[0].block * 8, root->extent[0].length * 8, (void*)SCRATCH_BLOCK_LOC);
dirEntry_t* dentry = (dirEntry_t*)SCRATCH_BLOCK_LOC;
uint32_t total = 0;
while ((dentry + total)->name[0] != '\0') { total++; }
putc(' '); // TODO
printf("\bTotal %d\n", total);
while (dentry->name[0] != '\0') {
inode_t* inode = (inode_t*)BOOT_FIRST_INODE_LOC + dentry->id;
printf("%s", dentry->name);
for (uint32_t pad = (16 - strlen(dentry->name)); pad > 0; pad--) { putc(' '); }
switch (inode->type) {
case FT_FILE: printf("%dB\n", inode->sizeBytes); break;
case FT_DIR: printf("[dir]\n"); break;
}
dentry++;
}
}
void printRegs() {
+3 -1
View File
@@ -100,6 +100,8 @@ Legend:
- [x] Malloc()
- [x] Free()
- [ ] Seek()
- [ ] Tell()
- [ ] Exit()
- [ ] Shell
- [ ] Separate file/program
- [ ] ';' separated commands
@@ -122,7 +124,7 @@ Legend:
- [ ] cd
- [ ] Standard I/O stuff
- [ ] stdin
- [ ] stdout
- [x] stdout
- [ ] stderr
- [x] Memory manager
- [x] Memory map