summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-07 09:36:51 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-07 09:36:51 +0200
commit08cd75ac4baa2814bb6154c3ad127957b3b03b7c (patch)
tree87d8bcc40d4bd536c02cbef49c91e5520a44594a /Kernel
parent69a6ce90df7e0f074a714e0938cfd526076e38a3 (diff)
downloadserenity-08cd75ac4baa2814bb6154c3ad127957b3b03b7c.zip
Kernel: Rename FileDescriptor to FileDescription.
After reading a bunch of POSIX specs, I've learned that a file descriptor is the number that refers to a file description, not the description itself. So this patch renames FileDescriptor to FileDescription, and Process now has FileDescription* file_description(int fd).
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Console.cpp6
-rw-r--r--Kernel/Console.h8
-rw-r--r--Kernel/Devices/BXVGADevice.cpp12
-rw-r--r--Kernel/Devices/BXVGADevice.h12
-rw-r--r--Kernel/Devices/DebugLogDevice.cpp2
-rw-r--r--Kernel/Devices/DebugLogDevice.h8
-rw-r--r--Kernel/Devices/Device.cpp2
-rw-r--r--Kernel/Devices/Device.h2
-rw-r--r--Kernel/Devices/FullDevice.cpp6
-rw-r--r--Kernel/Devices/FullDevice.h8
-rw-r--r--Kernel/Devices/KeyboardDevice.cpp6
-rw-r--r--Kernel/Devices/KeyboardDevice.h8
-rw-r--r--Kernel/Devices/NullDevice.cpp6
-rw-r--r--Kernel/Devices/NullDevice.h8
-rw-r--r--Kernel/Devices/PS2MouseDevice.cpp6
-rw-r--r--Kernel/Devices/PS2MouseDevice.h8
-rw-r--r--Kernel/Devices/RandomDevice.cpp6
-rw-r--r--Kernel/Devices/RandomDevice.h8
-rw-r--r--Kernel/Devices/ZeroDevice.cpp6
-rw-r--r--Kernel/Devices/ZeroDevice.h8
-rw-r--r--Kernel/File.cpp10
-rw-r--r--Kernel/File.h20
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp4
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.h4
-rw-r--r--Kernel/FileSystem/FIFO.cpp16
-rw-r--r--Kernel/FileSystem/FIFO.h14
-rw-r--r--Kernel/FileSystem/FileDescription.cpp (renamed from Kernel/FileSystem/FileDescriptor.cpp)88
-rw-r--r--Kernel/FileSystem/FileDescription.h (renamed from Kernel/FileSystem/FileDescriptor.h)14
-rw-r--r--Kernel/FileSystem/FileSystem.h2
-rw-r--r--Kernel/FileSystem/Inode.cpp2
-rw-r--r--Kernel/FileSystem/Inode.h8
-rw-r--r--Kernel/FileSystem/InodeFile.cpp10
-rw-r--r--Kernel/FileSystem/InodeFile.h12
-rw-r--r--Kernel/FileSystem/ProcFS.cpp14
-rw-r--r--Kernel/FileSystem/ProcFS.h4
-rw-r--r--Kernel/FileSystem/SyntheticFileSystem.cpp6
-rw-r--r--Kernel/FileSystem/SyntheticFileSystem.h4
-rw-r--r--Kernel/FileSystem/VirtualFileSystem.cpp10
-rw-r--r--Kernel/FileSystem/VirtualFileSystem.h10
-rw-r--r--Kernel/KSyms.cpp2
-rw-r--r--Kernel/Makefile2
-rw-r--r--Kernel/Net/IPv4Socket.cpp20
-rw-r--r--Kernel/Net/IPv4Socket.h20
-rw-r--r--Kernel/Net/LocalSocket.cpp22
-rw-r--r--Kernel/Net/LocalSocket.h24
-rw-r--r--Kernel/Net/Socket.cpp4
-rw-r--r--Kernel/Net/Socket.h14
-rw-r--r--Kernel/Net/TCPSocket.cpp2
-rw-r--r--Kernel/Net/TCPSocket.h2
-rw-r--r--Kernel/Net/UDPSocket.h2
-rw-r--r--Kernel/Process.cpp84
-rw-r--r--Kernel/Process.h18
-rw-r--r--Kernel/ProcessTracer.cpp4
-rw-r--r--Kernel/ProcessTracer.h10
-rw-r--r--Kernel/Scheduler.cpp2
-rw-r--r--Kernel/SharedMemory.cpp8
-rw-r--r--Kernel/SharedMemory.h12
-rw-r--r--Kernel/TTY/MasterPTY.cpp14
-rw-r--r--Kernel/TTY/MasterPTY.h10
-rw-r--r--Kernel/TTY/PTYMultiplexer.cpp6
-rw-r--r--Kernel/TTY/PTYMultiplexer.h10
-rw-r--r--Kernel/TTY/SlavePTY.cpp6
-rw-r--r--Kernel/TTY/SlavePTY.h6
-rw-r--r--Kernel/TTY/TTY.cpp10
-rw-r--r--Kernel/TTY/TTY.h12
-rw-r--r--Kernel/Thread.cpp6
-rw-r--r--Kernel/Thread.h8
67 files changed, 364 insertions, 364 deletions
diff --git a/Kernel/Console.cpp b/Kernel/Console.cpp
index 394270a785..5ee1048557 100644
--- a/Kernel/Console.cpp
+++ b/Kernel/Console.cpp
@@ -23,19 +23,19 @@ Console::~Console()
{
}
-bool Console::can_read(FileDescriptor&) const
+bool Console::can_read(FileDescription&) const
{
return false;
}
-ssize_t Console::read(FileDescriptor&, byte*, ssize_t)
+ssize_t Console::read(FileDescription&, byte*, ssize_t)
{
// FIXME: Implement reading from the console.
// Maybe we could use a ring buffer for this device?
return 0;
}
-ssize_t Console::write(FileDescriptor&, const byte* data, ssize_t size)
+ssize_t Console::write(FileDescription&, const byte* data, ssize_t size)
{
if (!size)
return 0;
diff --git a/Kernel/Console.h b/Kernel/Console.h
index 59fe006c4e..e1f4e2d2a3 100644
--- a/Kernel/Console.h
+++ b/Kernel/Console.h
@@ -19,10 +19,10 @@ public:
virtual ~Console() override;
// ^CharacterDevice
- virtual bool can_read(FileDescriptor&) const override;
- virtual bool can_write(FileDescriptor&) const override { return true; }
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual bool can_write(FileDescription&) const override { return true; }
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
virtual const char* class_name() const override { return "Console"; }
void set_implementation(ConsoleImplementation* implementation) { m_implementation = implementation; }
diff --git a/Kernel/Devices/BXVGADevice.cpp b/Kernel/Devices/BXVGADevice.cpp
index e4b2d4c356..e8ad647c32 100644
--- a/Kernel/Devices/BXVGADevice.cpp
+++ b/Kernel/Devices/BXVGADevice.cpp
@@ -84,7 +84,7 @@ dword BXVGADevice::find_framebuffer_address()
return framebuffer_address;
}
-KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescriptor&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot)
+KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescription&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot)
{
ASSERT(offset == 0);
ASSERT(size == framebuffer_size_in_bytes());
@@ -104,7 +104,7 @@ KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescriptor&, LinearAd
return region;
}
-int BXVGADevice::ioctl(FileDescriptor&, unsigned request, unsigned arg)
+int BXVGADevice::ioctl(FileDescription&, unsigned request, unsigned arg)
{
switch (request) {
case BXVGA_DEV_IOCTL_SET_Y_OFFSET:
@@ -124,22 +124,22 @@ int BXVGADevice::ioctl(FileDescriptor&, unsigned request, unsigned arg)
};
}
-bool BXVGADevice::can_read(FileDescriptor&) const
+bool BXVGADevice::can_read(FileDescription&) const
{
ASSERT_NOT_REACHED();
}
-bool BXVGADevice::can_write(FileDescriptor&) const
+bool BXVGADevice::can_write(FileDescription&) const
{
ASSERT_NOT_REACHED();
}
-ssize_t BXVGADevice::read(FileDescriptor&, byte*, ssize_t)
+ssize_t BXVGADevice::read(FileDescription&, byte*, ssize_t)
{
ASSERT_NOT_REACHED();
}
-ssize_t BXVGADevice::write(FileDescriptor&, const byte*, ssize_t)
+ssize_t BXVGADevice::write(FileDescription&, const byte*, ssize_t)
{
ASSERT_NOT_REACHED();
}
diff --git a/Kernel/Devices/BXVGADevice.h b/Kernel/Devices/BXVGADevice.h
index 2270a41a9f..ac8b6f4fa8 100644
--- a/Kernel/Devices/BXVGADevice.h
+++ b/Kernel/Devices/BXVGADevice.h
@@ -17,18 +17,18 @@ public:
void set_resolution(int width, int height);
void set_y_offset(int);
- virtual int ioctl(FileDescriptor&, unsigned request, unsigned arg) override;
- virtual KResultOr<Region*> mmap(Process&, FileDescriptor&, LinearAddress preferred_laddr, size_t offset, size_t, int prot) override;
+ virtual int ioctl(FileDescription&, unsigned request, unsigned arg) override;
+ virtual KResultOr<Region*> mmap(Process&, FileDescription&, LinearAddress preferred_laddr, size_t offset, size_t, int prot) override;
size_t framebuffer_size_in_bytes() const { return m_framebuffer_size.area() * sizeof(dword) * 2; }
Size framebuffer_size() const { return m_framebuffer_size; }
private:
virtual const char* class_name() const override { return "BXVGA"; }
- virtual bool can_read(FileDescriptor&) const override;
- virtual bool can_write(FileDescriptor&) const override;
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual bool can_write(FileDescription&) const override;
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
void set_register(word index, word value);
dword find_framebuffer_address();
diff --git a/Kernel/Devices/DebugLogDevice.cpp b/Kernel/Devices/DebugLogDevice.cpp
index daa879ffb1..838101dda4 100644
--- a/Kernel/Devices/DebugLogDevice.cpp
+++ b/Kernel/Devices/DebugLogDevice.cpp
@@ -19,7 +19,7 @@ DebugLogDevice::~DebugLogDevice()
{
}
-ssize_t DebugLogDevice::write(FileDescriptor&, const byte* data, ssize_t data_size)
+ssize_t DebugLogDevice::write(FileDescription&, const byte* data, ssize_t data_size)
{
for (int i = 0; i < data_size; ++i)
IO::out8(0xe9, data[i]);
diff --git a/Kernel/Devices/DebugLogDevice.h b/Kernel/Devices/DebugLogDevice.h
index 9b09205074..2ef4ade046 100644
--- a/Kernel/Devices/DebugLogDevice.h
+++ b/Kernel/Devices/DebugLogDevice.h
@@ -9,9 +9,9 @@ public:
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override { return 0; }
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual bool can_write(FileDescriptor&) const override { return true; }
- virtual bool can_read(FileDescriptor&) const override { return true; }
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override { return 0; }
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual bool can_write(FileDescription&) const override { return true; }
+ virtual bool can_read(FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "DebugLogDevice"; }
};
diff --git a/Kernel/Devices/Device.cpp b/Kernel/Devices/Device.cpp
index fe3c28f01f..24a5274456 100644
--- a/Kernel/Devices/Device.cpp
+++ b/Kernel/Devices/Device.cpp
@@ -14,7 +14,7 @@ Device::~Device()
VFS::the().unregister_device({}, *this);
}
-String Device::absolute_path(const FileDescriptor&) const
+String Device::absolute_path(const FileDescription&) const
{
return String::format("device:%u,%u (%s)", m_major, m_minor, class_name());
}
diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h
index 7c19a9fea9..3b2256cf64 100644
--- a/Kernel/Devices/Device.h
+++ b/Kernel/Devices/Device.h
@@ -19,7 +19,7 @@ public:
unsigned major() const { return m_major; }
unsigned minor() const { return m_minor; }
- virtual String absolute_path(const FileDescriptor&) const override;
+ virtual String absolute_path(const FileDescription&) const override;
uid_t uid() const { return m_uid; }
uid_t gid() const { return m_gid; }
diff --git a/Kernel/Devices/FullDevice.cpp b/Kernel/Devices/FullDevice.cpp
index 024cd699e2..fd4403d1ce 100644
--- a/Kernel/Devices/FullDevice.cpp
+++ b/Kernel/Devices/FullDevice.cpp
@@ -12,19 +12,19 @@ FullDevice::~FullDevice()
{
}
-bool FullDevice::can_read(FileDescriptor&) const
+bool FullDevice::can_read(FileDescription&) const
{
return true;
}
-ssize_t FullDevice::read(FileDescriptor&, byte* buffer, ssize_t size)
+ssize_t FullDevice::read(FileDescription&, byte* buffer, ssize_t size)
{
ssize_t count = min(PAGE_SIZE, size);
memset(buffer, 0, (size_t)count);
return count;
}
-ssize_t FullDevice::write(FileDescriptor&, const byte*, ssize_t size)
+ssize_t FullDevice::write(FileDescription&, const byte*, ssize_t size)
{
if (size == 0)
return 0;
diff --git a/Kernel/Devices/FullDevice.h b/Kernel/Devices/FullDevice.h
index 9974e47c4d..fa4ffcb8bc 100644
--- a/Kernel/Devices/FullDevice.h
+++ b/Kernel/Devices/FullDevice.h
@@ -10,9 +10,9 @@ public:
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual bool can_read(FileDescriptor&) const override;
- virtual bool can_write(FileDescriptor&) const override { return true; }
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual bool can_write(FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "FullDevice"; }
};
diff --git a/Kernel/Devices/KeyboardDevice.cpp b/Kernel/Devices/KeyboardDevice.cpp
index 856fcc2fb8..7a8464e598 100644
--- a/Kernel/Devices/KeyboardDevice.cpp
+++ b/Kernel/Devices/KeyboardDevice.cpp
@@ -208,12 +208,12 @@ KeyboardDevice::~KeyboardDevice()
{
}
-bool KeyboardDevice::can_read(FileDescriptor&) const
+bool KeyboardDevice::can_read(FileDescription&) const
{
return !m_queue.is_empty();
}
-ssize_t KeyboardDevice::read(FileDescriptor&, byte* buffer, ssize_t size)
+ssize_t KeyboardDevice::read(FileDescription&, byte* buffer, ssize_t size)
{
ssize_t nread = 0;
while (nread < size) {
@@ -229,7 +229,7 @@ ssize_t KeyboardDevice::read(FileDescriptor&, byte* buffer, ssize_t size)
return nread;
}
-ssize_t KeyboardDevice::write(FileDescriptor&, const byte*, ssize_t)
+ssize_t KeyboardDevice::write(FileDescription&, const byte*, ssize_t)
{
return 0;
}
diff --git a/Kernel/Devices/KeyboardDevice.h b/Kernel/Devices/KeyboardDevice.h
index 16f134b2a7..1edffe3869 100644
--- a/Kernel/Devices/KeyboardDevice.h
+++ b/Kernel/Devices/KeyboardDevice.h
@@ -23,10 +23,10 @@ public:
void set_client(KeyboardClient* client) { m_client = client; }
// ^CharacterDevice
- virtual ssize_t read(FileDescriptor&, byte* buffer, ssize_t) override;
- virtual bool can_read(FileDescriptor&) const override;
- virtual ssize_t write(FileDescriptor&, const byte* buffer, ssize_t) override;
- virtual bool can_write(FileDescriptor&) const override { return true; }
+ virtual ssize_t read(FileDescription&, byte* buffer, ssize_t) override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual ssize_t write(FileDescription&, const byte* buffer, ssize_t) override;
+ virtual bool can_write(FileDescription&) const override { return true; }
private:
// ^IRQHandler
diff --git a/Kernel/Devices/NullDevice.cpp b/Kernel/Devices/NullDevice.cpp
index e93bd55891..c04f84e1ca 100644
--- a/Kernel/Devices/NullDevice.cpp
+++ b/Kernel/Devices/NullDevice.cpp
@@ -20,17 +20,17 @@ NullDevice::~NullDevice()
{
}
-bool NullDevice::can_read(FileDescriptor&) const
+bool NullDevice::can_read(FileDescription&) const
{
return true;
}
-ssize_t NullDevice::read(FileDescriptor&, byte*, ssize_t)
+ssize_t NullDevice::read(FileDescription&, byte*, ssize_t)
{
return 0;
}
-ssize_t NullDevice::write(FileDescriptor&, const byte*, ssize_t buffer_size)
+ssize_t NullDevice::write(FileDescription&, const byte*, ssize_t buffer_size)
{
return min(PAGE_SIZE, buffer_size);
}
diff --git a/Kernel/Devices/NullDevice.h b/Kernel/Devices/NullDevice.h
index 47ba7baf5a..964565c690 100644
--- a/Kernel/Devices/NullDevice.h
+++ b/Kernel/Devices/NullDevice.h
@@ -12,9 +12,9 @@ public:
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual bool can_write(FileDescriptor&) const override { return true; }
- virtual bool can_read(FileDescriptor&) const override;
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual bool can_write(FileDescription&) const override { return true; }
+ virtual bool can_read(FileDescription&) const override;
virtual const char* class_name() const override { return "NullDevice"; }
};
diff --git a/Kernel/Devices/PS2MouseDevice.cpp b/Kernel/Devices/PS2MouseDevice.cpp
index c7d8ff54f5..a7f2fe296d 100644
--- a/Kernel/Devices/PS2MouseDevice.cpp
+++ b/Kernel/Devices/PS2MouseDevice.cpp
@@ -218,12 +218,12 @@ byte PS2MouseDevice::mouse_read()
return IO::in8(0x60);
}
-bool PS2MouseDevice::can_read(FileDescriptor&) const
+bool PS2MouseDevice::can_read(FileDescription&) const
{
return !m_queue.is_empty();
}
-ssize_t PS2MouseDevice::read(FileDescriptor&, byte* buffer, ssize_t size)
+ssize_t PS2MouseDevice::read(FileDescription&, byte* buffer, ssize_t size)
{
ssize_t nread = 0;
while (nread < size) {
@@ -239,7 +239,7 @@ ssize_t PS2MouseDevice::read(FileDescriptor&, byte* buffer, ssize_t size)
return nread;
}
-ssize_t PS2MouseDevice::write(FileDescriptor&, const byte*, ssize_t)
+ssize_t PS2MouseDevice::write(FileDescription&, const byte*, ssize_t)
{
return 0;
}
diff --git a/Kernel/Devices/PS2MouseDevice.h b/Kernel/Devices/PS2MouseDevice.h
index de97cfe4e1..e63db8a998 100644
--- a/Kernel/Devices/PS2MouseDevice.h
+++ b/Kernel/Devices/PS2MouseDevice.h
@@ -14,10 +14,10 @@ public:
static PS2MouseDevice& the();
// ^CharacterDevice
- virtual bool can_read(FileDescriptor&) const override;
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual bool can_write(FileDescriptor&) const override { return true; }
+ virtual bool can_read(FileDescription&) const override;
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual bool can_write(FileDescription&) const override { return true; }
private:
// ^IRQHandler
diff --git a/Kernel/Devices/RandomDevice.cpp b/Kernel/Devices/RandomDevice.cpp
index 354212fbcd..3e3cfdd023 100644
--- a/Kernel/Devices/RandomDevice.cpp
+++ b/Kernel/Devices/RandomDevice.cpp
@@ -26,12 +26,12 @@ static void mysrand(unsigned seed)
}
#endif
-bool RandomDevice::can_read(FileDescriptor&) const
+bool RandomDevice::can_read(FileDescription&) const
{
return true;
}
-ssize_t RandomDevice::read(FileDescriptor&, byte* buffer, ssize_t size)
+ssize_t RandomDevice::read(FileDescription&, byte* buffer, ssize_t size)
{
const int range = 'z' - 'a';
ssize_t nread = min(size, PAGE_SIZE);
@@ -42,7 +42,7 @@ ssize_t RandomDevice::read(FileDescriptor&, byte* buffer, ssize_t size)
return nread;
}
-ssize_t RandomDevice::write(FileDescriptor&, const byte*, ssize_t size)
+ssize_t RandomDevice::write(FileDescription&, const byte*, ssize_t size)
{
// FIXME: Use input for entropy? I guess that could be a neat feature?
return min(PAGE_SIZE, size);
diff --git a/Kernel/Devices/RandomDevice.h b/Kernel/Devices/RandomDevice.h
index ecce3c6bfb..4d6dce159e 100644
--- a/Kernel/Devices/RandomDevice.h
+++ b/Kernel/Devices/RandomDevice.h
@@ -12,9 +12,9 @@ public:
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual bool can_read(FileDescriptor&) const override;
- virtual bool can_write(FileDescriptor&) const override { return true; }
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual bool can_write(FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "RandomDevice"; }
};
diff --git a/Kernel/Devices/ZeroDevice.cpp b/Kernel/Devices/ZeroDevice.cpp
index ee809045bc..aa9e98e3a8 100644
--- a/Kernel/Devices/ZeroDevice.cpp
+++ b/Kernel/Devices/ZeroDevice.cpp
@@ -11,19 +11,19 @@ ZeroDevice::~ZeroDevice()
{
}
-bool ZeroDevice::can_read(FileDescriptor&) const
+bool ZeroDevice::can_read(FileDescription&) const
{
return true;
}
-ssize_t ZeroDevice::read(FileDescriptor&, byte* buffer, ssize_t size)
+ssize_t ZeroDevice::read(FileDescription&, byte* buffer, ssize_t size)
{
ssize_t count = min(PAGE_SIZE, size);
memset(buffer, 0, (size_t)count);
return count;
}
-ssize_t ZeroDevice::write(FileDescriptor&, const byte*, ssize_t size)
+ssize_t ZeroDevice::write(FileDescription&, const byte*, ssize_t size)
{
return min(PAGE_SIZE, size);
}
diff --git a/Kernel/Devices/ZeroDevice.h b/Kernel/Devices/ZeroDevice.h
index 930f3adec2..631fdd8965 100644
--- a/Kernel/Devices/ZeroDevice.h
+++ b/Kernel/Devices/ZeroDevice.h
@@ -10,9 +10,9 @@ public:
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual bool can_read(FileDescriptor&) const override;
- virtual bool can_write(FileDescriptor&) const override { return true; }
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual bool can_write(FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "ZeroDevice"; }
};
diff --git a/Kernel/File.cpp b/Kernel/File.cpp
index ffc64bec9d..c0e4d37aea 100644
--- a/Kernel/File.cpp
+++ b/Kernel/File.cpp
@@ -1,5 +1,5 @@
#include <Kernel/File.h>
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
File::File()
{
@@ -9,22 +9,22 @@ File::~File()
{
}
-KResultOr<Retained<FileDescriptor>> File::open(int options)
+KResultOr<Retained<FileDescription>> File::open(int options)
{
UNUSED_PARAM(options);
- return FileDescriptor::create(this);
+ return FileDescription::create(this);
}
void File::close()
{
}
-int File::ioctl(FileDescriptor&, unsigned, unsigned)
+int File::ioctl(FileDescription&, unsigned, unsigned)
{
return -ENOTTY;
}
-KResultOr<Region*> File::mmap(Process&, FileDescriptor&, LinearAddress, size_t, size_t, int)
+KResultOr<Region*> File::mmap(Process&, FileDescription&, LinearAddress, size_t, size_t, int)
{
return KResult(-ENODEV);
}
diff --git a/Kernel/File.h b/Kernel/File.h
index 8a74b3cde1..4211c40db5 100644
--- a/Kernel/File.h
+++ b/Kernel/File.h
@@ -8,11 +8,11 @@
#include <Kernel/LinearAddress.h>
#include <Kernel/UnixTypes.h>
-class FileDescriptor;
+class FileDescription;
class Process;
class Region;
-// File is the base class for anything that can be referenced by a FileDescriptor.
+// File is the base class for anything that can be referenced by a FileDescription.
//
// The most important functions in File are:
//
@@ -43,18 +43,18 @@ class File : public Retainable<File> {
public:
virtual ~File();
- virtual KResultOr<Retained<FileDescriptor>> open(int options);
+ virtual KResultOr<Retained<FileDescription>> open(int options);
virtual void close();
- virtual bool can_read(FileDescriptor&) const = 0;
- virtual bool can_write(FileDescriptor&) const = 0;
+ virtual bool can_read(FileDescription&) const = 0;
+ virtual bool can_write(FileDescription&) const = 0;
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) = 0;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) = 0;
- virtual int ioctl(FileDescriptor&, unsigned request, unsigned arg);
- virtual KResultOr<Region*> mmap(Process&, FileDescriptor&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot);
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) = 0;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) = 0;
+ virtual int ioctl(FileDescription&, unsigned request, unsigned arg);
+ virtual KResultOr<Region*> mmap(Process&, FileDescription&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot);
- virtual String absolute_path(const FileDescriptor&) const = 0;
+ virtual String absolute_path(const FileDescription&) const = 0;
virtual KResult truncate(off_t) { return KResult(-EINVAL); }
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index f54606da35..a17fa9b2df 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -479,7 +479,7 @@ RetainPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
return new_inode;
}
-ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescriptor*) const
+ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescription*) const
{
Locker inode_locker(m_lock);
ASSERT(offset >= 0);
@@ -585,7 +585,7 @@ bool Ext2FSInode::resize(qword new_size)
return true;
}
-ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const byte* data, FileDescriptor*)
+ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const byte* data, FileDescription*)
{
ASSERT(offset >= 0);
ASSERT(count >= 0);
diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h
index 1d8aa0ebc0..5ac452dbe4 100644
--- a/Kernel/FileSystem/Ext2FileSystem.h
+++ b/Kernel/FileSystem/Ext2FileSystem.h
@@ -25,12 +25,12 @@ public:
private:
// ^Inode
- virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescriptor*) const override;
+ virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescription*) const override;
virtual InodeMetadata metadata() const override;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) const override;
virtual InodeIdentifier lookup(StringView name) override;
virtual void flush_metadata() override;
- virtual ssize_t write_bytes(off_t, ssize_t, const byte* data, FileDescriptor*) override;
+ virtual ssize_t write_bytes(off_t, ssize_t, const byte* data, FileDescription*) override;
virtual KResult add_child(InodeIdentifier child_id, const String& name, mode_t) override;
virtual KResult remove_child(const String& name) override;
virtual int set_atime(time_t) override;
diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp
index 344dcee87e..e14689e763 100644
--- a/Kernel/FileSystem/FIFO.cpp
+++ b/Kernel/FileSystem/FIFO.cpp
@@ -1,5 +1,5 @@
#include <Kernel/FileSystem/FIFO.h>
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Lock.h>
#include <Kernel/Process.h>
#include <Kernel/Thread.h>
@@ -30,9 +30,9 @@ Retained<FIFO> FIFO::create(uid_t uid)
return adopt(*new FIFO(uid));
}
-Retained<FileDescriptor> FIFO::open_direction(FIFO::Direction direction)
+Retained<FileDescription> FIFO::open_direction(FIFO::Direction direction)
{
- auto descriptor = FileDescriptor::create(this);
+ auto descriptor = FileDescription::create(this);
attach(direction);
descriptor->set_fifo_direction({ }, direction);
return descriptor;
@@ -83,17 +83,17 @@ void FIFO::detach(Direction direction)
}
}
-bool FIFO::can_read(FileDescriptor&) const
+bool FIFO::can_read(FileDescription&) const
{
return !m_buffer.is_empty() || !m_writers;
}
-bool FIFO::can_write(FileDescriptor&) const
+bool FIFO::can_write(FileDescription&) const
{
return m_buffer.bytes_in_write_buffer() < 4096 || !m_readers;
}
-ssize_t FIFO::read(FileDescriptor&, byte* buffer, ssize_t size)
+ssize_t FIFO::read(FileDescription&, byte* buffer, ssize_t size)
{
if (!m_writers && m_buffer.is_empty())
return 0;
@@ -107,7 +107,7 @@ ssize_t FIFO::read(FileDescriptor&, byte* buffer, ssize_t size)
return nread;
}
-ssize_t FIFO::write(FileDescriptor&, const byte* buffer, ssize_t size)
+ssize_t FIFO::write(FileDescription&, const byte* buffer, ssize_t size)
{
if (!m_readers) {
current->process().send_signal(SIGPIPE, &current->process());
@@ -119,7 +119,7 @@ ssize_t FIFO::write(FileDescriptor&, const byte* buffer, ssize_t size)
return m_buffer.write(buffer, size);
}
-String FIFO::absolute_path(const FileDescriptor&) const
+String FIFO::absolute_path(const FileDescription&) const
{
return String::format("fifo:%u", this);
}
diff --git a/Kernel/FileSystem/FIFO.h b/Kernel/FileSystem/FIFO.h
index 50e1c88ea4..8cbb60513a 100644
--- a/Kernel/FileSystem/FIFO.h
+++ b/Kernel/FileSystem/FIFO.h
@@ -4,7 +4,7 @@
#include <Kernel/File.h>
#include <Kernel/UnixTypes.h>
-class FileDescriptor;
+class FileDescription;
class FIFO final : public File {
public:
@@ -22,18 +22,18 @@ public:
uid_t uid() const { return m_uid; }
- Retained<FileDescriptor> open_direction(Direction);
+ Retained<FileDescription> open_direction(Direction);
void attach(Direction);
void detach(Direction);
private:
// ^File
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual bool can_read(FileDescriptor&) const override;
- virtual bool can_write(FileDescriptor&) const override;
- virtual String absolute_path(const FileDescriptor&) const override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual bool can_write(FileDescription&) const override;
+ virtual String absolute_path(const FileDescription&) const override;
virtual const char* class_name() const override { return "FIFO"; }
virtual bool is_fifo() const override { return true; }
diff --git a/Kernel/FileSystem/FileDescriptor.cpp b/Kernel/FileSystem/FileDescription.cpp
index f760792757..d62e573d3b 100644
--- a/Kernel/FileSystem/FileDescriptor.cpp
+++ b/Kernel/FileSystem/FileDescription.cpp
@@ -3,7 +3,7 @@
#include <Kernel/Devices/CharacterDevice.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/FIFO.h>
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/FileSystem/InodeFile.h>
#include <Kernel/Net/Socket.h>
@@ -15,19 +15,19 @@
#include <Kernel/VM/MemoryManager.h>
#include <LibC/errno_numbers.h>
-Retained<FileDescriptor> FileDescriptor::create(RetainPtr<Custody>&& custody)
+Retained<FileDescription> FileDescription::create(RetainPtr<Custody>&& custody)
{
- auto descriptor = adopt(*new FileDescriptor(InodeFile::create(custody->inode())));
+ auto descriptor = adopt(*new FileDescription(InodeFile::create(custody->inode())));
descriptor->m_custody = move(custody);
return descriptor;
}
-Retained<FileDescriptor> FileDescriptor::create(RetainPtr<File>&& file, SocketRole role)
+Retained<FileDescription> FileDescription::create(RetainPtr<File>&& file, SocketRole role)
{
- return adopt(*new FileDescriptor(move(file), role));
+ return adopt(*new FileDescription(move(file), role));
}
-FileDescriptor::FileDescriptor(RetainPtr<File>&& file, SocketRole role)
+FileDescription::FileDescription(RetainPtr<File>&& file, SocketRole role)
: m_file(move(file))
{
if (m_file->is_inode())
@@ -35,7 +35,7 @@ FileDescriptor::FileDescriptor(RetainPtr<File>&& file, SocketRole role)
set_socket_role(role);
}
-FileDescriptor::~FileDescriptor()
+FileDescription::~FileDescription()
{
if (is_socket())
socket()->detach(*this);
@@ -46,7 +46,7 @@ FileDescriptor::~FileDescriptor()
m_inode = nullptr;
}
-void FileDescriptor::set_socket_role(SocketRole role)
+void FileDescription::set_socket_role(SocketRole role)
{
if (role == m_socket_role)
return;
@@ -58,13 +58,13 @@ void FileDescriptor::set_socket_role(SocketRole role)
socket()->attach(*this);
}
-Retained<FileDescriptor> FileDescriptor::clone()
+Retained<FileDescription> FileDescription::clone()
{
- RetainPtr<FileDescriptor> descriptor;
+ RetainPtr<FileDescription> descriptor;
if (is_fifo()) {
descriptor = fifo()->open_direction(m_fifo_direction);
} else {
- descriptor = FileDescriptor::create(m_file.copy_ref(), m_socket_role);
+ descriptor = FileDescription::create(m_file.copy_ref(), m_socket_role);
descriptor->m_custody = m_custody.copy_ref();
descriptor->m_inode = m_inode.copy_ref();
}
@@ -76,7 +76,7 @@ Retained<FileDescriptor> FileDescriptor::clone()
return *descriptor;
}
-KResult FileDescriptor::fstat(stat& buffer)
+KResult FileDescription::fstat(stat& buffer)
{
ASSERT(!is_fifo());
if (!m_inode)
@@ -84,14 +84,14 @@ KResult FileDescriptor::fstat(stat& buffer)
return metadata().stat(buffer);
}
-KResult FileDescriptor::fchmod(mode_t mode)
+KResult FileDescription::fchmod(mode_t mode)
{
if (!m_inode)
return KResult(-EBADF);
return VFS::the().chmod(*m_inode, mode);
}
-off_t FileDescriptor::seek(off_t offset, int whence)
+off_t FileDescription::seek(off_t offset, int whence)
{
if (!m_file->is_seekable())
return -EINVAL;
@@ -127,7 +127,7 @@ off_t FileDescriptor::seek(off_t offset, int whence)
return m_current_offset;
}
-ssize_t FileDescriptor::read(byte* buffer, ssize_t count)
+ssize_t FileDescription::read(byte* buffer, ssize_t count)
{
int nread = m_file->read(*this, buffer, count);
if (m_file->is_seekable())
@@ -135,7 +135,7 @@ ssize_t FileDescriptor::read(byte* buffer, ssize_t count)
return nread;
}
-ssize_t FileDescriptor::write(const byte* data, ssize_t size)
+ssize_t FileDescription::write(const byte* data, ssize_t size)
{
int nwritten = m_file->write(*this, data, size);
if (m_file->is_seekable())
@@ -143,17 +143,17 @@ ssize_t FileDescriptor::write(const byte* data, ssize_t size)
return nwritten;
}
-bool FileDescriptor::can_write()
+bool FileDescription::can_write()
{
return m_file->can_write(*this);
}
-bool FileDescriptor::can_read()
+bool FileDescription::can_read()
{
return m_file->can_read(*this);
}
-ByteBuffer FileDescriptor::read_entire_file()
+ByteBuffer FileDescription::read_entire_file()
{
// HACK ALERT: (This entire function)
ASSERT(m_file->is_inode());
@@ -161,13 +161,13 @@ ByteBuffer FileDescriptor::read_entire_file()
return m_inode->read_entire(this);
}
-bool FileDescriptor::is_directory() const
+bool FileDescription::is_directory() const
{
ASSERT(!is_fifo());
return metadata().is_directory();
}
-ssize_t FileDescriptor::get_dir_entries(byte* buffer, ssize_t size)
+ssize_t FileDescription::get_dir_entries(byte* buffer, ssize_t size)
{
auto metadata = this->metadata();
if (!metadata.is_valid())
@@ -195,137 +195,137 @@ ssize_t FileDescriptor::get_dir_entries(byte* buffer, ssize_t size)
return stream.offset();
}
-bool FileDescriptor::is_device() const
+bool FileDescription::is_device() const
{
return m_file->is_device();
}
-bool FileDescriptor::is_tty() const
+bool FileDescription::is_tty() const
{
return m_file->is_tty();
}
-const TTY* FileDescriptor::tty() const
+const TTY* FileDescription::tty() const
{
if (!is_tty())
return nullptr;
return static_cast<const TTY*>(m_file.ptr());
}
-TTY* FileDescriptor::tty()
+TTY* FileDescription::tty()
{
if (!is_tty())
return nullptr;
return static_cast<TTY*>(m_file.ptr());
}
-bool FileDescriptor::is_master_pty() const
+bool FileDescription::is_master_pty() const
{
return m_file->is_master_pty();
}
-const MasterPTY* FileDescriptor::master_pty() const
+const MasterPTY* FileDescription::master_pty() const
{
if (!is_master_pty())
return nullptr;
return static_cast<const MasterPTY*>(m_file.ptr());
}
-MasterPTY* FileDescriptor::master_pty()
+MasterPTY* FileDescription::master_pty()
{
if (!is_master_pty())
return nullptr;
return static_cast<MasterPTY*>(m_file.ptr());
}
-int FileDescriptor::close()
+int FileDescription::close()
{
return 0;
}
-String FileDescriptor::absolute_path() const
+String FileDescription::absolute_path() const
{
if (m_custody)
return m_custody->absolute_path();
- dbgprintf("FileDescriptor::absolute_path() for FD without custody, File type: %s\n", m_file->class_name());
+ dbgprintf("FileDescription::absolute_path() for FD without custody, File type: %s\n", m_file->class_name());
return m_file->absolute_path(*this);
}
-InodeMetadata FileDescriptor::metadata() const
+InodeMetadata FileDescription::metadata() const
{
if (m_inode)
return m_inode->metadata();
return { };
}
-KResultOr<Region*> FileDescriptor::mmap(Process& process, LinearAddress laddr, size_t offset, size_t size, int prot)
+KResultOr<Region*> FileDescription::mmap(Process& process, LinearAddress laddr, size_t offset, size_t size, int prot)
{
return m_file->mmap(process, *this, laddr, offset, size, prot);
}
-KResult FileDescriptor::truncate(off_t length)
+KResult FileDescription::truncate(off_t length)
{
return m_file->truncate(length);
}
-bool FileDescriptor::is_shared_memory() const
+bool FileDescription::is_shared_memory() const
{
return m_file->is_shared_memory();
}
-SharedMemory* FileDescriptor::shared_memory()
+SharedMemory* FileDescription::shared_memory()
{
if (!is_shared_memory())
return nullptr;
return static_cast<SharedMemory*>(m_file.ptr());
}
-const SharedMemory* FileDescriptor::shared_memory() const
+const SharedMemory* FileDescription::shared_memory() const
{
if (!is_shared_memory())
return nullptr;
return static_cast<const SharedMemory*>(m_file.ptr());
}
-bool FileDescriptor::is_fifo() const
+bool FileDescription::is_fifo() const
{
return m_file->is_fifo();
}
-FIFO* FileDescriptor::fifo()
+FIFO* FileDescription::fifo()
{
if (!is_fifo())
return nullptr;
return static_cast<FIFO*>(m_file.ptr());
}
-bool FileDescriptor::is_socket() const
+bool FileDescription::is_socket() const
{
return m_file->is_socket();
}
-Socket* FileDescriptor::socket()
+Socket* FileDescription::socket()
{
if (!is_socket())
return nullptr;
return static_cast<Socket*>(m_file.ptr());
}
-const Socket* FileDescriptor::socket() const
+const Socket* FileDescription::socket() const
{
if (!is_socket())
return nullptr;
return static_cast<const Socket*>(m_file.ptr());
}
-void FileDescriptor::set_file_flags(dword flags)
+void FileDescription::set_file_flags(dword flags)
{
m_is_blocking = !(flags & O_NONBLOCK);
m_should_append = flags & O_APPEND;
m_file_flags = flags;
}
-KResult FileDescriptor::chown(uid_t uid, gid_t gid)
+KResult FileDescription::chown(uid_t uid, gid_t gid)
{
if (!m_inode)
return KResult(-EINVAL);
diff --git a/Kernel/FileSystem/FileDescriptor.h b/Kernel/FileSystem/FileDescription.h
index 7d8cdf8d7d..7c1d1ef4bb 100644
--- a/Kernel/FileSystem/FileDescriptor.h
+++ b/Kernel/FileSystem/FileDescription.h
@@ -19,13 +19,13 @@ class Region;
class CharacterDevice;
class SharedMemory;
-class FileDescriptor : public Retainable<FileDescriptor> {
+class FileDescription : public Retainable<FileDescription> {
public:
- static Retained<FileDescriptor> create(RetainPtr<Custody>&&);
- static Retained<FileDescriptor> create(RetainPtr<File>&&, SocketRole = SocketRole::None);
- ~FileDescriptor();
+ static Retained<FileDescription> create(RetainPtr<Custody>&&);
+ static Retained<FileDescription> create(RetainPtr<File>&&, SocketRole = SocketRole::None);
+ ~FileDescription();
- Retained<FileDescriptor> clone();
+ Retained<FileDescription> clone();
int close();
@@ -105,8 +105,8 @@ public:
private:
friend class VFS;
- FileDescriptor(RetainPtr<File>&&, SocketRole = SocketRole::None);
- FileDescriptor(FIFO&, FIFO::Direction);
+ FileDescription(RetainPtr<File>&&, SocketRole = SocketRole::None);
+ FileDescription(FIFO&, FIFO::Direction);
RetainPtr<Custody> m_custody;
RetainPtr<Inode> m_inode;
diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h
index 097d479b00..81d953c832 100644
--- a/Kernel/FileSystem/FileSystem.h
+++ b/Kernel/FileSystem/FileSystem.h
@@ -19,7 +19,7 @@
static const dword mepoch = 476763780;
class Inode;
-class FileDescriptor;
+class FileDescription;
class LocalSocket;
class VMObject;
diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp
index 38eb0395d1..2be2ec2ea6 100644
--- a/Kernel/FileSystem/Inode.cpp
+++ b/Kernel/FileSystem/Inode.cpp
@@ -28,7 +28,7 @@ void Inode::sync()
}
}
-ByteBuffer Inode::read_entire(FileDescriptor* descriptor) const
+ByteBuffer Inode::read_entire(FileDescription* descriptor) const
{
size_t initial_size = metadata().size ? metadata().size : 4096;
StringBuilder builder(initial_size);
diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h
index 8010597ccb..44f3b3666a 100644
--- a/Kernel/FileSystem/Inode.h
+++ b/Kernel/FileSystem/Inode.h
@@ -10,7 +10,7 @@
#include <Kernel/KResult.h>
#include <Kernel/Lock.h>
-class FileDescriptor;
+class FileDescription;
class LocalSocket;
class VMObject;
@@ -37,12 +37,12 @@ public:
InodeIdentifier identifier() const { return { fsid(), index() }; }
virtual InodeMetadata metadata() const = 0;
- ByteBuffer read_entire(FileDescriptor* = nullptr) const;
+ ByteBuffer read_entire(FileDescription* = nullptr) const;
- virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescriptor*) const = 0;
+ virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescription*) const = 0;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) const = 0;
virtual InodeIdentifier lookup(StringView name) = 0;
- virtual ssize_t write_bytes(off_t, ssize_t, const byte* data, FileDescriptor*) = 0;
+ virtual ssize_t write_bytes(off_t, ssize_t, const byte* data, FileDescription*) = 0;
virtual KResult add_child(InodeIdentifier child_id, const String& name, mode_t) = 0;
virtual KResult remove_child(const String& name) = 0;
virtual size_t directory_entry_count() const = 0;
diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp
index f30fb655f1..577dec1a21 100644
--- a/Kernel/FileSystem/InodeFile.cpp
+++ b/Kernel/FileSystem/InodeFile.cpp
@@ -1,6 +1,6 @@
#include <Kernel/FileSystem/InodeFile.h>
#include <Kernel/FileSystem/Inode.h>
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/Process.h>
@@ -13,17 +13,17 @@ InodeFile::~InodeFile()
{
}
-ssize_t InodeFile::read(FileDescriptor& descriptor, byte* buffer, ssize_t count)
+ssize_t InodeFile::read(FileDescription& descriptor, byte* buffer, ssize_t count)
{
return m_inode->read_bytes(descriptor.offset(), count, buffer, &descriptor);
}
-ssize_t InodeFile::write(FileDescriptor& descriptor, const byte* data, ssize_t count)
+ssize_t InodeFile::write(FileDescription& descriptor, const byte* data, ssize_t count)
{
return m_inode->write_bytes(descriptor.offset(), count, data, &descriptor);
}
-KResultOr<Region*> InodeFile::mmap(Process& process, FileDescriptor& descriptor, LinearAddress preferred_laddr, size_t offset, size_t size, int prot)
+KResultOr<Region*> InodeFile::mmap(Process& process, FileDescription& descriptor, LinearAddress preferred_laddr, size_t offset, size_t size, int prot)
{
ASSERT(offset == 0);
// FIXME: If PROT_EXEC, check that the underlying file system isn't mounted noexec.
@@ -34,7 +34,7 @@ KResultOr<Region*> InodeFile::mmap(Process& process, FileDescriptor& descriptor,
return region;
}
-String InodeFile::absolute_path(const FileDescriptor& descriptor) const
+String InodeFile::absolute_path(const FileDescription& descriptor) const
{
ASSERT_NOT_REACHED();
ASSERT(descriptor.custody());
diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h
index 5522822d1e..cae2818697 100644
--- a/Kernel/FileSystem/InodeFile.h
+++ b/Kernel/FileSystem/InodeFile.h
@@ -16,14 +16,14 @@ public:
const Inode& inode() const { return *m_inode; }
Inode& inode() { return *m_inode; }
- virtual bool can_read(FileDescriptor&) const override { return true; }
- virtual bool can_write(FileDescriptor&) const override { return true; }
+ virtual bool can_read(FileDescription&) const override { return true; }
+ virtual bool can_write(FileDescription&) const override { return true; }
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual KResultOr<Region*> mmap(Process&, FileDescriptor&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot) override;
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual KResultOr<Region*> mmap(Process&, FileDescription&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot) override;
- virtual String absolute_path(const FileDescriptor&) const override;
+ virtual String absolute_path(const FileDescription&) const override;
virtual KResult truncate(off_t) override;
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index b09b89e163..73aeb43743 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -1,7 +1,7 @@
#include "ProcFS.h"
#include "Process.h"
#include <Kernel/FileSystem/Custody.h>
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/VM/MemoryManager.h>
#include "StdLib.h"
@@ -189,7 +189,7 @@ ByteBuffer procfs$pid_fds(InodeIdentifier identifier)
return { };
StringBuilder builder;
for (int i = 0; i < process.max_open_file_descriptors(); ++i) {
- auto* descriptor = process.file_descriptor(i);
+ auto* descriptor = process.file_description(i);
if (!descriptor)
continue;
builder.appendf("% 3u %s\n", i, descriptor->absolute_path().characters());
@@ -204,7 +204,7 @@ ByteBuffer procfs$pid_fd_entry(InodeIdentifier identifier)
return { };
auto& process = handle->process();
int fd = to_fd(identifier);
- auto* descriptor = process.file_descriptor(fd);
+ auto* descriptor = process.file_description(fd);
if (!descriptor)
return { };
return descriptor->absolute_path().to_byte_buffer();
@@ -835,7 +835,7 @@ InodeMetadata ProcFSInode::metadata() const
return metadata;
}
-ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescriptor* descriptor) const
+ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescription* descriptor) const
{
#ifdef PROCFS_DEBUG
dbgprintf("ProcFS: read_bytes %u\n", index());
@@ -941,7 +941,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)
return false;
auto& process = handle->process();
for (int i = 0; i < process.max_open_file_descriptors(); ++i) {
- auto* descriptor = process.file_descriptor(i);
+ auto* descriptor = process.file_description(i);
if (!descriptor)
continue;
char name[16];
@@ -1027,7 +1027,7 @@ InodeIdentifier ProcFSInode::lookup(StringView name)
{
InterruptDisabler disabler;
if (auto* process = Process::from_pid(to_pid(identifier())))
- fd_exists = process->file_descriptor(name_as_number);
+ fd_exists = process->file_description(name_as_number);
}
if (fd_exists)
@@ -1041,7 +1041,7 @@ void ProcFSInode::flush_metadata()
{
}
-ssize_t ProcFSInode::write_bytes(off_t offset, ssize_t size, const byte* buffer, FileDescriptor*)
+ssize_t ProcFSInode::write_bytes(off_t offset, ssize_t size, const byte* buffer, FileDescription*)
{
auto* directory_entry = fs().get_directory_entry(identifier());
if (!directory_entry || !directory_entry->write_callback)
diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h
index 1ba73615d6..bb4e18eb80 100644
--- a/Kernel/FileSystem/ProcFS.h
+++ b/Kernel/FileSystem/ProcFS.h
@@ -80,12 +80,12 @@ public:
private:
// ^Inode
- virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescriptor*) const override;
+ virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescription*) const override;
virtual InodeMetadata metadata() const override;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) const override;
virtual InodeIdentifier lookup(StringView name) override;
virtual void flush_metadata() override;
- virtual ssize_t write_bytes(off_t, ssize_t, const byte* buffer, FileDescriptor*) override;
+ virtual ssize_t write_bytes(off_t, ssize_t, const byte* buffer, FileDescription*) override;
virtual KResult add_child(InodeIdentifier child_id, const String& name, mode_t) override;
virtual KResult remove_child(const String& name) override;
virtual size_t directory_entry_count() const override;
diff --git a/Kernel/FileSystem/SyntheticFileSystem.cpp b/Kernel/FileSystem/SyntheticFileSystem.cpp
index 9dc2711319..86e2aed130 100644
--- a/Kernel/FileSystem/SyntheticFileSystem.cpp
+++ b/Kernel/FileSystem/SyntheticFileSystem.cpp
@@ -1,5 +1,5 @@
#include <Kernel/FileSystem/SyntheticFileSystem.h>
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <LibC/errno_numbers.h>
#include <AK/StdLibExtras.h>
@@ -185,7 +185,7 @@ InodeMetadata SynthFSInode::metadata() const
return m_metadata;
}
-ssize_t SynthFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescriptor* descriptor) const
+ssize_t SynthFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescription* descriptor) const
{
LOCKER(m_lock);
#ifdef SYNTHFS_DEBUG
@@ -250,7 +250,7 @@ void SynthFSInode::flush_metadata()
{
}
-ssize_t SynthFSInode::write_bytes(off_t offset, ssize_t size, const byte* buffer, FileDescriptor*)
+ssize_t SynthFSInode::write_bytes(off_t offset, ssize_t size, const byte* buffer, FileDescription*)
{
LOCKER(m_lock);
if (!m_write_callback)
diff --git a/Kernel/FileSystem/SyntheticFileSystem.h b/Kernel/FileSystem/SyntheticFileSystem.h
index c5bb164363..df989d53f1 100644
--- a/Kernel/FileSystem/SyntheticFileSystem.h
+++ b/Kernel/FileSystem/SyntheticFileSystem.h
@@ -57,12 +57,12 @@ public:
private:
// ^Inode
- virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescriptor*) const override;
+ virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescription*) const override;
virtual InodeMetadata metadata() const override;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) const override;
virtual InodeIdentifier lookup(StringView name) override;
virtual void flush_metadata() override;
- virtual ssize_t write_bytes(off_t, ssize_t, const byte* buffer, FileDescriptor*) override;
+ virtual ssize_t write_bytes(off_t, ssize_t, const byte* buffer, FileDescription*) override;
virtual KResult add_child(InodeIdentifier child_id, const String& name, mode_t) override;
virtual KResult remove_child(const String& name) override;
virtual size_t directory_entry_count() const override;
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp
index e4ba6cafd4..7ae678e6d1 100644
--- a/Kernel/FileSystem/VirtualFileSystem.cpp
+++ b/Kernel/FileSystem/VirtualFileSystem.cpp
@@ -1,5 +1,5 @@
#include "VirtualFileSystem.h"
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include "FileSystem.h"
#include <AK/FileSystemPath.h>
#include <AK/StringBuilder.h>
@@ -149,7 +149,7 @@ KResult VFS::stat(StringView path, int options, Custody& base, struct stat& stat
return custody_or_error.value()->inode().metadata().stat(statbuf);
}
-KResultOr<Retained<FileDescriptor>> VFS::open(StringView path, int options, mode_t mode, Custody& base)
+KResultOr<Retained<FileDescription>> VFS::open(StringView path, int options, mode_t mode, Custody& base)
{
auto custody_or_error = resolve_path(path, base, nullptr, options);
if (options & O_CREAT) {
@@ -194,7 +194,7 @@ KResultOr<Retained<FileDescriptor>> VFS::open(StringView path, int options, mode
}
if (should_truncate_file)
inode.truncate(0);
- return FileDescriptor::create(custody);
+ return FileDescription::create(custody);
}
KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base)
@@ -224,7 +224,7 @@ KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base)
return KSuccess;
}
-KResultOr<Retained<FileDescriptor>> VFS::create(StringView path, int options, mode_t mode, Custody& base)
+KResultOr<Retained<FileDescription>> VFS::create(StringView path, int options, mode_t mode, Custody& base)
{
(void)options;
@@ -253,7 +253,7 @@ KResultOr<Retained<FileDescriptor>> VFS::create(StringView path, int options, mo
return KResult(error);
auto new_custody = Custody::create(parent_custody, p.basename(), *new_file);
- return FileDescriptor::create(*new_custody);
+ return FileDescription::create(*new_custody);
}
KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
diff --git a/Kernel/FileSystem/VirtualFileSystem.h b/Kernel/FileSystem/VirtualFileSystem.h
index 4edbb3c0bd..a6ff04c2af 100644
--- a/Kernel/FileSystem/VirtualFileSystem.h
+++ b/Kernel/FileSystem/VirtualFileSystem.h
@@ -28,7 +28,7 @@
class Custody;
class Device;
-class FileDescriptor;
+class FileDescription;
class VFS {
AK_MAKE_ETERNAL
@@ -59,9 +59,9 @@ public:
bool mount_root(Retained<FS>&&);
bool mount(Retained<FS>&&, StringView path);
- KResultOr<Retained<FileDescriptor>> open(RetainPtr<Device>&&, int options);
- KResultOr<Retained<FileDescriptor>> open(StringView path, int options, mode_t mode, Custody& base);
- KResultOr<Retained<FileDescriptor>> create(StringView path, int options, mode_t mode, Custody& base);
+ KResultOr<Retained<FileDescription>> open(RetainPtr<Device>&&, int options);
+ KResultOr<Retained<FileDescription>> open(StringView path, int options, mode_t mode, Custody& base);
+ KResultOr<Retained<FileDescription>> create(StringView path, int options, mode_t mode, Custody& base);
KResult mkdir(StringView path, mode_t mode, Custody& base);
KResult link(StringView old_path, StringView new_path, Custody& base);
KResult unlink(StringView path, Custody& base);
@@ -94,7 +94,7 @@ public:
KResultOr<Retained<Custody>> resolve_path(StringView path, Custody& base, RetainPtr<Custody>* parent = nullptr, int options = 0);
private:
- friend class FileDescriptor;
+ friend class FileDescription;
RetainPtr<Inode> get_inode(InodeIdentifier);
diff --git a/Kernel/KSyms.cpp b/Kernel/KSyms.cpp
index 6ee0a3ac23..73816e0d20 100644
--- a/Kernel/KSyms.cpp
+++ b/Kernel/KSyms.cpp
@@ -1,7 +1,7 @@
#include "KSyms.h"
#include "Process.h"
#include "Scheduler.h"
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <AK/ELF/ELFLoader.h>
#include <AK/TemporaryChange.h>
diff --git a/Kernel/Makefile b/Kernel/Makefile
index 3479d8eed2..8356f9526a 100644
--- a/Kernel/Makefile
+++ b/Kernel/Makefile
@@ -72,7 +72,7 @@ VFS_OBJS = \
FileSystem/DiskBackedFileSystem.o \
FileSystem/Ext2FileSystem.o \
FileSystem/VirtualFileSystem.o \
- FileSystem/FileDescriptor.o \
+ FileSystem/FileDescription.o \
FileSystem/SyntheticFileSystem.o
AK_OBJS = \
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index 681674ba61..b09e320409 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -11,7 +11,7 @@
#include <Kernel/Net/ARP.h>
#include <Kernel/Net/Routing.h>
#include <LibC/errno_numbers.h>
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#define IPV4_SOCKET_DEBUG
@@ -89,7 +89,7 @@ KResult IPv4Socket::bind(const sockaddr* address, socklen_t address_size)
return protocol_bind();
}
-KResult IPv4Socket::connect(FileDescriptor& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock should_block)
+KResult IPv4Socket::connect(FileDescription& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock should_block)
{
ASSERT(!m_bound);
if (address_size != sizeof(sockaddr_in))
@@ -104,17 +104,17 @@ KResult IPv4Socket::connect(FileDescriptor& descriptor, const sockaddr* address,
return protocol_connect(descriptor, should_block);
}
-void IPv4Socket::attach(FileDescriptor&)
+void IPv4Socket::attach(FileDescription&)
{
++m_attached_fds;
}
-void IPv4Socket::detach(FileDescriptor&)
+void IPv4Socket::detach(FileDescription&)
{
--m_attached_fds;
}
-bool IPv4Socket::can_read(FileDescriptor& descriptor) const
+bool IPv4Socket::can_read(FileDescription& descriptor) const
{
if (descriptor.socket_role() == SocketRole::Listener)
return can_accept();
@@ -123,17 +123,17 @@ bool IPv4Socket::can_read(FileDescriptor& descriptor) const
return m_can_read;
}
-ssize_t IPv4Socket::read(FileDescriptor& descriptor, byte* buffer, ssize_t size)
+ssize_t IPv4Socket::read(FileDescription& descriptor, byte* buffer, ssize_t size)
{
return recvfrom(descriptor, buffer, size, 0, nullptr, 0);
}
-ssize_t IPv4Socket::write(FileDescriptor& descriptor, const byte* data, ssize_t size)
+ssize_t IPv4Socket::write(FileDescription& descriptor, const byte* data, ssize_t size)
{
return sendto(descriptor, data, size, 0, nullptr, 0);
}
-bool IPv4Socket::can_write(FileDescriptor&) const
+bool IPv4Socket::can_write(FileDescription&) const
{
return is_connected();
}
@@ -149,7 +149,7 @@ int IPv4Socket::allocate_local_port_if_needed()
return port;
}
-ssize_t IPv4Socket::sendto(FileDescriptor&, const void* data, size_t data_length, int flags, const sockaddr* addr, socklen_t addr_length)
+ssize_t IPv4Socket::sendto(FileDescription&, const void* data, size_t data_length, int flags, const sockaddr* addr, socklen_t addr_length)
{
(void)flags;
if (addr && addr_length != sizeof(sockaddr_in))
@@ -184,7 +184,7 @@ ssize_t IPv4Socket::sendto(FileDescriptor&, const void* data, size_t data_length
return protocol_send(data, data_length);
}
-ssize_t IPv4Socket::recvfrom(FileDescriptor& descriptor, void* buffer, size_t buffer_length, int flags, sockaddr* addr, socklen_t* addr_length)
+ssize_t IPv4Socket::recvfrom(FileDescription& descriptor, void* buffer, size_t buffer_length, int flags, sockaddr* addr, socklen_t* addr_length)
{
(void)flags;
if (addr_length && *addr_length < sizeof(sockaddr_in))
diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h
index 4f18d63113..dea6b5c171 100644
--- a/Kernel/Net/IPv4Socket.h
+++ b/Kernel/Net/IPv4Socket.h
@@ -21,17 +21,17 @@ public:
static Lockable<HashTable<IPv4Socket*>>& all_sockets();
virtual KResult bind(const sockaddr*, socklen_t) override;
- virtual KResult connect(FileDescriptor&, const sockaddr*, socklen_t, ShouldBlock = ShouldBlock::Yes) override;
+ virtual KResult connect(FileDescription&, const sockaddr*, socklen_t, ShouldBlock = ShouldBlock::Yes) override;
virtual bool get_local_address(sockaddr*, socklen_t*) override;
virtual bool get_peer_address(sockaddr*, socklen_t*) override;
- virtual void attach(FileDescriptor&) override;
- virtual void detach(FileDescriptor&) override;
- virtual bool can_read(FileDescriptor&) const override;
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual bool can_write(FileDescriptor&) const override;
- virtual ssize_t sendto(FileDescriptor&, const void*, size_t, int, const sockaddr*, socklen_t) override;
- virtual ssize_t recvfrom(FileDescriptor&, void*, size_t, int flags, sockaddr*, socklen_t*) override;
+ virtual void attach(FileDescription&) override;
+ virtual void detach(FileDescription&) override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual bool can_write(FileDescription&) const override;
+ virtual ssize_t sendto(FileDescription&, const void*, size_t, int, const sockaddr*, socklen_t) override;
+ virtual ssize_t recvfrom(FileDescription&, void*, size_t, int flags, sockaddr*, socklen_t*) override;
void did_receive(const IPv4Address& peer_address, word peer_port, ByteBuffer&&);
@@ -52,7 +52,7 @@ protected:
virtual KResult protocol_bind() { return KSuccess; }
virtual int protocol_receive(const ByteBuffer&, void*, size_t, int, sockaddr*, socklen_t*) { return -ENOTIMPL; }
virtual int protocol_send(const void*, int) { return -ENOTIMPL; }
- virtual KResult protocol_connect(FileDescriptor&, ShouldBlock) { return KSuccess; }
+ virtual KResult protocol_connect(FileDescription&, ShouldBlock) { return KSuccess; }
virtual int protocol_allocate_local_port() { return 0; }
virtual bool protocol_is_disconnected() const { return false; }
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index 99457e2cc4..208348847a 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -1,7 +1,7 @@
#include <Kernel/Net/LocalSocket.h>
#include <Kernel/UnixTypes.h>
#include <Kernel/Process.h>
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <LibC/errno_numbers.h>
@@ -71,7 +71,7 @@ KResult LocalSocket::bind(const sockaddr* address, socklen_t address_size)
return KSuccess;
}
-KResult LocalSocket::connect(FileDescriptor& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock)
+KResult LocalSocket::connect(FileDescription& descriptor, const sockaddr* address, socklen_t address_size, ShouldBlock)
{
ASSERT(!m_bound);
if (address_size != sizeof(sockaddr_un))
@@ -106,7 +106,7 @@ KResult LocalSocket::connect(FileDescriptor& descriptor, const sockaddr* address
return current->wait_for_connect(descriptor);
}
-void LocalSocket::attach(FileDescriptor& descriptor)
+void LocalSocket::attach(FileDescription& descriptor)
{
switch (descriptor.socket_role()) {
case SocketRole::Accepted:
@@ -123,7 +123,7 @@ void LocalSocket::attach(FileDescriptor& descriptor)
}
}
-void LocalSocket::detach(FileDescriptor& descriptor)
+void LocalSocket::detach(FileDescription& descriptor)
{
switch (descriptor.socket_role()) {
case SocketRole::Accepted:
@@ -143,7 +143,7 @@ void LocalSocket::detach(FileDescriptor& descriptor)
}
}
-bool LocalSocket::can_read(FileDescriptor& descriptor) const
+bool LocalSocket::can_read(FileDescription& descriptor) const
{
auto role = descriptor.socket_role();
if (role == SocketRole::Listener)
@@ -155,7 +155,7 @@ bool LocalSocket::can_read(FileDescriptor& descriptor) const
ASSERT_NOT_REACHED();
}
-ssize_t LocalSocket::read(FileDescriptor& descriptor, byte* buffer, ssize_t size)
+ssize_t LocalSocket::read(FileDescription& descriptor, byte* buffer, ssize_t size)
{
auto role = descriptor.socket_role();
if (role == SocketRole::Accepted) {
@@ -175,7 +175,7 @@ ssize_t LocalSocket::read(FileDescriptor& descriptor, byte* buffer, ssize_t size
ASSERT_NOT_REACHED();
}
-bool LocalSocket::has_attached_peer(const FileDescriptor& descriptor) const
+bool LocalSocket::has_attached_peer(const FileDescription& descriptor) const
{
if (descriptor.socket_role() == SocketRole::Accepted)
return m_connected_fds_open || m_connecting_fds_open;
@@ -184,7 +184,7 @@ bool LocalSocket::has_attached_peer(const FileDescriptor& descriptor) const
ASSERT_NOT_REACHED();
}
-ssize_t LocalSocket::write(FileDescriptor& descriptor, const byte* data, ssize_t size)
+ssize_t LocalSocket::write(FileDescription& descriptor, const byte* data, ssize_t size)
{
if (!has_attached_peer(descriptor))
return -EPIPE;
@@ -195,7 +195,7 @@ ssize_t LocalSocket::write(FileDescriptor& descriptor, const byte* data, ssize_t
ASSERT_NOT_REACHED();
}
-bool LocalSocket::can_write(FileDescriptor& descriptor) const
+bool LocalSocket::can_write(FileDescription& descriptor) const
{
if (descriptor.socket_role() == SocketRole::Accepted)
return !has_attached_peer(descriptor) || m_for_client.bytes_in_write_buffer() < 16384;
@@ -204,12 +204,12 @@ bool LocalSocket::can_write(FileDescriptor& descriptor) const
ASSERT_NOT_REACHED();
}
-ssize_t LocalSocket::sendto(FileDescriptor& descriptor, const void* data, size_t data_size, int, const sockaddr*, socklen_t)
+ssize_t LocalSocket::sendto(FileDescription& descriptor, const void* data, size_t data_size, int, const sockaddr*, socklen_t)
{
return write(descriptor, (const byte*)data, data_size);
}
-ssize_t LocalSocket::recvfrom(FileDescriptor& descriptor, void* buffer, size_t buffer_size, int, sockaddr*, socklen_t*)
+ssize_t LocalSocket::recvfrom(FileDescription& descriptor, void* buffer, size_t buffer_size, int, sockaddr*, socklen_t*)
{
return read(descriptor, (byte*)buffer, buffer_size);
}
diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h
index 3328fd4eba..f1ac23719b 100644
--- a/Kernel/Net/LocalSocket.h
+++ b/Kernel/Net/LocalSocket.h
@@ -3,7 +3,7 @@
#include <Kernel/DoubleBuffer.h>
#include <Kernel/Net/Socket.h>
-class FileDescriptor;
+class FileDescription;
class LocalSocket final : public Socket {
public:
@@ -11,24 +11,24 @@ public:
virtual ~LocalSocket() override;
virtual KResult bind(const sockaddr*, socklen_t) override;
- virtual KResult connect(FileDescriptor&, const sockaddr*, socklen_t, ShouldBlock = ShouldBlock::Yes) override;
+ virtual KResult connect(FileDescription&, const sockaddr*, socklen_t, ShouldBlock = ShouldBlock::Yes) override;
virtual bool get_local_address(sockaddr*, socklen_t*) override;
virtual bool get_peer_address(sockaddr*, socklen_t*) override;
- virtual void attach(FileDescriptor&) override;
- virtual void detach(FileDescriptor&) override;
- virtual bool can_read(FileDescriptor&) const override;
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual bool can_write(FileDescriptor&) const override;
- virtual ssize_t sendto(FileDescriptor&, const void*, size_t, int, const sockaddr*, socklen_t) override;
- virtual ssize_t recvfrom(FileDescriptor&, void*, size_t, int flags, sockaddr*, socklen_t*) override;
+ virtual void attach(FileDescription&) override;
+ virtual void detach(FileDescription&) override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual bool can_write(FileDescription&) const override;
+ virtual ssize_t sendto(FileDescription&, const void*, size_t, int, const sockaddr*, socklen_t) override;
+ virtual ssize_t recvfrom(FileDescription&, void*, size_t, int flags, sockaddr*, socklen_t*) override;
private:
explicit LocalSocket(int type);
virtual bool is_local() const override { return true; }
- bool has_attached_peer(const FileDescriptor&) const;
+ bool has_attached_peer(const FileDescription&) const;
- RetainPtr<FileDescriptor> m_file;
+ RetainPtr<FileDescription> m_file;
bool m_bound { false };
int m_accepted_fds_open { 0 };
diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp
index 8c800f8eba..ee4a78c473 100644
--- a/Kernel/Net/Socket.cpp
+++ b/Kernel/Net/Socket.cpp
@@ -1,4 +1,4 @@
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Net/Socket.h>
#include <Kernel/Net/LocalSocket.h>
#include <Kernel/Net/IPv4Socket.h>
@@ -142,7 +142,7 @@ static const char* to_string(SocketRole role)
}
}
-String Socket::absolute_path(const FileDescriptor& descriptor) const
+String Socket::absolute_path(const FileDescription& descriptor) const
{
return String::format("socket:%x (role: %s)", this, to_string(descriptor.socket_role()));
}
diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h
index f11f3e768b..336dc8623b 100644
--- a/Kernel/Net/Socket.h
+++ b/Kernel/Net/Socket.h
@@ -23,7 +23,7 @@ enum class ShouldBlock
Yes = 1
};
-class FileDescriptor;
+class FileDescription;
class Socket : public File {
public:
@@ -40,15 +40,15 @@ public:
KResult listen(int backlog);
virtual KResult bind(const sockaddr*, socklen_t) = 0;
- virtual KResult connect(FileDescriptor&, const sockaddr*, socklen_t, ShouldBlock) = 0;
+ virtual KResult connect(FileDescription&, const sockaddr*, socklen_t, ShouldBlock) = 0;
virtual bool get_local_address(sockaddr*, socklen_t*) = 0;
virtual bool get_peer_address(sockaddr*, socklen_t*) = 0;
virtual bool is_local() const { return false; }
virtual bool is_ipv4() const { return false; }
- virtual void attach(FileDescriptor&) = 0;
- virtual void detach(FileDescriptor&) = 0;
- virtual ssize_t sendto(FileDescriptor&, const void*, size_t, int flags, const sockaddr*, socklen_t) = 0;
- virtual ssize_t recvfrom(FileDescriptor&, void*, size_t, int flags, sockaddr*, socklen_t*) = 0;
+ virtual void attach(FileDescription&) = 0;
+ virtual void detach(FileDescription&) = 0;
+ virtual ssize_t sendto(FileDescription&, const void*, size_t, int flags, const sockaddr*, socklen_t) = 0;
+ virtual ssize_t recvfrom(FileDescription&, void*, size_t, int flags, sockaddr*, socklen_t*) = 0;
KResult setsockopt(int level, int option, const void*, socklen_t);
KResult getsockopt(int level, int option, void*, socklen_t*);
@@ -62,7 +62,7 @@ public:
Lock& lock() { return m_lock; }
- virtual String absolute_path(const FileDescriptor&) const override;
+ virtual String absolute_path(const FileDescription&) const override;
protected:
Socket(int domain, int type, int protocol);
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index acb3c47569..fe60425fd3 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -148,7 +148,7 @@ NetworkOrdered<word> TCPSocket::compute_tcp_checksum(const IPv4Address& source,
return ~(checksum & 0xffff);
}
-KResult TCPSocket::protocol_connect(FileDescriptor& descriptor, ShouldBlock should_block)
+KResult TCPSocket::protocol_connect(FileDescription& descriptor, ShouldBlock should_block)
{
auto* adapter = adapter_for_route_to(peer_address());
if (!adapter)
diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h
index 35856d7ae8..7ced06f56f 100644
--- a/Kernel/Net/TCPSocket.h
+++ b/Kernel/Net/TCPSocket.h
@@ -36,7 +36,7 @@ private:
virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags, sockaddr* addr, socklen_t* addr_length) override;
virtual int protocol_send(const void*, int) override;
- virtual KResult protocol_connect(FileDescriptor&, ShouldBlock) override;
+ virtual KResult protocol_connect(FileDescription&, ShouldBlock) override;
virtual int protocol_allocate_local_port() override;
virtual bool protocol_is_disconnected() const override;
virtual KResult protocol_bind() override;
diff --git a/Kernel/Net/UDPSocket.h b/Kernel/Net/UDPSocket.h
index a76eaa7fe7..80ef09b7bf 100644
--- a/Kernel/Net/UDPSocket.h
+++ b/Kernel/Net/UDPSocket.h
@@ -18,7 +18,7 @@ private:
virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags, sockaddr* addr, socklen_t* addr_length) override;
virtual int protocol_send(const void*, int) override;
- virtual KResult protocol_connect(FileDescriptor&, ShouldBlock) override { return KSuccess; }
+ virtual KResult protocol_connect(FileDescription&, ShouldBlock) override { return KSuccess; }
virtual int protocol_allocate_local_port() override;
virtual KResult protocol_bind() override;
};
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index a4a9e03205..2e219f7612 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -3,7 +3,7 @@
#include "kmalloc.h"
#include "StdLib.h"
#include "i386.h"
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/Devices/NullDevice.h>
#include <Kernel/VM/MemoryManager.h>
@@ -190,7 +190,7 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params)
}
if (offset & ~PAGE_MASK)
return (void*)-EINVAL;
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return (void*)-EBADF;
auto region_or_error = descriptor->mmap(*this, LinearAddress((dword)addr), offset, size, prot);
@@ -765,7 +765,7 @@ Process* Process::from_pid(pid_t pid)
return nullptr;
}
-FileDescriptor* Process::file_descriptor(int fd)
+FileDescription* Process::file_description(int fd)
{
if (fd < 0)
return nullptr;
@@ -774,7 +774,7 @@ FileDescriptor* Process::file_descriptor(int fd)
return nullptr;
}
-const FileDescriptor* Process::file_descriptor(int fd) const
+const FileDescription* Process::file_description(int fd) const
{
if (fd < 0)
return nullptr;
@@ -789,7 +789,7 @@ ssize_t Process::sys$get_dir_entries(int fd, void* buffer, ssize_t size)
return -EINVAL;
if (!validate_write(buffer, size))
return -EFAULT;
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
return descriptor->get_dir_entries((byte*)buffer, size);
@@ -797,7 +797,7 @@ ssize_t Process::sys$get_dir_entries(int fd, void* buffer, ssize_t size)
int Process::sys$lseek(int fd, off_t offset, int whence)
{
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
return descriptor->seek(offset, whence);
@@ -809,7 +809,7 @@ int Process::sys$ttyname_r(int fd, char* buffer, ssize_t size)
return -EINVAL;
if (!validate_write(buffer, size))
return -EFAULT;
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
if (!descriptor->is_tty())
@@ -827,7 +827,7 @@ int Process::sys$ptsname_r(int fd, char* buffer, ssize_t size)
return -EINVAL;
if (!validate_write(buffer, size))
return -EFAULT;
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
auto* master_pty = descriptor->master_pty();
@@ -850,7 +850,7 @@ ssize_t Process::sys$writev(int fd, const struct iovec* iov, int iov_count)
// FIXME: Return EINVAL if sum of iovecs is greater than INT_MAX
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
@@ -874,7 +874,7 @@ ssize_t Process::sys$writev(int fd, const struct iovec* iov, int iov_count)
return nwritten;
}
-ssize_t Process::do_write(FileDescriptor& descriptor, const byte* data, int data_size)
+ssize_t Process::do_write(FileDescription& descriptor, const byte* data, int data_size)
{
ssize_t nwritten = 0;
if (!descriptor.is_blocking()) {
@@ -931,7 +931,7 @@ ssize_t Process::sys$write(int fd, const byte* data, ssize_t size)
#ifdef DEBUG_IO
dbgprintf("%s(%u): sys$write(%d, %p, %u)\n", name().characters(), pid(), fd, data, size);
#endif
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
auto nwritten = do_write(*descriptor, data, size);
@@ -954,7 +954,7 @@ ssize_t Process::sys$read(int fd, byte* buffer, ssize_t size)
#ifdef DEBUG_IO
dbgprintf("%s(%u) sys$read(%d, %p, %u)\n", name().characters(), pid(), fd, buffer, size);
#endif
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
if (descriptor->is_blocking()) {
@@ -969,7 +969,7 @@ ssize_t Process::sys$read(int fd, byte* buffer, ssize_t size)
int Process::sys$close(int fd)
{
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
int rc = descriptor->close();
@@ -1009,10 +1009,10 @@ int Process::sys$fcntl(int fd, int cmd, dword arg)
(void) cmd;
(void) arg;
dbgprintf("sys$fcntl: fd=%d, cmd=%d, arg=%u\n", fd, cmd, arg);
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
- // NOTE: The FD flags are not shared between FileDescriptor objects.
+ // NOTE: The FD flags are not shared between FileDescription objects.
// This means that dup() doesn't copy the FD_CLOEXEC flag!
switch (cmd) {
case F_DUPFD: {
@@ -1045,7 +1045,7 @@ int Process::sys$fstat(int fd, stat* statbuf)
{
if (!validate_write_typed(statbuf))
return -EFAULT;
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
return descriptor->fstat(*statbuf);
@@ -1226,7 +1226,7 @@ int Process::sys$uname(utsname* buf)
int Process::sys$isatty(int fd)
{
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
if (!descriptor->is_tty())
@@ -1607,7 +1607,7 @@ int Process::sys$setpgid(pid_t specified_pid, pid_t specified_pgid)
int Process::sys$ioctl(int fd, unsigned request, unsigned arg)
{
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
return descriptor->file().ioctl(*descriptor, request, arg);
@@ -1620,7 +1620,7 @@ int Process::sys$getdtablesize()
int Process::sys$dup(int old_fd)
{
- auto* descriptor = file_descriptor(old_fd);
+ auto* descriptor = file_description(old_fd);
if (!descriptor)
return -EBADF;
int new_fd = alloc_fd(0);
@@ -1632,7 +1632,7 @@ int Process::sys$dup(int old_fd)
int Process::sys$dup2(int old_fd, int new_fd)
{
- auto* descriptor = file_descriptor(old_fd);
+ auto* descriptor = file_description(old_fd);
if (!descriptor)
return -EBADF;
if (new_fd < 0 || new_fd >= m_max_open_file_descriptors)
@@ -1779,7 +1779,7 @@ int Process::sys$select(const Syscall::SC_select_params* params)
return 0;
for (int fd = 0; fd < params->nfds; ++fd) {
if (FD_ISSET(fd, fds)) {
- if (!file_descriptor(fd))
+ if (!file_description(fd))
return -EBADF;
vector.append(fd);
}
@@ -1806,7 +1806,7 @@ int Process::sys$select(const Syscall::SC_select_params* params)
return;
FD_ZERO(fds);
for (int fd : vector) {
- if (auto* descriptor = file_descriptor(fd); descriptor && should_mark(*descriptor)) {
+ if (auto* descriptor = file_description(fd); descriptor && should_mark(*descriptor)) {
FD_SET(fd, fds);
++marked_fd_count;
}
@@ -1858,7 +1858,7 @@ int Process::sys$poll(pollfd* fds, int nfds, int timeout)
int fds_with_revents = 0;
for (int i = 0; i < nfds; ++i) {
- auto* descriptor = file_descriptor(fds[i].fd);
+ auto* descriptor = file_description(fds[i].fd);
if (!descriptor) {
fds[i].revents = POLLNVAL;
continue;
@@ -1934,7 +1934,7 @@ int Process::sys$chmod(const char* pathname, mode_t mode)
int Process::sys$fchmod(int fd, mode_t mode)
{
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
return descriptor->fchmod(mode);
@@ -1942,7 +1942,7 @@ int Process::sys$fchmod(int fd, mode_t mode)
int Process::sys$fchown(int fd, uid_t uid, gid_t gid)
{
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
return descriptor->chown(uid, gid);
@@ -2041,7 +2041,7 @@ int Process::sys$socket(int domain, int type, int protocol)
auto result = Socket::create(domain, type, protocol);
if (result.is_error())
return result.error();
- auto descriptor = FileDescriptor::create(*result.value());
+ auto descriptor = FileDescription::create(*result.value());
unsigned flags = 0;
if (type & SOCK_CLOEXEC)
flags |= FD_CLOEXEC;
@@ -2055,7 +2055,7 @@ int Process::sys$bind(int sockfd, const sockaddr* address, socklen_t address_len
{
if (!validate_read(address, address_length))
return -EFAULT;
- auto* descriptor = file_descriptor(sockfd);
+ auto* descriptor = file_description(sockfd);
if (!descriptor)
return -EBADF;
if (!descriptor->is_socket())
@@ -2066,7 +2066,7 @@ int Process::sys$bind(int sockfd, const sockaddr* address, socklen_t address_len
int Process::sys$listen(int sockfd, int backlog)
{
- auto* descriptor = file_descriptor(sockfd);
+ auto* descriptor = file_description(sockfd);
if (!descriptor)
return -EBADF;
if (!descriptor->is_socket())
@@ -2088,7 +2088,7 @@ int Process::sys$accept(int accepting_socket_fd, sockaddr* address, socklen_t* a
int accepted_socket_fd = alloc_fd();
if (accepted_socket_fd < 0)
return accepted_socket_fd;
- auto* accepting_socket_descriptor = file_descriptor(accepting_socket_fd);
+ auto* accepting_socket_descriptor = file_description(accepting_socket_fd);
if (!accepting_socket_descriptor)
return -EBADF;
if (!accepting_socket_descriptor->is_socket())
@@ -2102,7 +2102,7 @@ int Process::sys$accept(int accepting_socket_fd, sockaddr* address, socklen_t* a
ASSERT(accepted_socket);
bool success = accepted_socket->get_local_address(address, address_size);
ASSERT(success);
- auto accepted_socket_descriptor = FileDescriptor::create(move(accepted_socket), SocketRole::Accepted);
+ auto accepted_socket_descriptor = FileDescription::create(move(accepted_socket), SocketRole::Accepted);
// NOTE: The accepted socket inherits fd flags from the accepting socket.
// I'm not sure if this matches other systems but it makes sense to me.
accepted_socket_descriptor->set_blocking(accepting_socket_descriptor->is_blocking());
@@ -2117,7 +2117,7 @@ int Process::sys$connect(int sockfd, const sockaddr* address, socklen_t address_
int fd = alloc_fd();
if (fd < 0)
return fd;
- auto* descriptor = file_descriptor(sockfd);
+ auto* descriptor = file_description(sockfd);
if (!descriptor)
return -EBADF;
if (!descriptor->is_socket())
@@ -2151,7 +2151,7 @@ ssize_t Process::sys$sendto(const Syscall::SC_sendto_params* params)
return -EFAULT;
if (addr && !validate_read(addr, addr_length))
return -EFAULT;
- auto* descriptor = file_descriptor(sockfd);
+ auto* descriptor = file_description(sockfd);
if (!descriptor)
return -EBADF;
if (!descriptor->is_socket())
@@ -2183,7 +2183,7 @@ ssize_t Process::sys$recvfrom(const Syscall::SC_recvfrom_params* params)
} else if (addr) {
return -EINVAL;
}
- auto* descriptor = file_descriptor(sockfd);
+ auto* descriptor = file_description(sockfd);
if (!descriptor)
return -EBADF;
if (!descriptor->is_socket())
@@ -2212,7 +2212,7 @@ int Process::sys$getsockname(int sockfd, sockaddr* addr, socklen_t* addrlen)
if (!validate_write(addr, *addrlen))
return -EFAULT;
- auto* descriptor = file_descriptor(sockfd);
+ auto* descriptor = file_description(sockfd);
if (!descriptor)
return -EBADF;
@@ -2237,7 +2237,7 @@ int Process::sys$getpeername(int sockfd, sockaddr* addr, socklen_t* addrlen)
if (!validate_write(addr, *addrlen))
return -EFAULT;
- auto* descriptor = file_descriptor(sockfd);
+ auto* descriptor = file_description(sockfd);
if (!descriptor)
return -EBADF;
@@ -2312,7 +2312,7 @@ int Process::sys$getsockopt(const Syscall::SC_getsockopt_params* params)
return -EFAULT;
if (!validate_write(value, *value_size))
return -EFAULT;
- auto* descriptor = file_descriptor(sockfd);
+ auto* descriptor = file_description(sockfd);
if (!descriptor)
return -EBADF;
if (!descriptor->is_socket())
@@ -2333,7 +2333,7 @@ int Process::sys$setsockopt(const Syscall::SC_setsockopt_params* params)
if (!validate_read(value, value_size))
return -EFAULT;
- auto* descriptor = file_descriptor(sockfd);
+ auto* descriptor = file_description(sockfd);
if (!descriptor)
return -EBADF;
if (!descriptor->is_socket())
@@ -2672,7 +2672,7 @@ int Process::sys$shm_open(const char* name, int flags, mode_t mode)
auto shm_or_error = SharedMemory::open(String(name), flags, mode);
if (shm_or_error.is_error())
return shm_or_error.error();
- auto descriptor = FileDescriptor::create(shm_or_error.value().ptr());
+ auto descriptor = FileDescription::create(shm_or_error.value().ptr());
m_fds[fd].set(move(descriptor), FD_CLOEXEC);
return fd;
}
@@ -2686,7 +2686,7 @@ int Process::sys$shm_unlink(const char* name)
int Process::sys$ftruncate(int fd, off_t length)
{
- auto* descriptor = file_descriptor(fd);
+ auto* descriptor = file_description(fd);
if (!descriptor)
return -EBADF;
// FIXME: Check that fd is writable, otherwise EINVAL.
@@ -2704,7 +2704,7 @@ int Process::sys$systrace(pid_t pid)
int fd = alloc_fd();
if (fd < 0)
return fd;
- auto descriptor = FileDescriptor::create(peer->ensure_tracer());
+ auto descriptor = FileDescription::create(peer->ensure_tracer());
m_fds[fd].set(move(descriptor), 0);
return fd;
}
@@ -2716,13 +2716,13 @@ ProcessTracer& Process::ensure_tracer()
return *m_tracer;
}
-void Process::FileDescriptorAndFlags::clear()
+void Process::FileDescriptionAndFlags::clear()
{
descriptor = nullptr;
flags = 0;
}
-void Process::FileDescriptorAndFlags::set(Retained<FileDescriptor>&& d, dword f)
+void Process::FileDescriptionAndFlags::set(Retained<FileDescription>&& d, dword f)
{
descriptor = move(d);
flags = f;
diff --git a/Kernel/Process.h b/Kernel/Process.h
index b5cadaec0c..a792e5a2a2 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -16,7 +16,7 @@
#include <LibC/signal_numbers.h>
class ELFLoader;
-class FileDescriptor;
+class FileDescription;
class PageDirectory;
class Region;
class VMObject;
@@ -87,8 +87,8 @@ public:
bool in_group(gid_t) const;
- FileDescriptor* file_descriptor(int fd);
- const FileDescriptor* file_descriptor(int fd) const;
+ FileDescription* file_description(int fd);
+ const FileDescription* file_description(int fd) const;
template<typename Callback>
static void for_each(Callback);
@@ -280,7 +280,7 @@ private:
Range allocate_range(LinearAddress, size_t);
int do_exec(String path, Vector<String> arguments, Vector<String> environment);
- ssize_t do_write(FileDescriptor&, const byte*, int data_size);
+ ssize_t do_write(FileDescription&, const byte*, int data_size);
int alloc_fd(int first_candidate_fd = 0);
void disown_all_shared_buffers();
@@ -306,17 +306,17 @@ private:
Priority m_priority { NormalPriority };
- struct FileDescriptorAndFlags {
+ struct FileDescriptionAndFlags {
operator bool() const { return !!descriptor; }
void clear();
- void set(Retained<FileDescriptor>&& d, dword f = 0);
- RetainPtr<FileDescriptor> descriptor;
+ void set(Retained<FileDescription>&& d, dword f = 0);
+ RetainPtr<FileDescription> descriptor;
dword flags { 0 };
};
- Vector<FileDescriptorAndFlags> m_fds;
+ Vector<FileDescriptionAndFlags> m_fds;
RingLevel m_ring { Ring0 };
- int m_max_open_file_descriptors { 128 };
+ static const int m_max_open_file_descriptors { FD_SETSIZE };
byte m_termination_status { 0 };
byte m_termination_signal { 0 };
diff --git a/Kernel/ProcessTracer.cpp b/Kernel/ProcessTracer.cpp
index e81568b4a0..66aeb8ac49 100644
--- a/Kernel/ProcessTracer.cpp
+++ b/Kernel/ProcessTracer.cpp
@@ -18,7 +18,7 @@ void ProcessTracer::did_syscall(dword function, dword arg1, dword arg2, dword ar
m_calls.enqueue(data);
}
-int ProcessTracer::read(FileDescriptor&, byte* buffer, int buffer_size)
+int ProcessTracer::read(FileDescription&, byte* buffer, int buffer_size)
{
if (m_calls.is_empty())
return 0;
@@ -29,7 +29,7 @@ int ProcessTracer::read(FileDescriptor&, byte* buffer, int buffer_size)
return sizeof(data);
}
-String ProcessTracer::absolute_path(const FileDescriptor&) const
+String ProcessTracer::absolute_path(const FileDescription&) const
{
return String::format("tracer:%d", m_pid);
}
diff --git a/Kernel/ProcessTracer.h b/Kernel/ProcessTracer.h
index 3f23e4e31d..0b71b0ba0a 100644
--- a/Kernel/ProcessTracer.h
+++ b/Kernel/ProcessTracer.h
@@ -12,13 +12,13 @@ public:
bool is_dead() const { return m_dead; }
void set_dead() { m_dead = true; }
- virtual bool can_read(FileDescriptor&) const override { return !m_calls.is_empty() || m_dead; }
- virtual int read(FileDescriptor&, byte*, int) override;
+ virtual bool can_read(FileDescription&) const override { return !m_calls.is_empty() || m_dead; }
+ virtual int read(FileDescription&, byte*, int) override;
- virtual bool can_write(FileDescriptor&) const override { return true; }
- virtual int write(FileDescriptor&, const byte*, int) override { return -EIO; }
+ virtual bool can_write(FileDescription&) const override { return true; }
+ virtual int write(FileDescription&, const byte*, int) override { return -EIO; }
- virtual String absolute_path(const FileDescriptor&) const override;
+ virtual String absolute_path(const FileDescription&) const override;
void did_syscall(dword function, dword arg1, dword arg2, dword arg3, dword result);
pid_t pid() const { return m_pid; }
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp
index 98c357e6b1..5063f157e7 100644
--- a/Kernel/Scheduler.cpp
+++ b/Kernel/Scheduler.cpp
@@ -4,7 +4,7 @@
#include "i8253.h"
#include <AK/TemporaryChange.h>
#include <Kernel/Alarm.h>
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Devices/PCSpeaker.h>
//#define LOG_EVERY_CONTEXT_SWITCH
diff --git a/Kernel/SharedMemory.cpp b/Kernel/SharedMemory.cpp
index 830c8ffee9..5f4e54c4dd 100644
--- a/Kernel/SharedMemory.cpp
+++ b/Kernel/SharedMemory.cpp
@@ -68,12 +68,12 @@ KResult SharedMemory::truncate(int length)
return KResult(-ENOTIMPL);
}
-String SharedMemory::absolute_path(const FileDescriptor&) const
+String SharedMemory::absolute_path(const FileDescription&) const
{
return String::format("shm:%u", this);
}
-int SharedMemory::read(FileDescriptor&, byte* buffer, int buffer_size)
+int SharedMemory::read(FileDescription&, byte* buffer, int buffer_size)
{
UNUSED_PARAM(buffer);
UNUSED_PARAM(buffer_size);
@@ -81,7 +81,7 @@ int SharedMemory::read(FileDescriptor&, byte* buffer, int buffer_size)
ASSERT_NOT_REACHED();
}
-int SharedMemory::write(FileDescriptor&, const byte* data, int data_size)
+int SharedMemory::write(FileDescription&, const byte* data, int data_size)
{
UNUSED_PARAM(data);
UNUSED_PARAM(data_size);
@@ -89,7 +89,7 @@ int SharedMemory::write(FileDescriptor&, const byte* data, int data_size)
ASSERT_NOT_REACHED();
}
-KResultOr<Region*> SharedMemory::mmap(Process& process, FileDescriptor&, LinearAddress laddr, size_t offset, size_t size, int prot)
+KResultOr<Region*> SharedMemory::mmap(Process& process, FileDescription&, LinearAddress laddr, size_t offset, size_t size, int prot)
{
if (!vmo())
return KResult(-ENODEV);
diff --git a/Kernel/SharedMemory.h b/Kernel/SharedMemory.h
index b0de2e5009..c0ec93a132 100644
--- a/Kernel/SharedMemory.h
+++ b/Kernel/SharedMemory.h
@@ -24,14 +24,14 @@ public:
private:
// ^File
- virtual bool can_read(FileDescriptor&) const override { return true; }
- virtual bool can_write(FileDescriptor&) const override { return true; }
- virtual int read(FileDescriptor&, byte*, int) override;
- virtual int write(FileDescriptor&, const byte*, int) override;
- virtual String absolute_path(const FileDescriptor&) const override;
+ virtual bool can_read(FileDescription&) const override { return true; }
+ virtual bool can_write(FileDescription&) const override { return true; }
+ virtual int read(FileDescription&, byte*, int) override;
+ virtual int write(FileDescription&, const byte*, int) override;
+ virtual String absolute_path(const FileDescription&) const override;
virtual const char* class_name() const override { return "SharedMemory"; }
virtual bool is_shared_memory() const override { return true; }
- virtual KResultOr<Region*> mmap(Process&, FileDescriptor&, LinearAddress, size_t offset, size_t size, int prot) override;
+ virtual KResultOr<Region*> mmap(Process&, FileDescription&, LinearAddress, size_t offset, size_t size, int prot) override;
SharedMemory(const String& name, uid_t, gid_t, mode_t);
diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp
index 22e87495b0..c3eb39b0b1 100644
--- a/Kernel/TTY/MasterPTY.cpp
+++ b/Kernel/TTY/MasterPTY.cpp
@@ -31,14 +31,14 @@ String MasterPTY::pts_name() const
return m_pts_name;
}
-ssize_t MasterPTY::read(FileDescriptor&, byte* buffer, ssize_t size)
+ssize_t MasterPTY::read(FileDescription&, byte* buffer, ssize_t size)
{
if (!m_slave && m_buffer.is_empty())
return 0;
return m_buffer.read(buffer, size);
}
-ssize_t MasterPTY::write(FileDescriptor&, const byte* buffer, ssize_t size)
+ssize_t MasterPTY::write(FileDescription&, const byte* buffer, ssize_t size)
{
if (!m_slave)
return -EIO;
@@ -46,14 +46,14 @@ ssize_t MasterPTY::write(FileDescriptor&, const byte* buffer, ssize_t size)
return size;
}
-bool MasterPTY::can_read(FileDescriptor&) const
+bool MasterPTY::can_read(FileDescription&) const
{
if (!m_slave)
return true;
return !m_buffer.is_empty();
}
-bool MasterPTY::can_write(FileDescriptor&) const
+bool MasterPTY::can_write(FileDescription&) const
{
return true;
}
@@ -64,7 +64,7 @@ void MasterPTY::notify_slave_closed(Badge<SlavePTY>)
dbgprintf("MasterPTY(%u): slave closed, my retains: %u, slave retains: %u\n", m_index, retain_count(), m_slave->retain_count());
#endif
// +1 retain for my MasterPTY::m_slave
- // +1 retain for FileDescriptor::m_device
+ // +1 retain for FileDescription::m_device
if (m_slave->retain_count() == 2)
m_slave = nullptr;
}
@@ -88,7 +88,7 @@ void MasterPTY::close()
{
if (retain_count() == 2) {
InterruptDisabler disabler;
- // After the closing FileDescriptor dies, slave is the only thing keeping me alive.
+ // After the closing FileDescription dies, slave is the only thing keeping me alive.
// From this point, let's consider ourselves closed.
m_closed = true;
@@ -96,7 +96,7 @@ void MasterPTY::close()
}
}
-int MasterPTY::ioctl(FileDescriptor& descriptor, unsigned request, unsigned arg)
+int MasterPTY::ioctl(FileDescription& descriptor, unsigned request, unsigned arg)
{
if (request == TIOCSWINSZ)
return m_slave->ioctl(descriptor, request, arg);
diff --git a/Kernel/TTY/MasterPTY.h b/Kernel/TTY/MasterPTY.h
index 22fd3db48e..accb6902bc 100644
--- a/Kernel/TTY/MasterPTY.h
+++ b/Kernel/TTY/MasterPTY.h
@@ -20,13 +20,13 @@ public:
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual bool can_read(FileDescriptor&) const override;
- virtual bool can_write(FileDescriptor&) const override;
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual bool can_write(FileDescription&) const override;
virtual void close() override;
virtual bool is_master_pty() const override { return true; }
- virtual int ioctl(FileDescriptor&, unsigned request, unsigned arg) override;
+ virtual int ioctl(FileDescription&, unsigned request, unsigned arg) override;
virtual const char* class_name() const override { return "MasterPTY"; }
RetainPtr<SlavePTY> m_slave;
diff --git a/Kernel/TTY/PTYMultiplexer.cpp b/Kernel/TTY/PTYMultiplexer.cpp
index 1620f8f952..3b8b596502 100644
--- a/Kernel/TTY/PTYMultiplexer.cpp
+++ b/Kernel/TTY/PTYMultiplexer.cpp
@@ -1,6 +1,6 @@
#include "PTYMultiplexer.h"
#include "MasterPTY.h"
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Process.h>
#include <LibC/errno_numbers.h>
@@ -28,7 +28,7 @@ PTYMultiplexer::~PTYMultiplexer()
{
}
-KResultOr<Retained<FileDescriptor>> PTYMultiplexer::open(int options)
+KResultOr<Retained<FileDescription>> PTYMultiplexer::open(int options)
{
UNUSED_PARAM(options);
LOCKER(m_lock);
@@ -39,7 +39,7 @@ KResultOr<Retained<FileDescriptor>> PTYMultiplexer::open(int options)
#ifdef PTMX_DEBUG
dbgprintf("PTYMultiplexer::open: Vending master %u\n", master->index());
#endif
- return FileDescriptor::create(master.ptr());
+ return FileDescription::create(master.ptr());
}
void PTYMultiplexer::notify_master_destroyed(Badge<MasterPTY>, unsigned index)
diff --git a/Kernel/TTY/PTYMultiplexer.h b/Kernel/TTY/PTYMultiplexer.h
index 1d06d6f4d8..b25a5674fc 100644
--- a/Kernel/TTY/PTYMultiplexer.h
+++ b/Kernel/TTY/PTYMultiplexer.h
@@ -15,11 +15,11 @@ public:
static PTYMultiplexer& the();
// ^CharacterDevice
- virtual KResultOr<Retained<FileDescriptor>> open(int options) override;
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override { return 0; }
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override { return 0; }
- virtual bool can_read(FileDescriptor&) const override { return true; }
- virtual bool can_write(FileDescriptor&) const override { return true; }
+ virtual KResultOr<Retained<FileDescription>> open(int options) override;
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override { return 0; }
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override { return 0; }
+ virtual bool can_read(FileDescription&) const override { return true; }
+ virtual bool can_write(FileDescription&) const override { return true; }
void notify_master_destroyed(Badge<MasterPTY>, unsigned index);
diff --git a/Kernel/TTY/SlavePTY.cpp b/Kernel/TTY/SlavePTY.cpp
index f40392037c..102a7ee48a 100644
--- a/Kernel/TTY/SlavePTY.cpp
+++ b/Kernel/TTY/SlavePTY.cpp
@@ -41,19 +41,19 @@ ssize_t SlavePTY::on_tty_write(const byte* data, ssize_t size)
return m_master->on_slave_write(data, size);
}
-bool SlavePTY::can_write(FileDescriptor&) const
+bool SlavePTY::can_write(FileDescription&) const
{
return m_master->can_write_from_slave();
}
-bool SlavePTY::can_read(FileDescriptor& descriptor) const
+bool SlavePTY::can_read(FileDescription& descriptor) const
{
if (m_master->is_closed())
return true;
return TTY::can_read(descriptor);
}
-ssize_t SlavePTY::read(FileDescriptor& descriptor, byte* buffer, ssize_t size)
+ssize_t SlavePTY::read(FileDescription& descriptor, byte* buffer, ssize_t size)
{
if (m_master->is_closed())
return 0;
diff --git a/Kernel/TTY/SlavePTY.h b/Kernel/TTY/SlavePTY.h
index ffe7ebd8b1..83387d8731 100644
--- a/Kernel/TTY/SlavePTY.h
+++ b/Kernel/TTY/SlavePTY.h
@@ -21,9 +21,9 @@ private:
virtual ssize_t on_tty_write(const byte*, ssize_t) override;
// ^CharacterDevice
- virtual bool can_read(FileDescriptor&) const override;
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual bool can_write(FileDescriptor&) const override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual bool can_write(FileDescription&) const override;
virtual const char* class_name() const override { return "SlavePTY"; }
virtual void close() override;
diff --git a/Kernel/TTY/TTY.cpp b/Kernel/TTY/TTY.cpp
index 3a659a9585..eb82d6f720 100644
--- a/Kernel/TTY/TTY.cpp
+++ b/Kernel/TTY/TTY.cpp
@@ -24,12 +24,12 @@ void TTY::set_default_termios()
memcpy(m_termios.c_cc, default_cc, sizeof(default_cc));
}
-ssize_t TTY::read(FileDescriptor&, byte* buffer, ssize_t size)
+ssize_t TTY::read(FileDescription&, byte* buffer, ssize_t size)
{
return m_buffer.read(buffer, size);
}
-ssize_t TTY::write(FileDescriptor&, const byte* buffer, ssize_t size)
+ssize_t TTY::write(FileDescription&, const byte* buffer, ssize_t size)
{
#ifdef TTY_DEBUG
dbgprintf("TTY::write {%u} ", size);
@@ -42,12 +42,12 @@ ssize_t TTY::write(FileDescriptor&, const byte* buffer, ssize_t size)
return size;
}
-bool TTY::can_read(FileDescriptor&) const
+bool TTY::can_read(FileDescription&) const
{
return !m_buffer.is_empty();
}
-bool TTY::can_write(FileDescriptor&) const
+bool TTY::can_write(FileDescription&) const
{
return true;
}
@@ -111,7 +111,7 @@ void TTY::set_termios(const termios& t)
);
}
-int TTY::ioctl(FileDescriptor&, unsigned request, unsigned arg)
+int TTY::ioctl(FileDescription&, unsigned request, unsigned arg)
{
auto& process = current->process();
pid_t pgid;
diff --git a/Kernel/TTY/TTY.h b/Kernel/TTY/TTY.h
index 150b7c3761..78c7762829 100644
--- a/Kernel/TTY/TTY.h
+++ b/Kernel/TTY/TTY.h
@@ -10,12 +10,12 @@ class TTY : public CharacterDevice {
public:
virtual ~TTY() override;
- virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
- virtual bool can_read(FileDescriptor&) const override;
- virtual bool can_write(FileDescriptor&) const override;
- virtual int ioctl(FileDescriptor&, unsigned request, unsigned arg) override final;
- virtual String absolute_path(const FileDescriptor&) const override { return tty_name(); }
+ virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual bool can_read(FileDescription&) const override;
+ virtual bool can_write(FileDescription&) const override;
+ virtual int ioctl(FileDescription&, unsigned request, unsigned arg) override final;
+ virtual String absolute_path(const FileDescription&) const override { return tty_name(); }
virtual String tty_name() const = 0;
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index 62caa2ce23..0d53125938 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -1,7 +1,7 @@
#include <Kernel/Thread.h>
#include <Kernel/Scheduler.h>
#include <Kernel/Process.h>
-#include <Kernel/FileSystem/FileDescriptor.h>
+#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibC/signal_numbers.h>
@@ -129,7 +129,7 @@ void Thread::block(Thread::State new_state)
process().big_lock().lock();
}
-void Thread::block(Thread::State new_state, FileDescriptor& descriptor)
+void Thread::block(Thread::State new_state, FileDescription& descriptor)
{
m_blocked_descriptor = &descriptor;
block(new_state);
@@ -512,7 +512,7 @@ Thread* Thread::clone(Process& process)
return clone;
}
-KResult Thread::wait_for_connect(FileDescriptor& descriptor)
+KResult Thread::wait_for_connect(FileDescription& descriptor)
{
ASSERT(descriptor.is_socket());
auto& socket = *descriptor.socket();
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index 40f7abba11..328d2b0388 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -12,7 +12,7 @@
#include <Kernel/i386.h>
class Alarm;
-class FileDescriptor;
+class FileDescription;
class Process;
class Region;
class Thread;
@@ -97,13 +97,13 @@ public:
void sleep(dword ticks);
void block(Thread::State);
- void block(Thread::State, FileDescriptor&);
+ void block(Thread::State, FileDescription&);
void unblock();
void set_wakeup_time(qword t) { m_wakeup_time = t; }
qword wakeup_time() const { return m_wakeup_time; }
void snooze_until(Alarm&);
- KResult wait_for_connect(FileDescriptor&);
+ KResult wait_for_connect(FileDescription&);
const FarPtr& far_ptr() const { return m_far_ptr; }
@@ -181,7 +181,7 @@ private:
RetainPtr<Region> m_kernel_stack_region;
RetainPtr<Region> m_kernel_stack_for_signal_handler_region;
pid_t m_waitee_pid { -1 };
- RetainPtr<FileDescriptor> m_blocked_descriptor;
+ RetainPtr<FileDescription> m_blocked_descriptor;
timeval m_select_timeout;
SignalActionData m_signal_action_data[32];
Region* m_signal_stack_user_region { nullptr };