Break ioctl() up into smaller syscalls

This commit is contained in:
2025-10-14 20:05:41 +02:00
parent c34a253d11
commit 406434fed0
21 changed files with 375 additions and 320 deletions

View File

@ -5,8 +5,8 @@
int showtree(char *root, int indent) {
#define INDENT() for (size_t i = 0; i < indent; i++) uprintf(" ")
IoctlStat statbuf; ZERO(&statbuf);
if (ioctl(IOCTL_NOHANDLE, IOCTL_STAT, (uint64_t)&statbuf, (uint64_t)root, 0) != E_OK) {
FsStat statbuf; ZERO(&statbuf);
if (fs_stat(root, &statbuf) != E_OK) {
uprintf("fs: could not stat %s\n", root);
return -1;
}
@ -18,16 +18,16 @@ int showtree(char *root, int indent) {
}
if (statbuf.type == IOCTLSTAT_FILE) {
if (statbuf.type == FSSTAT_FILE) {
return 0;
}
if (statbuf.type == IOCTLSTAT_DIR) {
IoctlDirent *dirents = (IoctlDirent *)umalloc(statbuf.size * sizeof(*dirents));
if (statbuf.type == FSSTAT_DIR) {
FsDirent *dirents = (FsDirent *)umalloc(statbuf.size * sizeof(*dirents));
for (size_t i = 0; i < statbuf.size; i++) {
ioctl(IOCTL_NOHANDLE, IOCTL_FETCHDIRENT, (uint64_t)root, (uint64_t)&dirents[i], i);
fs_fetchdirent(root, &dirents[i], i);
IoctlDirent *dirent = &dirents[i];
FsDirent *dirent = &dirents[i];
if (string_strcmp(dirent->name, ".") == 0 || string_strcmp(dirent->name, "..") == 0) {
continue;