1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:07:44 +00:00

Kernel: Tidy up FileDescriptor members a bit.

This commit is contained in:
Andreas Kling 2019-05-18 04:14:22 +02:00
parent 123283d840
commit 237628a7a6
5 changed files with 10 additions and 13 deletions

View file

@ -51,12 +51,12 @@ FIFO::~FIFO()
void FIFO::attach(Direction direction) void FIFO::attach(Direction direction)
{ {
if (direction == Reader) { if (direction == Direction::Reader) {
++m_readers; ++m_readers;
#ifdef FIFO_DEBUG #ifdef FIFO_DEBUG
kprintf("open reader (%u)\n", m_readers); kprintf("open reader (%u)\n", m_readers);
#endif #endif
} else if (direction == Writer) { } else if (direction == Direction::Writer) {
++m_writers; ++m_writers;
#ifdef FIFO_DEBUG #ifdef FIFO_DEBUG
kprintf("open writer (%u)\n", m_writers); kprintf("open writer (%u)\n", m_writers);
@ -66,13 +66,13 @@ void FIFO::attach(Direction direction)
void FIFO::detach(Direction direction) void FIFO::detach(Direction direction)
{ {
if (direction == Reader) { if (direction == Direction::Reader) {
#ifdef FIFO_DEBUG #ifdef FIFO_DEBUG
kprintf("close reader (%u - 1)\n", m_readers); kprintf("close reader (%u - 1)\n", m_readers);
#endif #endif
ASSERT(m_readers); ASSERT(m_readers);
--m_readers; --m_readers;
} else if (direction == Writer) { } else if (direction == Direction::Writer) {
#ifdef FIFO_DEBUG #ifdef FIFO_DEBUG
kprintf("close writer (%u - 1)\n", m_writers); kprintf("close writer (%u - 1)\n", m_writers);
#endif #endif

View file

@ -8,7 +8,7 @@ class FileDescriptor;
class FIFO final : public File { class FIFO final : public File {
public: public:
enum Direction { enum class Direction : byte {
Neither, Reader, Writer Neither, Reader, Writer
}; };

View file

@ -110,13 +110,10 @@ private:
ByteBuffer m_generator_cache; ByteBuffer m_generator_cache;
bool m_is_blocking { true };
dword m_file_flags { 0 }; dword m_file_flags { 0 };
bool m_is_blocking { true };
SocketRole m_socket_role { SocketRole::None }; SocketRole m_socket_role { SocketRole::None };
FIFO::Direction m_fifo_direction { FIFO::Direction::Neither };
FIFO::Direction m_fifo_direction { FIFO::Neither };
bool m_closed { false };
}; };

View file

@ -9,7 +9,7 @@
#include <Kernel/UnixTypes.h> #include <Kernel/UnixTypes.h>
#include <Kernel/KResult.h> #include <Kernel/KResult.h>
enum class SocketRole { None, Listener, Accepted, Connected, Connecting }; enum class SocketRole : byte { None, Listener, Accepted, Connected, Connecting };
enum class ShouldBlock { No = 0, Yes = 1 }; enum class ShouldBlock { No = 0, Yes = 1 };
class FileDescriptor; class FileDescriptor;

View file

@ -1140,11 +1140,11 @@ int Process::sys$pipe(int pipefd[2])
auto fifo = FIFO::create(m_uid); auto fifo = FIFO::create(m_uid);
int reader_fd = alloc_fd(); int reader_fd = alloc_fd();
m_fds[reader_fd].set(fifo->open_direction(FIFO::Reader)); m_fds[reader_fd].set(fifo->open_direction(FIFO::Direction::Reader));
pipefd[0] = reader_fd; pipefd[0] = reader_fd;
int writer_fd = alloc_fd(); int writer_fd = alloc_fd();
m_fds[writer_fd].set(fifo->open_direction(FIFO::Writer)); m_fds[writer_fd].set(fifo->open_direction(FIFO::Direction::Writer));
pipefd[1] = writer_fd; pipefd[1] = writer_fd;
return 0; return 0;