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
Notes: sideshowbarker 2024-07-19 14:02:24 +09:00
5 changed files with 10 additions and 13 deletions

View file

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

View file

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

View file

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

View file

@ -9,7 +9,7 @@
#include <Kernel/UnixTypes.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 };
class FileDescriptor;

View file

@ -1140,11 +1140,11 @@ int Process::sys$pipe(int pipefd[2])
auto fifo = FIFO::create(m_uid);
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;
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;
return 0;