Fetching directory entries

This commit is contained in:
2025-10-03 19:50:10 +02:00
parent de20efa0f3
commit 443cf0e4ff
6 changed files with 107 additions and 1 deletions

View File

@ -37,6 +37,23 @@ void fs_fetch(void) {
ufree(buf);
ioctl(ioh, IOCTL_CLOSEF, 0, 0, 0);
} else if (statbuf.type == IOCTLSTAT_DIR) {
uprintf("entries = %zu\n", statbuf.size);
IoctlDirent *dirents = (IoctlDirent *)umalloc(statbuf.size * sizeof(*dirents));
for (size_t i = 0; i < statbuf.size; i++) {
ioctl(IOCTL_NOHANDLE, IOCTL_FETCHDIRENT, (uint64_t)path, (uint64_t)&dirents[i], i);
IoctlDirent *dirent = &dirents[i];
char membuf[20];
uprintf("%-30s %-15s %-1s",
dirent->name,
dirent->stat.type == IOCTLSTAT_FILE ? human_size(dirent->stat.size, membuf, 20) : "-",
dirent->stat.type == IOCTLSTAT_FILE ? "F" : "D"
);
uprintf("\n");
}
ufree(dirents);
}
}