mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00:00
Kernel: Make FIFO inherit from File.
This commit is contained in:
parent
f254a84d17
commit
0a0d739e98
18 changed files with 96 additions and 72 deletions
|
@ -1,4 +1,5 @@
|
||||||
#include "CharacterDevice.h"
|
#include <Kernel/Devices/Device.h>
|
||||||
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
|
|
||||||
Device::Device(unsigned major, unsigned minor)
|
Device::Device(unsigned major, unsigned minor)
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <Kernel/File.h>
|
#include <Kernel/File.h>
|
||||||
|
#include <Kernel/UnixTypes.h>
|
||||||
|
|
||||||
class Device : public File {
|
class Device : public File {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <Kernel/Devices/CharacterDevice.h>
|
#include <Kernel/Devices/CharacterDevice.h>
|
||||||
#include <Kernel/MousePacket.h>
|
#include <Kernel/MousePacket.h>
|
||||||
#include <Kernel/IRQHandler.h>
|
#include <Kernel/IRQHandler.h>
|
||||||
|
#include <AK/CircularQueue.h>
|
||||||
|
|
||||||
class PS2MouseDevice final : public IRQHandler, public CharacterDevice {
|
class PS2MouseDevice final : public IRQHandler, public CharacterDevice {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/AKString.h>
|
||||||
#include <AK/Retainable.h>
|
#include <AK/Retainable.h>
|
||||||
|
#include <AK/Retained.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <Kernel/FileSystem/FileDescriptor.h>
|
#include <Kernel/KResult.h>
|
||||||
|
#include <Kernel/LinearAddress.h>
|
||||||
|
|
||||||
|
class FileDescriptor;
|
||||||
class Process;
|
class Process;
|
||||||
|
class Region;
|
||||||
|
|
||||||
class File : public Retainable<File> {
|
class File : public Retainable<File> {
|
||||||
public:
|
public:
|
||||||
|
@ -28,6 +33,7 @@ public:
|
||||||
virtual bool is_seekable() const { return false; }
|
virtual bool is_seekable() const { return false; }
|
||||||
|
|
||||||
virtual bool is_shared_memory() const { return false; }
|
virtual bool is_shared_memory() const { return false; }
|
||||||
|
virtual bool is_fifo() const { return false; }
|
||||||
virtual bool is_device() const { return false; }
|
virtual bool is_device() const { return false; }
|
||||||
virtual bool is_tty() const { return false; }
|
virtual bool is_tty() const { return false; }
|
||||||
virtual bool is_master_pty() const { return false; }
|
virtual bool is_master_pty() const { return false; }
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <Kernel/FileSystem/FIFO.h>
|
#include <Kernel/FileSystem/FIFO.h>
|
||||||
|
#include <Kernel/FileSystem/FileDescriptor.h>
|
||||||
#include <Kernel/Lock.h>
|
#include <Kernel/Lock.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <AK/HashTable.h>
|
#include <AK/HashTable.h>
|
||||||
|
@ -27,6 +28,14 @@ Retained<FIFO> FIFO::create(uid_t uid)
|
||||||
return adopt(*new FIFO(uid));
|
return adopt(*new FIFO(uid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Retained<FileDescriptor> FIFO::open_direction(FIFO::Direction direction)
|
||||||
|
{
|
||||||
|
auto descriptor = FileDescriptor::create(this);
|
||||||
|
attach(direction);
|
||||||
|
descriptor->set_fifo_direction({ }, direction);
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
FIFO::FIFO(uid_t uid)
|
FIFO::FIFO(uid_t uid)
|
||||||
: m_uid(uid)
|
: m_uid(uid)
|
||||||
{
|
{
|
||||||
|
@ -40,7 +49,7 @@ FIFO::~FIFO()
|
||||||
all_fifos().resource().remove(this);
|
all_fifos().resource().remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFO::open(Direction direction)
|
void FIFO::attach(Direction direction)
|
||||||
{
|
{
|
||||||
if (direction == Reader) {
|
if (direction == Reader) {
|
||||||
++m_readers;
|
++m_readers;
|
||||||
|
@ -55,7 +64,7 @@ void FIFO::open(Direction direction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFO::close(Direction direction)
|
void FIFO::detach(Direction direction)
|
||||||
{
|
{
|
||||||
if (direction == Reader) {
|
if (direction == Reader) {
|
||||||
#ifdef FIFO_DEBUG
|
#ifdef FIFO_DEBUG
|
||||||
|
@ -72,17 +81,17 @@ void FIFO::close(Direction direction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FIFO::can_read() const
|
bool FIFO::can_read(Process&) const
|
||||||
{
|
{
|
||||||
return !m_buffer.is_empty() || !m_writers;
|
return !m_buffer.is_empty() || !m_writers;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FIFO::can_write() const
|
bool FIFO::can_write(Process&) const
|
||||||
{
|
{
|
||||||
return m_buffer.bytes_in_write_buffer() < 4096;
|
return m_buffer.bytes_in_write_buffer() < 4096;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t FIFO::read(byte* buffer, ssize_t size)
|
ssize_t FIFO::read(Process&, byte* buffer, ssize_t size)
|
||||||
{
|
{
|
||||||
if (!m_writers && m_buffer.is_empty())
|
if (!m_writers && m_buffer.is_empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -96,7 +105,7 @@ ssize_t FIFO::read(byte* buffer, ssize_t size)
|
||||||
return nread;
|
return nread;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t FIFO::write(const byte* buffer, ssize_t size)
|
ssize_t FIFO::write(Process&, const byte* buffer, ssize_t size)
|
||||||
{
|
{
|
||||||
if (!m_readers)
|
if (!m_readers)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -105,3 +114,8 @@ ssize_t FIFO::write(const byte* buffer, ssize_t size)
|
||||||
#endif
|
#endif
|
||||||
return m_buffer.write(buffer, size);
|
return m_buffer.write(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String FIFO::absolute_path() const
|
||||||
|
{
|
||||||
|
return String::format("fifo:%u", this);
|
||||||
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "DoubleBuffer.h"
|
#include <Kernel/DoubleBuffer.h>
|
||||||
#include <AK/Retainable.h>
|
|
||||||
#include <AK/RetainPtr.h>
|
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
|
#include <Kernel/File.h>
|
||||||
|
|
||||||
class FIFO : public Retainable<FIFO> {
|
class FileDescriptor;
|
||||||
|
|
||||||
|
class FIFO final : public File {
|
||||||
public:
|
public:
|
||||||
enum Direction {
|
enum Direction {
|
||||||
Neither, Reader, Writer
|
Neither, Reader, Writer
|
||||||
|
@ -14,20 +15,25 @@ public:
|
||||||
static RetainPtr<FIFO> from_fifo_id(dword);
|
static RetainPtr<FIFO> from_fifo_id(dword);
|
||||||
|
|
||||||
static Retained<FIFO> create(uid_t);
|
static Retained<FIFO> create(uid_t);
|
||||||
~FIFO();
|
virtual ~FIFO() override;
|
||||||
|
|
||||||
uid_t uid() const { return m_uid; }
|
uid_t uid() const { return m_uid; }
|
||||||
|
|
||||||
void open(Direction);
|
Retained<FileDescriptor> open_direction(Direction);
|
||||||
void close(Direction);
|
|
||||||
|
|
||||||
ssize_t write(const byte*, ssize_t);
|
void attach(Direction);
|
||||||
ssize_t read(byte*, ssize_t);
|
void detach(Direction);
|
||||||
|
|
||||||
bool can_read() const;
|
|
||||||
bool can_write() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// ^File
|
||||||
|
virtual ssize_t write(Process&, const byte*, ssize_t) override;
|
||||||
|
virtual ssize_t read(Process&, byte*, ssize_t) override;
|
||||||
|
virtual bool can_read(Process&) const override;
|
||||||
|
virtual bool can_write(Process&) const override;
|
||||||
|
virtual String absolute_path() const override;
|
||||||
|
virtual const char* class_name() const override { return "FIFO"; }
|
||||||
|
virtual bool is_fifo() const override { return true; }
|
||||||
|
|
||||||
explicit FIFO(uid_t);
|
explicit FIFO(uid_t);
|
||||||
|
|
||||||
unsigned m_writers { 0 };
|
unsigned m_writers { 0 };
|
||||||
|
|
|
@ -28,16 +28,6 @@ Retained<FileDescriptor> FileDescriptor::create(RetainPtr<Socket>&& socket, Sock
|
||||||
return adopt(*new FileDescriptor(move(socket), role));
|
return adopt(*new FileDescriptor(move(socket), role));
|
||||||
}
|
}
|
||||||
|
|
||||||
Retained<FileDescriptor> FileDescriptor::create_pipe_writer(FIFO& fifo)
|
|
||||||
{
|
|
||||||
return adopt(*new FileDescriptor(fifo, FIFO::Writer));
|
|
||||||
}
|
|
||||||
|
|
||||||
Retained<FileDescriptor> FileDescriptor::create_pipe_reader(FIFO& fifo)
|
|
||||||
{
|
|
||||||
return adopt(*new FileDescriptor(fifo, FIFO::Reader));
|
|
||||||
}
|
|
||||||
|
|
||||||
FileDescriptor::FileDescriptor(RetainPtr<Inode>&& inode)
|
FileDescriptor::FileDescriptor(RetainPtr<Inode>&& inode)
|
||||||
: m_inode(move(inode))
|
: m_inode(move(inode))
|
||||||
{
|
{
|
||||||
|
@ -60,14 +50,12 @@ FileDescriptor::~FileDescriptor()
|
||||||
m_socket->detach_fd(m_socket_role);
|
m_socket->detach_fd(m_socket_role);
|
||||||
m_socket = nullptr;
|
m_socket = nullptr;
|
||||||
}
|
}
|
||||||
|
if (is_fifo())
|
||||||
|
static_cast<FIFO*>(m_file.ptr())->detach(m_fifo_direction);
|
||||||
if (m_file) {
|
if (m_file) {
|
||||||
m_file->close();
|
m_file->close();
|
||||||
m_file = nullptr;
|
m_file = nullptr;
|
||||||
}
|
}
|
||||||
if (m_fifo) {
|
|
||||||
m_fifo->close(fifo_direction());
|
|
||||||
m_fifo = nullptr;
|
|
||||||
}
|
|
||||||
m_inode = nullptr;
|
m_inode = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,9 +76,7 @@ Retained<FileDescriptor> FileDescriptor::clone()
|
||||||
{
|
{
|
||||||
RetainPtr<FileDescriptor> descriptor;
|
RetainPtr<FileDescriptor> descriptor;
|
||||||
if (is_fifo()) {
|
if (is_fifo()) {
|
||||||
descriptor = fifo_direction() == FIFO::Reader
|
descriptor = fifo()->open_direction(m_fifo_direction);
|
||||||
? FileDescriptor::create_pipe_reader(*m_fifo)
|
|
||||||
: FileDescriptor::create_pipe_writer(*m_fifo);
|
|
||||||
} else {
|
} else {
|
||||||
if (m_file) {
|
if (m_file) {
|
||||||
descriptor = FileDescriptor::create(m_file.copy_ref());
|
descriptor = FileDescriptor::create(m_file.copy_ref());
|
||||||
|
@ -189,10 +175,6 @@ off_t FileDescriptor::seek(off_t offset, int whence)
|
||||||
|
|
||||||
ssize_t FileDescriptor::read(Process& process, byte* buffer, ssize_t count)
|
ssize_t FileDescriptor::read(Process& process, byte* buffer, ssize_t count)
|
||||||
{
|
{
|
||||||
if (is_fifo()) {
|
|
||||||
ASSERT(fifo_direction() == FIFO::Reader);
|
|
||||||
return m_fifo->read(buffer, count);
|
|
||||||
}
|
|
||||||
if (m_file) {
|
if (m_file) {
|
||||||
int nread = m_file->read(process, buffer, count);
|
int nread = m_file->read(process, buffer, count);
|
||||||
if (!m_file->is_seekable())
|
if (!m_file->is_seekable())
|
||||||
|
@ -209,10 +191,6 @@ ssize_t FileDescriptor::read(Process& process, byte* buffer, ssize_t count)
|
||||||
|
|
||||||
ssize_t FileDescriptor::write(Process& process, const byte* data, ssize_t size)
|
ssize_t FileDescriptor::write(Process& process, const byte* data, ssize_t size)
|
||||||
{
|
{
|
||||||
if (is_fifo()) {
|
|
||||||
ASSERT(fifo_direction() == FIFO::Writer);
|
|
||||||
return m_fifo->write(data, size);
|
|
||||||
}
|
|
||||||
if (m_file) {
|
if (m_file) {
|
||||||
int nwritten = m_file->write(process, data, size);
|
int nwritten = m_file->write(process, data, size);
|
||||||
if (m_file->is_seekable())
|
if (m_file->is_seekable())
|
||||||
|
@ -229,10 +207,6 @@ ssize_t FileDescriptor::write(Process& process, const byte* data, ssize_t size)
|
||||||
|
|
||||||
bool FileDescriptor::can_write(Process& process)
|
bool FileDescriptor::can_write(Process& process)
|
||||||
{
|
{
|
||||||
if (is_fifo()) {
|
|
||||||
ASSERT(fifo_direction() == FIFO::Writer);
|
|
||||||
return m_fifo->can_write();
|
|
||||||
}
|
|
||||||
if (m_file)
|
if (m_file)
|
||||||
return m_file->can_write(process);
|
return m_file->can_write(process);
|
||||||
if (m_socket)
|
if (m_socket)
|
||||||
|
@ -242,10 +216,6 @@ bool FileDescriptor::can_write(Process& process)
|
||||||
|
|
||||||
bool FileDescriptor::can_read(Process& process)
|
bool FileDescriptor::can_read(Process& process)
|
||||||
{
|
{
|
||||||
if (is_fifo()) {
|
|
||||||
ASSERT(fifo_direction() == FIFO::Reader);
|
|
||||||
return m_fifo->can_read();
|
|
||||||
}
|
|
||||||
if (m_file)
|
if (m_file)
|
||||||
return m_file->can_read(process);
|
return m_file->can_read(process);
|
||||||
if (m_socket)
|
if (m_socket)
|
||||||
|
@ -374,8 +344,6 @@ bool FileDescriptor::is_fsfile() const
|
||||||
|
|
||||||
KResultOr<String> FileDescriptor::absolute_path()
|
KResultOr<String> FileDescriptor::absolute_path()
|
||||||
{
|
{
|
||||||
if (is_fifo())
|
|
||||||
return String::format("fifo:%u", m_fifo.ptr());
|
|
||||||
if (m_file)
|
if (m_file)
|
||||||
return m_file->absolute_path();
|
return m_file->absolute_path();
|
||||||
if (is_socket())
|
if (is_socket())
|
||||||
|
@ -384,14 +352,6 @@ KResultOr<String> FileDescriptor::absolute_path()
|
||||||
return VFS::the().absolute_path(*m_inode);
|
return VFS::the().absolute_path(*m_inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDescriptor::FileDescriptor(FIFO& fifo, FIFO::Direction direction)
|
|
||||||
: m_is_blocking(true)
|
|
||||||
, m_fifo(fifo)
|
|
||||||
, m_fifo_direction(direction)
|
|
||||||
{
|
|
||||||
m_fifo->open(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
InodeMetadata FileDescriptor::metadata() const
|
InodeMetadata FileDescriptor::metadata() const
|
||||||
{
|
{
|
||||||
if (m_inode)
|
if (m_inode)
|
||||||
|
@ -457,3 +417,15 @@ const SharedMemory* FileDescriptor::shared_memory() const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return static_cast<const SharedMemory*>(m_file.ptr());
|
return static_cast<const SharedMemory*>(m_file.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileDescriptor::is_fifo() const
|
||||||
|
{
|
||||||
|
return m_file && m_file->is_fifo();
|
||||||
|
}
|
||||||
|
|
||||||
|
FIFO* FileDescriptor::fifo()
|
||||||
|
{
|
||||||
|
if (!is_fifo())
|
||||||
|
return nullptr;
|
||||||
|
return static_cast<FIFO*>(m_file.ptr());
|
||||||
|
}
|
||||||
|
|
|
@ -23,8 +23,6 @@ public:
|
||||||
static Retained<FileDescriptor> create(RetainPtr<Socket>&&, SocketRole = SocketRole::None);
|
static Retained<FileDescriptor> create(RetainPtr<Socket>&&, SocketRole = SocketRole::None);
|
||||||
static Retained<FileDescriptor> create(RetainPtr<Inode>&&);
|
static Retained<FileDescriptor> create(RetainPtr<Inode>&&);
|
||||||
static Retained<FileDescriptor> create(RetainPtr<File>&&);
|
static Retained<FileDescriptor> create(RetainPtr<File>&&);
|
||||||
static Retained<FileDescriptor> create_pipe_writer(FIFO&);
|
|
||||||
static Retained<FileDescriptor> create_pipe_reader(FIFO&);
|
|
||||||
~FileDescriptor();
|
~FileDescriptor();
|
||||||
|
|
||||||
Retained<FileDescriptor> clone();
|
Retained<FileDescriptor> clone();
|
||||||
|
@ -80,8 +78,10 @@ public:
|
||||||
Socket* socket() { return m_socket.ptr(); }
|
Socket* socket() { return m_socket.ptr(); }
|
||||||
const Socket* socket() const { return m_socket.ptr(); }
|
const Socket* socket() const { return m_socket.ptr(); }
|
||||||
|
|
||||||
bool is_fifo() const { return m_fifo; }
|
bool is_fifo() const;
|
||||||
|
FIFO* fifo();
|
||||||
FIFO::Direction fifo_direction() { return m_fifo_direction; }
|
FIFO::Direction fifo_direction() { return m_fifo_direction; }
|
||||||
|
void set_fifo_direction(Badge<FIFO>, FIFO::Direction direction) { m_fifo_direction = direction; }
|
||||||
|
|
||||||
bool is_fsfile() const;
|
bool is_fsfile() const;
|
||||||
bool is_shared_memory() const;
|
bool is_shared_memory() const;
|
||||||
|
@ -117,7 +117,6 @@ private:
|
||||||
RetainPtr<Socket> m_socket;
|
RetainPtr<Socket> m_socket;
|
||||||
SocketRole m_socket_role { SocketRole::None };
|
SocketRole m_socket_role { SocketRole::None };
|
||||||
|
|
||||||
RetainPtr<FIFO> m_fifo;
|
|
||||||
FIFO::Direction m_fifo_direction { FIFO::Neither };
|
FIFO::Direction m_fifo_direction { FIFO::Neither };
|
||||||
|
|
||||||
bool m_closed { false };
|
bool m_closed { false };
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "ProcFS.h"
|
#include "ProcFS.h"
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
|
#include <Kernel/FileSystem/FileDescriptor.h>
|
||||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||||
#include <Kernel/VM/MemoryManager.h>
|
#include <Kernel/VM/MemoryManager.h>
|
||||||
#include "StdLib.h"
|
#include "StdLib.h"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "KSyms.h"
|
#include "KSyms.h"
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include "Scheduler.h"
|
#include "Scheduler.h"
|
||||||
|
#include <Kernel/FileSystem/FileDescriptor.h>
|
||||||
|
|
||||||
static KSym* s_ksyms;
|
static KSym* s_ksyms;
|
||||||
dword ksym_lowest_address;
|
dword ksym_lowest_address;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <Kernel/Net/LocalSocket.h>
|
#include <Kernel/Net/LocalSocket.h>
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
|
#include <Kernel/FileSystem/FileDescriptor.h>
|
||||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
|
|
||||||
|
|
|
@ -1105,11 +1105,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(FileDescriptor::create_pipe_reader(*fifo));
|
m_fds[reader_fd].set(fifo->open_direction(FIFO::Reader));
|
||||||
pipefd[0] = reader_fd;
|
pipefd[0] = reader_fd;
|
||||||
|
|
||||||
int writer_fd = alloc_fd();
|
int writer_fd = alloc_fd();
|
||||||
m_fds[writer_fd].set(FileDescriptor::create_pipe_writer(*fifo));
|
m_fds[writer_fd].set(fifo->open_direction(FIFO::Writer));
|
||||||
pipefd[1] = writer_fd;
|
pipefd[1] = writer_fd;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2531,3 +2531,15 @@ ProcessTracer& Process::ensure_tracer()
|
||||||
m_tracer = ProcessTracer::create(m_pid);
|
m_tracer = ProcessTracer::create(m_pid);
|
||||||
return *m_tracer;
|
return *m_tracer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Process::FileDescriptorAndFlags::clear()
|
||||||
|
{
|
||||||
|
descriptor = nullptr;
|
||||||
|
flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Process::FileDescriptorAndFlags::set(Retained<FileDescriptor>&& d, dword f)
|
||||||
|
{
|
||||||
|
descriptor = move(d);
|
||||||
|
flags = f;
|
||||||
|
}
|
||||||
|
|
|
@ -281,8 +281,8 @@ private:
|
||||||
|
|
||||||
struct FileDescriptorAndFlags {
|
struct FileDescriptorAndFlags {
|
||||||
operator bool() const { return !!descriptor; }
|
operator bool() const { return !!descriptor; }
|
||||||
void clear() { descriptor = nullptr; flags = 0; }
|
void clear();
|
||||||
void set(Retained<FileDescriptor>&& d, dword f = 0) { descriptor = move(d); flags = f; }
|
void set(Retained<FileDescriptor>&& d, dword f = 0);
|
||||||
RetainPtr<FileDescriptor> descriptor;
|
RetainPtr<FileDescriptor> descriptor;
|
||||||
dword flags { 0 };
|
dword flags { 0 };
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "i8253.h"
|
#include "i8253.h"
|
||||||
#include <AK/TemporaryChange.h>
|
#include <AK/TemporaryChange.h>
|
||||||
#include <Kernel/Alarm.h>
|
#include <Kernel/Alarm.h>
|
||||||
|
#include <Kernel/FileSystem/FileDescriptor.h>
|
||||||
|
|
||||||
//#define LOG_EVERY_CONTEXT_SWITCH
|
//#define LOG_EVERY_CONTEXT_SWITCH
|
||||||
//#define SCHEDULER_DEBUG
|
//#define SCHEDULER_DEBUG
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "PTYMultiplexer.h"
|
#include "PTYMultiplexer.h"
|
||||||
#include "MasterPTY.h"
|
#include "MasterPTY.h"
|
||||||
|
#include <Kernel/FileSystem/FileDescriptor.h>
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <Kernel/FileSystem/InodeIdentifier.h>
|
||||||
#include <Kernel/TTY/TTY.h>
|
#include <Kernel/TTY/TTY.h>
|
||||||
|
|
||||||
class MasterPTY;
|
class MasterPTY;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <Kernel/Thread.h>
|
#include <Kernel/Thread.h>
|
||||||
#include <Kernel/Scheduler.h>
|
#include <Kernel/Scheduler.h>
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
|
#include <Kernel/Net/Socket.h>
|
||||||
#include <Kernel/VM/MemoryManager.h>
|
#include <Kernel/VM/MemoryManager.h>
|
||||||
#include <LibC/signal_numbers.h>
|
#include <LibC/signal_numbers.h>
|
||||||
|
|
||||||
|
@ -532,3 +533,8 @@ bool Thread::is_thread(void* ptr)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Thread::set_blocked_socket(Socket* socket)
|
||||||
|
{
|
||||||
|
m_blocked_socket = socket;
|
||||||
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ public:
|
||||||
bool has_used_fpu() const { return m_has_used_fpu; }
|
bool has_used_fpu() const { return m_has_used_fpu; }
|
||||||
void set_has_used_fpu(bool b) { m_has_used_fpu = b; }
|
void set_has_used_fpu(bool b) { m_has_used_fpu = b; }
|
||||||
|
|
||||||
void set_blocked_socket(Socket* socket) { m_blocked_socket = socket; }
|
void set_blocked_socket(Socket*);
|
||||||
|
|
||||||
void set_default_signal_dispositions();
|
void set_default_signal_dispositions();
|
||||||
void push_value_on_stack(dword);
|
void push_value_on_stack(dword);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue