1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

Add an lstat() syscall and use it to make "ls" nicer.

This commit is contained in:
Andreas Kling 2018-10-24 13:19:36 +02:00
parent bca4b71bfa
commit 5f36a5f22e
10 changed files with 118 additions and 2 deletions

View file

@ -700,13 +700,22 @@ int Task::sys$close(int fd)
return 0;
}
int Task::sys$lstat(const char* path, void* statbuf)
{
auto handle = VirtualFileSystem::the().open(move(path));
if (!handle)
return -1;
handle->stat((Unix::stat*)statbuf);
return 0;
}
int Task::sys$open(const char* path, size_t pathLength)
{
Task::checkSanity("sys$open");
#ifdef DEBUG_IO
kprintf("Task::sys$open(): PID=%u, path=%s {%u}\n", m_pid, path, pathLength);
#endif
auto* handle = current->openFile(String(path, pathLength));
auto* handle = openFile(String(path, pathLength));
if (handle)
return handle->fd();
return -1;