diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 9ae4682..3ca56d7 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -35,8 +35,8 @@ main(int argc, const char *argv[]) break; } if (status < 0) { - fputs("Error\n", stdout); - break; + printf("OSReadDir Error: %x\n", -status); + return 1; } printf("%s\n", de.d_name); diff --git a/sys/fs/o2fs/o2fs.c b/sys/fs/o2fs/o2fs.c index d3074e7..209af02 100644 --- a/sys/fs/o2fs/o2fs.c +++ b/sys/fs/o2fs/o2fs.c @@ -364,8 +364,11 @@ O2FS_ReadDir(VNode *fn, void *buf, uint64_t len, uint64_t *off) status = O2FS_Read(fn, &dirEntry, *off, sizeof(dirEntry)); if (status != sizeof(dirEntry)) { - kprintf("Unexpected error reading directory: %d", status); - return status; + kprintf("Unexpected error reading directory: %d\n", status); + return -ENOTDIR; + } + if (strncmp((char *)&dirEntry.magic[0], BDIR_MAGIC, sizeof(dirEntry.magic)) != 0) { + return -ENOTDIR; } // XXX: Validation and fill in all fields