diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-24 14:28:22 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-24 14:28:22 +0200 |
commit | ec1d16b307e1467391d5d314bf700cb151ca96f4 (patch) | |
tree | 0d30ef8436f114ff0fb78e71cc6aa9e4711f6266 /VirtualFileSystem | |
parent | eb4074bb9dd9c38d6bc7f67f382bac288c630686 (diff) | |
download | serenity-ec1d16b307e1467391d5d314bf700cb151ca96f4.zip |
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().
Diffstat (limited to 'VirtualFileSystem')
-rw-r--r-- | VirtualFileSystem/FileHandle.cpp | 3 | ||||
-rw-r--r-- | VirtualFileSystem/FileHandle.h | 2 | ||||
-rw-r--r-- | VirtualFileSystem/InodeIdentifier.h | 5 | ||||
-rw-r--r-- | VirtualFileSystem/VirtualFileSystem.h | 1 |
4 files changed, 11 insertions, 0 deletions
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<bool(const FileSystem::DirectoryEntry&)>); + String absolutePath(InodeIdentifier); InodeIdentifier resolvePath(const String& path); InodeIdentifier resolveSymbolicLink(const String& basePath, InodeIdentifier symlinkInode); |