From ec1d16b307e1467391d5d314bf700cb151ca96f4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 24 Oct 2018 14:28:22 +0200 Subject: Add a "pwd" utility to userland. It's implemented as a separate process. How cute is that. Tasks now have a current working directory. Spawned tasks inherit their parent task's working directory. Currently everyone just uses "/" as there's no way to chdir(). --- VirtualFileSystem/FileHandle.cpp | 3 +++ VirtualFileSystem/FileHandle.h | 2 ++ VirtualFileSystem/InodeIdentifier.h | 5 +++++ VirtualFileSystem/VirtualFileSystem.h | 1 + 4 files changed, 11 insertions(+) (limited to 'VirtualFileSystem') diff --git a/VirtualFileSystem/FileHandle.cpp b/VirtualFileSystem/FileHandle.cpp index 90c0beade2..172fe74cf5 100644 --- a/VirtualFileSystem/FileHandle.cpp +++ b/VirtualFileSystem/FileHandle.cpp @@ -142,6 +142,9 @@ ssize_t FileHandle::get_dir_entries(byte* buffer, size_t size) return true; }); + if (size < stream.offset()) + return -1; + memcpy(buffer, tempBuffer.pointer(), stream.offset()); return stream.offset(); } diff --git a/VirtualFileSystem/FileHandle.h b/VirtualFileSystem/FileHandle.h index f75d88895c..0aa23b93dd 100644 --- a/VirtualFileSystem/FileHandle.h +++ b/VirtualFileSystem/FileHandle.h @@ -16,6 +16,8 @@ public: ByteBuffer readEntireFile(); + String absolutePath() const; + #ifdef SERENITY int fd() const { return m_fd; } void setFD(int fd) { m_fd = fd; } diff --git a/VirtualFileSystem/InodeIdentifier.h b/VirtualFileSystem/InodeIdentifier.h index 865b07f838..d985266ec6 100644 --- a/VirtualFileSystem/InodeIdentifier.h +++ b/VirtualFileSystem/InodeIdentifier.h @@ -28,6 +28,11 @@ public: return m_fileSystemID == other.m_fileSystemID && m_index == other.m_index; } + bool operator!=(const InodeIdentifier& other) const + { + return m_fileSystemID != other.m_fileSystemID || m_index != other.m_index; + } + InodeMetadata metadata() const; bool isRootInode() const; diff --git a/VirtualFileSystem/VirtualFileSystem.h b/VirtualFileSystem/VirtualFileSystem.h index bafb791d9f..53e8fcb4a1 100644 --- a/VirtualFileSystem/VirtualFileSystem.h +++ b/VirtualFileSystem/VirtualFileSystem.h @@ -78,6 +78,7 @@ private: friend class FileHandle; void enumerateDirectoryInode(InodeIdentifier, Function); + String absolutePath(InodeIdentifier); InodeIdentifier resolvePath(const String& path); InodeIdentifier resolveSymbolicLink(const String& basePath, InodeIdentifier symlinkInode); -- cgit v1.2.3