From 5f36a5f22e8bf0e9de9a8059722352d2f8cf9b5f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 24 Oct 2018 13:19:36 +0200 Subject: Add an lstat() syscall and use it to make "ls" nicer. --- Kernel/Syscall.cpp | 2 ++ Kernel/Syscall.h | 1 + Kernel/Task.cpp | 11 ++++++++++- Kernel/Task.h | 1 + Kernel/VGA.cpp | 1 + Kernel/_fs_contents | Bin 1024000 -> 1024000 bytes 6 files changed, 15 insertions(+), 1 deletion(-) (limited to 'Kernel') diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index 4be04cbfac..846c1b99ea 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -68,6 +68,8 @@ DWORD handle(DWORD function, DWORD arg1, DWORD arg2, DWORD arg3) return current->sys$spawn((const char*)arg1); case Syscall::GetDirEntries: return current->sys$get_dir_entries((int)arg1, (void*)arg2, (size_t)arg3); + case Syscall::PosixLstat: + return current->sys$lstat((const char*)arg1, (void*)arg2); case Syscall::PosixOpen: //kprintf("syscall: open('%s', %u)\n", arg1, arg2); return current->sys$open((const char*)arg1, (size_t)arg2); diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index 70b3f12983..ff0b8af69e 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -27,6 +27,7 @@ enum Function { PosixMmap = 0x1995, PosixMunmap = 0x1996, GetDirEntries = 0x1997, + PosixLstat = 0x1998, }; void initialize(); diff --git a/Kernel/Task.cpp b/Kernel/Task.cpp index fe185cc154..7005394ee5 100644 --- a/Kernel/Task.cpp +++ b/Kernel/Task.cpp @@ -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; diff --git a/Kernel/Task.h b/Kernel/Task.h index 8ff28a00ed..c7ca13eeb4 100644 --- a/Kernel/Task.h +++ b/Kernel/Task.h @@ -92,6 +92,7 @@ public: int sys$open(const char* path, size_t pathLength); int sys$close(int fd); int sys$read(int fd, void* outbuf, size_t nread); + int sys$lstat(const char*, void* statbuf); int sys$seek(int fd, int offset); int sys$kill(pid_t pid, int sig); int sys$geterror() { return m_error; } diff --git a/Kernel/VGA.cpp b/Kernel/VGA.cpp index 458a3c967c..59e3c73267 100644 --- a/Kernel/VGA.cpp +++ b/Kernel/VGA.cpp @@ -10,6 +10,7 @@ PRIVATE BYTE current_attr = 0x07; void vga_scroll_up() { + InterruptDisabler disabler; memcpy(vga_mem, vga_mem + 160, 160 * 24); memset(vga_mem + (160 * 24), 0, 160); } diff --git a/Kernel/_fs_contents b/Kernel/_fs_contents index 25f45186bf..7aacb359bb 100644 Binary files a/Kernel/_fs_contents and b/Kernel/_fs_contents differ -- cgit v1.2.3