Prevent ls from running on files

This commit is contained in:
Ali Mashtizadeh 2023-10-01 20:47:09 -04:00
parent 64818e1337
commit 21a30db5d3
2 changed files with 7 additions and 4 deletions

View File

@ -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);

View File

@ -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