forked from Bananymous/banan-os
Kernel: Add syscall for reading directory entries
This commit is contained in:
parent
f7de310889
commit
7a5d5cabad
|
@ -144,6 +144,14 @@ namespace Kernel
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long sys_read_dir_entries(int fd, API::DirectoryEntryList* buffer, size_t buffer_size)
|
||||||
|
{
|
||||||
|
auto ret = Process::current().read_next_directory_entries(fd, buffer, buffer_size);
|
||||||
|
if (ret.is_error())
|
||||||
|
return -ret.error().get_error_code();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" long sys_fork_trampoline();
|
extern "C" long sys_fork_trampoline();
|
||||||
|
|
||||||
extern "C" long cpp_syscall_handler(int syscall, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
|
extern "C" long cpp_syscall_handler(int syscall, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
|
||||||
|
@ -215,6 +223,9 @@ namespace Kernel
|
||||||
case SYS_SETENVP:
|
case SYS_SETENVP:
|
||||||
ret = sys_setenvp((char**)arg1);
|
ret = sys_setenvp((char**)arg1);
|
||||||
break;
|
break;
|
||||||
|
case SYS_READ_DIR_ENTRIES:
|
||||||
|
ret = sys_read_dir_entries((int)arg1, (API::DirectoryEntryList*)arg2, (size_t)arg3);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Kernel::panic("Unknown syscall {}", syscall);
|
Kernel::panic("Unknown syscall {}", syscall);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ __BEGIN_DECLS
|
||||||
#define SYS_WAIT 17
|
#define SYS_WAIT 17
|
||||||
#define SYS_STAT 18
|
#define SYS_STAT 18
|
||||||
#define SYS_SETENVP 19
|
#define SYS_SETENVP 19
|
||||||
|
#define SYS_READ_DIR_ENTRIES 20
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,14 @@ long syscall(long syscall, ...)
|
||||||
ret = Kernel::syscall(SYS_SETENVP, (uintptr_t)envp);
|
ret = Kernel::syscall(SYS_SETENVP, (uintptr_t)envp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SYS_READ_DIR_ENTRIES:
|
||||||
|
{
|
||||||
|
int fd = va_arg(args, int);
|
||||||
|
void* buffer = va_arg(args, void*);
|
||||||
|
size_t buffer_size = va_arg(args, size_t);
|
||||||
|
ret = Kernel::syscall(SYS_READ_DIR_ENTRIES, fd, (uintptr_t)buffer, buffer_size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
puts("LibC: Unhandeled syscall");
|
puts("LibC: Unhandeled syscall");
|
||||||
ret = -ENOSYS;
|
ret = -ENOSYS;
|
||||||
|
|
Loading…
Reference in New Issue