mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
More coding style changes.
This commit is contained in:
parent
d824442e3e
commit
f6e27c2abe
Notes:
sideshowbarker
2024-07-19 16:09:08 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f6e27c2abe9
39 changed files with 216 additions and 216 deletions
|
@ -14,7 +14,7 @@ public:
|
|||
m_elements[i] = T();
|
||||
}
|
||||
|
||||
bool isEmpty() const { return !m_size; }
|
||||
bool is_empty() const { return !m_size; }
|
||||
size_t size() const { return m_size; }
|
||||
|
||||
size_t capacity() const { return Capacity; }
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
T dequeue()
|
||||
{
|
||||
ASSERT(!isEmpty());
|
||||
ASSERT(!is_empty());
|
||||
T value = m_elements[m_head];
|
||||
m_head = (m_head + 1) % Capacity;
|
||||
--m_size;
|
||||
|
|
|
@ -67,7 +67,7 @@ int main(int c, char** v)
|
|||
queue.enqueue(3);
|
||||
queue.dump();
|
||||
queue.enqueue(4);
|
||||
ASSERT(!queue.isEmpty());
|
||||
ASSERT(!queue.is_empty());
|
||||
ASSERT(queue.size() == 4);
|
||||
ASSERT(queue.dequeue() == 1);
|
||||
queue.dump();
|
||||
|
@ -77,7 +77,7 @@ int main(int c, char** v)
|
|||
queue.dump();
|
||||
ASSERT(queue.dequeue() == 4);
|
||||
queue.dump();
|
||||
ASSERT(queue.isEmpty());
|
||||
ASSERT(queue.is_empty());
|
||||
queue.enqueue(1);
|
||||
queue.enqueue(2);
|
||||
queue.enqueue(3);
|
||||
|
@ -89,7 +89,7 @@ int main(int c, char** v)
|
|||
ASSERT(queue.dequeue() == 5);
|
||||
ASSERT(queue.dequeue() == 6);
|
||||
ASSERT(queue.dequeue() == 7);
|
||||
ASSERT(queue.isEmpty());
|
||||
ASSERT(queue.is_empty());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ Console::~Console()
|
|||
{
|
||||
}
|
||||
|
||||
bool Console::hasDataAvailableForRead() const
|
||||
bool Console::has_data_available_for_reading() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ void Console::putChar(char ch)
|
|||
IO::out8(0xe9, ch);
|
||||
#endif
|
||||
if (m_implementation)
|
||||
m_implementation->onConsoleReceive(ch);
|
||||
m_implementation->on_sysconsole_receive(ch);
|
||||
}
|
||||
|
||||
ConsoleImplementation::~ConsoleImplementation()
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
class ConsoleImplementation {
|
||||
public:
|
||||
virtual ~ConsoleImplementation();
|
||||
virtual void onConsoleReceive(byte) = 0;
|
||||
virtual void on_sysconsole_receive(byte) = 0;
|
||||
};
|
||||
|
||||
class Console final : public CharacterDevice {
|
||||
|
@ -18,7 +18,7 @@ public:
|
|||
Console();
|
||||
virtual ~Console() override;
|
||||
|
||||
virtual bool hasDataAvailableForRead() const override;
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
virtual ssize_t read(byte* buffer, size_t size) override;
|
||||
virtual ssize_t write(const byte* data, size_t size) override;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ void FIFO::close(Direction direction)
|
|||
|
||||
bool FIFO::can_read() const
|
||||
{
|
||||
return !m_queue.isEmpty() || !m_writers;
|
||||
return !m_queue.is_empty() || !m_writers;
|
||||
}
|
||||
|
||||
bool FIFO::can_write() const
|
||||
|
@ -59,7 +59,7 @@ bool FIFO::can_write() const
|
|||
|
||||
ssize_t FIFO::read(byte* buffer, size_t size)
|
||||
{
|
||||
if (!m_writers && m_queue.isEmpty())
|
||||
if (!m_writers && m_queue.is_empty())
|
||||
return 0;
|
||||
#ifdef FIFO_DEBUG
|
||||
dbgprintf("fifo: read(%u)\n",size);
|
||||
|
|
|
@ -100,7 +100,7 @@ bool IDEDiskDevice::wait_for_irq()
|
|||
return true;
|
||||
}
|
||||
|
||||
void IDEDiskDevice::handleIRQ()
|
||||
void IDEDiskDevice::handle_irq()
|
||||
{
|
||||
#ifdef DISK_DEBUG
|
||||
byte status = IO::in8(0x1f7);
|
||||
|
@ -123,13 +123,13 @@ void IDEDiskDevice::initialize()
|
|||
|
||||
while (IO::in8(IDE0_STATUS) & BUSY);
|
||||
|
||||
enableIRQ();
|
||||
enable_irq();
|
||||
|
||||
IO::out8(0x1F6, 0xA0); // 0xB0 for 2nd device
|
||||
IO::out8(0x3F6, 0xA0); // 0xB0 for 2nd device
|
||||
IO::out8(IDE0_COMMAND, IDENTIFY_DRIVE);
|
||||
|
||||
enableIRQ();
|
||||
enable_irq();
|
||||
wait_for_irq();
|
||||
|
||||
ByteBuffer wbuf = ByteBuffer::createUninitialized(512);
|
||||
|
@ -180,7 +180,7 @@ bool IDEDiskDevice::read_sectors(dword start_sector, word count, byte* outbuf)
|
|||
count,
|
||||
start_sector);
|
||||
#endif
|
||||
disableIRQ();
|
||||
disable_irq();
|
||||
|
||||
auto chs = lba_to_chs(start_sector);
|
||||
|
||||
|
@ -202,7 +202,7 @@ bool IDEDiskDevice::read_sectors(dword start_sector, word count, byte* outbuf)
|
|||
|
||||
IO::out8(IDE0_COMMAND, READ_SECTORS);
|
||||
m_interrupted = false;
|
||||
enableIRQ();
|
||||
enable_irq();
|
||||
wait_for_irq();
|
||||
|
||||
byte status = IO::in8(0x1f7);
|
||||
|
@ -228,7 +228,7 @@ bool IDEDiskDevice::write_sectors(dword start_sector, word count, const byte* da
|
|||
current->pid(),
|
||||
count,
|
||||
start_sector);
|
||||
disableIRQ();
|
||||
disable_irq();
|
||||
|
||||
auto chs = lba_to_chs(start_sector);
|
||||
|
||||
|
@ -259,7 +259,7 @@ bool IDEDiskDevice::write_sectors(dword start_sector, word count, const byte* da
|
|||
}
|
||||
|
||||
m_interrupted = false;
|
||||
enableIRQ();
|
||||
enable_irq();
|
||||
wait_for_irq();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -20,7 +20,7 @@ protected:
|
|||
|
||||
private:
|
||||
// ^IRQHandler
|
||||
virtual void handleIRQ() override;
|
||||
virtual void handle_irq() override;
|
||||
|
||||
// ^DiskDevice
|
||||
virtual const char* class_name() const override;
|
||||
|
|
|
@ -3,23 +3,23 @@
|
|||
#include "PIC.h"
|
||||
|
||||
IRQHandler::IRQHandler(byte irq)
|
||||
: m_irqNumber(irq)
|
||||
: m_irq_number(irq)
|
||||
{
|
||||
registerIRQHandler(m_irqNumber, *this);
|
||||
register_irq_handler(m_irq_number, *this);
|
||||
}
|
||||
|
||||
IRQHandler::~IRQHandler()
|
||||
{
|
||||
unregisterIRQHandler(m_irqNumber, *this);
|
||||
unregister_irq_handler(m_irq_number, *this);
|
||||
}
|
||||
|
||||
void IRQHandler::enableIRQ()
|
||||
void IRQHandler::enable_irq()
|
||||
{
|
||||
PIC::enable(m_irqNumber);
|
||||
PIC::enable(m_irq_number);
|
||||
}
|
||||
|
||||
void IRQHandler::disableIRQ()
|
||||
void IRQHandler::disable_irq()
|
||||
{
|
||||
PIC::disable(m_irqNumber);
|
||||
PIC::disable(m_irq_number);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
class IRQHandler {
|
||||
public:
|
||||
virtual ~IRQHandler();
|
||||
virtual void handleIRQ() = 0;
|
||||
virtual void handle_irq() = 0;
|
||||
|
||||
byte irqNumber() const { return m_irqNumber; }
|
||||
byte irq_number() const { return m_irq_number; }
|
||||
|
||||
void enableIRQ();
|
||||
void disableIRQ();
|
||||
void enable_irq();
|
||||
void disable_irq();
|
||||
|
||||
protected:
|
||||
explicit IRQHandler(byte irq);
|
||||
|
||||
private:
|
||||
byte m_irqNumber { 0 };
|
||||
byte m_irq_number { 0 };
|
||||
};
|
||||
|
||||
|
|
|
@ -43,11 +43,11 @@ void Keyboard::emit(byte ch)
|
|||
key.character = ch;
|
||||
key.modifiers = m_modifiers;
|
||||
if (m_client)
|
||||
m_client->onKeyPress(key);
|
||||
m_client->on_key_pressed(key);
|
||||
m_queue.enqueue(key);
|
||||
}
|
||||
|
||||
void Keyboard::handleIRQ()
|
||||
void Keyboard::handle_irq()
|
||||
{
|
||||
while (IO::in8(0x64) & 1) {
|
||||
byte ch = IO::in8(0x60);
|
||||
|
@ -107,23 +107,23 @@ Keyboard::Keyboard()
|
|||
while (IO::in8(I8042_STATUS ) & DATA_AVAILABLE)
|
||||
IO::in8(I8042_BUFFER);
|
||||
|
||||
enableIRQ();
|
||||
enable_irq();
|
||||
}
|
||||
|
||||
Keyboard::~Keyboard()
|
||||
{
|
||||
}
|
||||
|
||||
bool Keyboard::hasDataAvailableForRead() const
|
||||
bool Keyboard::has_data_available_for_reading() const
|
||||
{
|
||||
return !m_queue.isEmpty();
|
||||
return !m_queue.is_empty();
|
||||
}
|
||||
|
||||
ssize_t Keyboard::read(byte* buffer, size_t size)
|
||||
{
|
||||
ssize_t nread = 0;
|
||||
while ((size_t)nread < size) {
|
||||
if (m_queue.isEmpty())
|
||||
if (m_queue.is_empty())
|
||||
break;
|
||||
buffer[nread++] = m_queue.dequeue().character;
|
||||
}
|
||||
|
|
|
@ -30,16 +30,16 @@ public:
|
|||
virtual ~Keyboard() override;
|
||||
Keyboard();
|
||||
|
||||
void setClient(KeyboardClient* client) { m_client = client; }
|
||||
void set_client(KeyboardClient* client) { m_client = client; }
|
||||
|
||||
private:
|
||||
// ^IRQHandler
|
||||
virtual void handleIRQ() override;
|
||||
virtual void handle_irq() override;
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual ssize_t read(byte* buffer, size_t) override;
|
||||
virtual ssize_t write(const byte* buffer, size_t) override;
|
||||
virtual bool hasDataAvailableForRead() const override;
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
|
||||
void emit(byte);
|
||||
|
||||
|
@ -51,5 +51,5 @@ private:
|
|||
class KeyboardClient {
|
||||
public:
|
||||
virtual ~KeyboardClient();
|
||||
virtual void onKeyPress(Keyboard::Key) = 0;
|
||||
virtual void on_key_pressed(Keyboard::Key) = 0;
|
||||
};
|
||||
|
|
|
@ -167,30 +167,30 @@ ByteBuffer procfs$pid_cwd(Process& process)
|
|||
return VFS::the().absolute_path(*inode).toByteBuffer();
|
||||
}
|
||||
|
||||
void ProcFS::addProcess(Process& process)
|
||||
void ProcFS::add_process(Process& process)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
char buf[16];
|
||||
ksprintf(buf, "%d", process.pid());
|
||||
auto dir = addFile(create_directory(buf));
|
||||
auto dir = add_file(create_directory(buf));
|
||||
m_pid2inode.set(process.pid(), dir.index());
|
||||
addFile(create_generated_file("vm", [&process] { return procfs$pid_vm(process); }), dir.index());
|
||||
addFile(create_generated_file("vmo", [&process] { return procfs$pid_vmo(process); }), dir.index());
|
||||
addFile(create_generated_file("stack", [&process] { return procfs$pid_stack(process); }), dir.index());
|
||||
addFile(create_generated_file("regs", [&process] { return procfs$pid_regs(process); }), dir.index());
|
||||
addFile(create_generated_file("fds", [&process] { return procfs$pid_fds(process); }), dir.index());
|
||||
add_file(create_generated_file("vm", [&process] { return procfs$pid_vm(process); }), dir.index());
|
||||
add_file(create_generated_file("vmo", [&process] { return procfs$pid_vmo(process); }), dir.index());
|
||||
add_file(create_generated_file("stack", [&process] { return procfs$pid_stack(process); }), dir.index());
|
||||
add_file(create_generated_file("regs", [&process] { return procfs$pid_regs(process); }), dir.index());
|
||||
add_file(create_generated_file("fds", [&process] { return procfs$pid_fds(process); }), dir.index());
|
||||
if (process.executable_inode())
|
||||
addFile(create_generated_file("exe", [&process] { return procfs$pid_exe(process); }, 00120777), dir.index());
|
||||
addFile(create_generated_file("cwd", [&process] { return procfs$pid_cwd(process); }, 00120777), dir.index());
|
||||
add_file(create_generated_file("exe", [&process] { return procfs$pid_exe(process); }, 00120777), dir.index());
|
||||
add_file(create_generated_file("cwd", [&process] { return procfs$pid_cwd(process); }, 00120777), dir.index());
|
||||
}
|
||||
|
||||
void ProcFS::removeProcess(Process& process)
|
||||
void ProcFS::remove_process(Process& process)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
auto pid = process.pid();
|
||||
auto it = m_pid2inode.find(pid);
|
||||
ASSERT(it != m_pid2inode.end());
|
||||
bool success = removeFile((*it).value);
|
||||
bool success = remove_file((*it).value);
|
||||
ASSERT(success);
|
||||
m_pid2inode.remove(pid);
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ ByteBuffer procfs$summary()
|
|||
process->ppid(),
|
||||
process->timesScheduled(),
|
||||
process->number_of_open_file_descriptors(),
|
||||
process->tty() ? strrchr(process->tty()->ttyName().characters(), '/') + 1 : "n/a",
|
||||
process->tty() ? strrchr(process->tty()->tty_name().characters(), '/') + 1 : "n/a",
|
||||
process->name().characters());
|
||||
}
|
||||
*ptr = '\0';
|
||||
|
@ -364,8 +364,8 @@ ByteBuffer procfs$vnodes()
|
|||
path = vfs.absolute_path(*vnode.core_inode());
|
||||
if (path.isEmpty()) {
|
||||
if (auto* dev = vnode.characterDevice()) {
|
||||
if (dev->isTTY())
|
||||
path = static_cast<const TTY*>(dev)->ttyName();
|
||||
if (dev->is_tty())
|
||||
path = static_cast<const TTY*>(dev)->tty_name();
|
||||
}
|
||||
}
|
||||
ptr += ksprintf(ptr, "vnode %03u: %02u:%08u (%u) %s\n", i, vnode.inode.fsid(), vnode.inode.index(), vnode.retain_count(), path.characters());
|
||||
|
@ -378,13 +378,13 @@ ByteBuffer procfs$vnodes()
|
|||
bool ProcFS::initialize()
|
||||
{
|
||||
SynthFS::initialize();
|
||||
addFile(create_generated_file("mm", procfs$mm));
|
||||
addFile(create_generated_file("regions", procfs$regions));
|
||||
addFile(create_generated_file("mounts", procfs$mounts));
|
||||
addFile(create_generated_file("kmalloc", procfs$kmalloc));
|
||||
addFile(create_generated_file("summary", procfs$summary));
|
||||
addFile(create_generated_file("cpuinfo", procfs$cpuinfo));
|
||||
addFile(create_generated_file("vnodes", procfs$vnodes));
|
||||
add_file(create_generated_file("mm", procfs$mm));
|
||||
add_file(create_generated_file("regions", procfs$regions));
|
||||
add_file(create_generated_file("mounts", procfs$mounts));
|
||||
add_file(create_generated_file("kmalloc", procfs$kmalloc));
|
||||
add_file(create_generated_file("summary", procfs$summary));
|
||||
add_file(create_generated_file("cpuinfo", procfs$cpuinfo));
|
||||
add_file(create_generated_file("vnodes", procfs$vnodes));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ public:
|
|||
virtual bool initialize() override;
|
||||
virtual const char* class_name() const override;
|
||||
|
||||
void addProcess(Process&);
|
||||
void removeProcess(Process&);
|
||||
void add_process(Process&);
|
||||
void remove_process(Process&);
|
||||
|
||||
private:
|
||||
ProcFS();
|
||||
|
|
|
@ -255,7 +255,7 @@ Process* Process::fork(RegisterDump& regs)
|
|||
dbgprintf("fork: child will begin executing at %w:%x with stack %w:%x\n", child->m_tss.cs, child->m_tss.eip, child->m_tss.ss, child->m_tss.esp);
|
||||
#endif
|
||||
|
||||
ProcFS::the().addProcess(*child);
|
||||
ProcFS::the().add_process(*child);
|
||||
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
|
@ -491,7 +491,7 @@ Process* Process::create_user_process(const String& path, uid_t uid, gid_t gid,
|
|||
if (error != 0)
|
||||
return nullptr;
|
||||
|
||||
ProcFS::the().addProcess(*process);
|
||||
ProcFS::the().add_process(*process);
|
||||
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
|
@ -554,7 +554,7 @@ Process* Process::create_kernel_process(void (*e)(), String&& name)
|
|||
g_processes->prepend(process);
|
||||
system.nprocess++;
|
||||
}
|
||||
ProcFS::the().addProcess(*process);
|
||||
ProcFS::the().add_process(*process);
|
||||
#ifdef TASK_DEBUG
|
||||
kprintf("Kernel process %u (%s) spawned @ %p\n", process->pid(), process->name().characters(), process->m_tss.eip);
|
||||
#endif
|
||||
|
@ -684,7 +684,7 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring
|
|||
Process::~Process()
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
ProcFS::the().removeProcess(*this);
|
||||
ProcFS::the().remove_process(*this);
|
||||
system.nprocess--;
|
||||
|
||||
gdt_free_entry(selector());
|
||||
|
@ -976,9 +976,9 @@ int Process::sys$ttyname_r(int fd, char* buffer, size_t size)
|
|||
auto* descriptor = file_descriptor(fd);
|
||||
if (!descriptor)
|
||||
return -EBADF;
|
||||
if (!descriptor->isTTY())
|
||||
if (!descriptor->is_tty())
|
||||
return -ENOTTY;
|
||||
auto ttyName = descriptor->tty()->ttyName();
|
||||
auto ttyName = descriptor->tty()->tty_name();
|
||||
if (size < ttyName.length() + 1)
|
||||
return -ERANGE;
|
||||
strcpy(buffer, ttyName.characters());
|
||||
|
@ -996,7 +996,7 @@ ssize_t Process::sys$write(int fd, const void* data, size_t size)
|
|||
if (!descriptor)
|
||||
return -EBADF;
|
||||
ssize_t nwritten = 0;
|
||||
if (descriptor->isBlocking()) {
|
||||
if (descriptor->is_blocking()) {
|
||||
while (nwritten < (ssize_t)size) {
|
||||
#ifdef IO_DEBUG
|
||||
dbgprintf("while %u < %u\n", nwritten, size);
|
||||
|
@ -1053,8 +1053,8 @@ ssize_t Process::sys$read(int fd, void* outbuf, size_t nread)
|
|||
auto* descriptor = file_descriptor(fd);
|
||||
if (!descriptor)
|
||||
return -EBADF;
|
||||
if (descriptor->isBlocking()) {
|
||||
if (!descriptor->hasDataAvailableForRead()) {
|
||||
if (descriptor->is_blocking()) {
|
||||
if (!descriptor->has_data_available_for_reading()) {
|
||||
m_fdBlockedOnRead = fd;
|
||||
block(BlockedRead);
|
||||
sched_yield();
|
||||
|
@ -1180,7 +1180,7 @@ int Process::sys$readlink(const char* path, char* buffer, size_t size)
|
|||
if (!descriptor->metadata().isSymbolicLink())
|
||||
return -EINVAL;
|
||||
|
||||
auto contents = descriptor->readEntireFile();
|
||||
auto contents = descriptor->read_entire_file();
|
||||
if (!contents)
|
||||
return -EIO; // FIXME: Get a more detailed error from VFS.
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ int Process::sys$chdir(const char* path)
|
|||
auto descriptor = VFS::the().open(path, error, 0, cwd_inode()->identifier());
|
||||
if (!descriptor)
|
||||
return error;
|
||||
if (!descriptor->isDirectory())
|
||||
if (!descriptor->is_directory())
|
||||
return -ENOTDIR;
|
||||
m_cwd = descriptor->vnode();
|
||||
return 0;
|
||||
|
@ -1241,7 +1241,7 @@ int Process::sys$open(const char* path, int options)
|
|||
auto descriptor = VFS::the().open(path, error, options, cwd_inode()->identifier());
|
||||
if (!descriptor)
|
||||
return error;
|
||||
if (options & O_DIRECTORY && !descriptor->isDirectory())
|
||||
if (options & O_DIRECTORY && !descriptor->is_directory())
|
||||
return -ENOTDIR; // FIXME: This should be handled by VFS::open.
|
||||
|
||||
int fd = 0;
|
||||
|
@ -1326,7 +1326,7 @@ int Process::sys$isatty(int fd)
|
|||
auto* descriptor = file_descriptor(fd);
|
||||
if (!descriptor)
|
||||
return -EBADF;
|
||||
if (!descriptor->isTTY())
|
||||
if (!descriptor->is_tty())
|
||||
return -ENOTTY;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ bool Scheduler::pick_next()
|
|||
if (process.state() == Process::BlockedRead) {
|
||||
ASSERT(process.m_fdBlockedOnRead != -1);
|
||||
// FIXME: Block until the amount of data wanted is available.
|
||||
if (process.m_fds[process.m_fdBlockedOnRead].descriptor->hasDataAvailableForRead())
|
||||
if (process.m_fds[process.m_fdBlockedOnRead].descriptor->has_data_available_for_reading())
|
||||
process.unblock();
|
||||
return true;
|
||||
}
|
||||
|
@ -167,9 +167,9 @@ void Scheduler::pick_next_and_switch_now()
|
|||
|
||||
void Scheduler::switch_now()
|
||||
{
|
||||
Descriptor& descriptor = getGDTEntry(current->selector());
|
||||
Descriptor& descriptor = get_gdt_entry(current->selector());
|
||||
descriptor.type = 9;
|
||||
flushGDT();
|
||||
flush_gdt();
|
||||
asm("sti\n"
|
||||
"ljmp *(%%eax)\n"
|
||||
::"a"(¤t->farPtr())
|
||||
|
@ -204,7 +204,7 @@ bool Scheduler::context_switch(Process& process)
|
|||
|
||||
if (!process.selector()) {
|
||||
process.setSelector(gdt_alloc_entry());
|
||||
auto& descriptor = getGDTEntry(process.selector());
|
||||
auto& descriptor = get_gdt_entry(process.selector());
|
||||
descriptor.setBase(&process.tss());
|
||||
descriptor.setLimit(0xffff);
|
||||
descriptor.dpl = 0;
|
||||
|
@ -215,9 +215,9 @@ bool Scheduler::context_switch(Process& process)
|
|||
descriptor.descriptor_type = 0;
|
||||
}
|
||||
|
||||
auto& descriptor = getGDTEntry(process.selector());
|
||||
auto& descriptor = get_gdt_entry(process.selector());
|
||||
descriptor.type = 11; // Busy TSS
|
||||
flushGDT();
|
||||
flush_gdt();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ int sched_yield()
|
|||
|
||||
static void initialize_redirection()
|
||||
{
|
||||
auto& descriptor = getGDTEntry(s_redirection.selector);
|
||||
auto& descriptor = get_gdt_entry(s_redirection.selector);
|
||||
descriptor.setBase(&s_redirection.tss);
|
||||
descriptor.setLimit(0xffff);
|
||||
descriptor.dpl = 0;
|
||||
|
@ -238,12 +238,12 @@ static void initialize_redirection()
|
|||
descriptor.operation_size = 1;
|
||||
descriptor.descriptor_type = 0;
|
||||
descriptor.type = 9;
|
||||
flushGDT();
|
||||
flush_gdt();
|
||||
}
|
||||
|
||||
void Scheduler::prepare_for_iret_to_new_process()
|
||||
{
|
||||
auto& descriptor = getGDTEntry(s_redirection.selector);
|
||||
auto& descriptor = get_gdt_entry(s_redirection.selector);
|
||||
descriptor.type = 9;
|
||||
s_redirection.tss.backlink = current->selector();
|
||||
load_task_register(s_redirection.selector);
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Syscall {
|
|||
|
||||
void initialize()
|
||||
{
|
||||
registerUserCallableInterruptHandler(0x80, syscall_ISR);
|
||||
register_user_callable_interrupt_handler(0x80, syscall_ISR);
|
||||
kprintf("syscall: int 0x80 handler installed\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -55,11 +55,11 @@ ssize_t TTY::write(const byte* buffer, size_t size)
|
|||
#ifdef TTY_DEBUG
|
||||
dbgprintf("TTY::write %b {%u}\n", buffer[0], size);
|
||||
#endif
|
||||
onTTYWrite(buffer, size);
|
||||
on_tty_write(buffer, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool TTY::hasDataAvailableForRead() const
|
||||
bool TTY::has_data_available_for_reading() const
|
||||
{
|
||||
return !m_buffer.is_empty();
|
||||
}
|
||||
|
@ -68,12 +68,12 @@ void TTY::emit(byte ch)
|
|||
{
|
||||
if (should_generate_signals()) {
|
||||
if (ch == m_termios.c_cc[VINTR]) {
|
||||
dbgprintf("%s: VINTR pressed!\n", ttyName().characters());
|
||||
dbgprintf("%s: VINTR pressed!\n", tty_name().characters());
|
||||
generate_signal(SIGINT);
|
||||
return;
|
||||
}
|
||||
if (ch == m_termios.c_cc[VQUIT]) {
|
||||
dbgprintf("%s: VQUIT pressed!\n", ttyName().characters());
|
||||
dbgprintf("%s: VQUIT pressed!\n", tty_name().characters());
|
||||
generate_signal(SIGQUIT);
|
||||
return;
|
||||
}
|
||||
|
@ -85,10 +85,10 @@ void TTY::generate_signal(int signal)
|
|||
{
|
||||
if (!pgid())
|
||||
return;
|
||||
dbgprintf("%s: Send signal %d to everyone in pgrp %d\n", ttyName().characters(), signal, pgid());
|
||||
dbgprintf("%s: Send signal %d to everyone in pgrp %d\n", tty_name().characters(), signal, pgid());
|
||||
InterruptDisabler disabler; // FIXME: Iterate over a set of process handles instead?
|
||||
Process::for_each_in_pgrp(pgid(), [&] (auto& process) {
|
||||
dbgprintf("%s: Send signal %d to %d\n", ttyName().characters(), signal, process.pid());
|
||||
dbgprintf("%s: Send signal %d to %d\n", tty_name().characters(), signal, process.pid());
|
||||
process.send_signal(signal, nullptr);
|
||||
return true;
|
||||
});
|
||||
|
@ -98,7 +98,7 @@ void TTY::set_termios(const Unix::termios& t)
|
|||
{
|
||||
m_termios = t;
|
||||
dbgprintf("%s set_termios: IECHO? %u, ISIG? %u, ICANON? %u\n",
|
||||
ttyName().characters(),
|
||||
tty_name().characters(),
|
||||
should_echo_input(),
|
||||
should_generate_signals(),
|
||||
in_canonical_mode()
|
||||
|
|
|
@ -34,10 +34,10 @@ public:
|
|||
|
||||
virtual ssize_t read(byte*, size_t) override;
|
||||
virtual ssize_t write(const byte*, size_t) override;
|
||||
virtual bool hasDataAvailableForRead() const override;
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
virtual int ioctl(Process&, unsigned request, unsigned arg) override final;
|
||||
|
||||
virtual String ttyName() const = 0;
|
||||
virtual String tty_name() const = 0;
|
||||
|
||||
unsigned short rows() const { return m_rows; }
|
||||
unsigned short columns() const { return m_columns; }
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
bool in_canonical_mode() const { return m_termios.c_lflag & ICANON; }
|
||||
|
||||
protected:
|
||||
virtual void onTTYWrite(const byte*, size_t) = 0;
|
||||
virtual void on_tty_write(const byte*, size_t) = 0;
|
||||
void set_size(unsigned short columns, unsigned short rows);
|
||||
|
||||
TTY(unsigned major, unsigned minor);
|
||||
|
@ -60,7 +60,7 @@ protected:
|
|||
|
||||
private:
|
||||
// ^CharacterDevice
|
||||
virtual bool isTTY() const final override { return true; }
|
||||
virtual bool is_tty() const final override { return true; }
|
||||
|
||||
void generate_signal(int signal);
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ void VirtualConsole::set_active(bool b)
|
|||
set_vga_start_row(0);
|
||||
flush_vga_cursor();
|
||||
|
||||
Keyboard::the().setClient(this);
|
||||
Keyboard::the().set_client(this);
|
||||
}
|
||||
|
||||
inline bool is_valid_parameter_character(byte ch)
|
||||
|
@ -441,7 +441,7 @@ void VirtualConsole::on_char(byte ch)
|
|||
set_cursor(m_cursor_row, m_cursor_column);
|
||||
}
|
||||
|
||||
void VirtualConsole::onKeyPress(Keyboard::Key key)
|
||||
void VirtualConsole::on_key_pressed(Keyboard::Key key)
|
||||
{
|
||||
if (key.ctrl()) {
|
||||
if (key.character >= 'a' && key.character <= 'z') {
|
||||
|
@ -455,7 +455,7 @@ void VirtualConsole::onKeyPress(Keyboard::Key key)
|
|||
emit(key.character);
|
||||
}
|
||||
|
||||
void VirtualConsole::onConsoleReceive(byte ch)
|
||||
void VirtualConsole::on_sysconsole_receive(byte ch)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
auto old_attribute = m_current_attribute;
|
||||
|
@ -464,14 +464,14 @@ void VirtualConsole::onConsoleReceive(byte ch)
|
|||
m_current_attribute = old_attribute;
|
||||
}
|
||||
|
||||
void VirtualConsole::onTTYWrite(const byte* data, size_t size)
|
||||
void VirtualConsole::on_tty_write(const byte* data, size_t size)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
on_char(data[i]);
|
||||
}
|
||||
|
||||
String VirtualConsole::ttyName() const
|
||||
String VirtualConsole::tty_name() const
|
||||
{
|
||||
char buf[16];
|
||||
ksprintf(buf, "/dev/tty%u", m_index);
|
||||
|
|
|
@ -17,14 +17,14 @@ public:
|
|||
|
||||
private:
|
||||
// ^KeyboardClient
|
||||
virtual void onKeyPress(Keyboard::Key) override;
|
||||
virtual void on_key_pressed(Keyboard::Key) override;
|
||||
|
||||
// ^ConsoleImplementation
|
||||
virtual void onConsoleReceive(byte) override;
|
||||
virtual void on_sysconsole_receive(byte) override;
|
||||
|
||||
// ^TTY
|
||||
virtual void onTTYWrite(const byte*, size_t) override;
|
||||
virtual String ttyName() const override;
|
||||
virtual void on_tty_write(const byte*, size_t) override;
|
||||
virtual String tty_name() const override;
|
||||
|
||||
void set_active(bool);
|
||||
void on_char(byte);
|
||||
|
|
|
@ -297,18 +297,18 @@ static void writeRawGDTEntry(word selector, dword low, dword high)
|
|||
}
|
||||
}
|
||||
|
||||
void writeGDTEntry(word selector, Descriptor& descriptor)
|
||||
void write_gdt_entry(word selector, Descriptor& descriptor)
|
||||
{
|
||||
writeRawGDTEntry(selector, descriptor.low, descriptor.high);
|
||||
}
|
||||
|
||||
Descriptor& getGDTEntry(word selector)
|
||||
Descriptor& get_gdt_entry(word selector)
|
||||
{
|
||||
word i = (selector & 0xfffc) >> 3;
|
||||
return *(Descriptor*)(&s_gdt[i]);
|
||||
}
|
||||
|
||||
void flushGDT()
|
||||
void flush_gdt()
|
||||
{
|
||||
s_gdtr.address = s_gdt;
|
||||
s_gdtr.size = (s_gdtLength * 8) - 1;
|
||||
|
@ -335,7 +335,7 @@ void gdt_init()
|
|||
writeRawGDTEntry(0x0018, 0x0000ffff, 0x00cffa00);
|
||||
writeRawGDTEntry(0x0020, 0x0000ffff, 0x00cff200);
|
||||
|
||||
flushGDT();
|
||||
flush_gdt();
|
||||
}
|
||||
|
||||
static void unimp_trap()
|
||||
|
@ -344,34 +344,34 @@ static void unimp_trap()
|
|||
HANG;
|
||||
}
|
||||
|
||||
void registerIRQHandler(byte irq, IRQHandler& handler)
|
||||
void register_irq_handler(byte irq, IRQHandler& handler)
|
||||
{
|
||||
ASSERT(!s_irqHandler[irq]);
|
||||
s_irqHandler[irq] = &handler;
|
||||
registerInterruptHandler(IRQ_VECTOR_BASE + irq, asm_irq_entry);
|
||||
register_interrupt_handler(IRQ_VECTOR_BASE + irq, asm_irq_entry);
|
||||
}
|
||||
|
||||
void unregisterIRQHandler(byte irq, IRQHandler& handler)
|
||||
void unregister_irq_handler(byte irq, IRQHandler& handler)
|
||||
{
|
||||
ASSERT(s_irqHandler[irq] == &handler);
|
||||
s_irqHandler[irq] = nullptr;
|
||||
}
|
||||
|
||||
void registerInterruptHandler(byte index, void (*f)())
|
||||
void register_interrupt_handler(byte index, void (*f)())
|
||||
{
|
||||
s_idt[index].low = 0x00080000 | LSW((f));
|
||||
s_idt[index].high = ((dword)(f) & 0xffff0000) | 0x8e00;
|
||||
flushIDT();
|
||||
flush_idt();
|
||||
}
|
||||
|
||||
void registerUserCallableInterruptHandler(byte index, void (*f)())
|
||||
void register_user_callable_interrupt_handler(byte index, void (*f)())
|
||||
{
|
||||
s_idt[index].low = 0x00080000 | LSW((f));
|
||||
s_idt[index].high = ((dword)(f) & 0xffff0000) | 0xef00;
|
||||
flushIDT();
|
||||
flush_idt();
|
||||
}
|
||||
|
||||
void flushIDT()
|
||||
void flush_idt()
|
||||
{
|
||||
asm("lidt %0"::"m"(s_idtr));
|
||||
}
|
||||
|
@ -396,34 +396,34 @@ void idt_init()
|
|||
s_idtr.size = 0x100 * 8;
|
||||
|
||||
for (byte i = 0xff; i > 0x10; --i)
|
||||
registerInterruptHandler(i, unimp_trap);
|
||||
register_interrupt_handler(i, unimp_trap);
|
||||
|
||||
registerInterruptHandler(0x00, _exception0);
|
||||
registerInterruptHandler(0x01, _exception1);
|
||||
registerInterruptHandler(0x02, _exception2);
|
||||
registerInterruptHandler(0x03, _exception3);
|
||||
registerInterruptHandler(0x04, _exception4);
|
||||
registerInterruptHandler(0x05, _exception5);
|
||||
registerInterruptHandler(0x06, exception_6_entry);
|
||||
registerInterruptHandler(0x07, _exception7);
|
||||
registerInterruptHandler(0x08, _exception8);
|
||||
registerInterruptHandler(0x09, _exception9);
|
||||
registerInterruptHandler(0x0a, _exception10);
|
||||
registerInterruptHandler(0x0b, _exception11);
|
||||
registerInterruptHandler(0x0c, _exception12);
|
||||
registerInterruptHandler(0x0d, exception_13_entry);
|
||||
registerInterruptHandler(0x0e, exception_14_entry);
|
||||
registerInterruptHandler(0x0f, _exception15);
|
||||
registerInterruptHandler(0x10, _exception16);
|
||||
register_interrupt_handler(0x00, _exception0);
|
||||
register_interrupt_handler(0x01, _exception1);
|
||||
register_interrupt_handler(0x02, _exception2);
|
||||
register_interrupt_handler(0x03, _exception3);
|
||||
register_interrupt_handler(0x04, _exception4);
|
||||
register_interrupt_handler(0x05, _exception5);
|
||||
register_interrupt_handler(0x06, exception_6_entry);
|
||||
register_interrupt_handler(0x07, _exception7);
|
||||
register_interrupt_handler(0x08, _exception8);
|
||||
register_interrupt_handler(0x09, _exception9);
|
||||
register_interrupt_handler(0x0a, _exception10);
|
||||
register_interrupt_handler(0x0b, _exception11);
|
||||
register_interrupt_handler(0x0c, _exception12);
|
||||
register_interrupt_handler(0x0d, exception_13_entry);
|
||||
register_interrupt_handler(0x0e, exception_14_entry);
|
||||
register_interrupt_handler(0x0f, _exception15);
|
||||
register_interrupt_handler(0x10, _exception16);
|
||||
|
||||
registerInterruptHandler(0x57, irq7_handler);
|
||||
register_interrupt_handler(0x57, irq7_handler);
|
||||
|
||||
s_irqHandler = static_cast<IRQHandler**>(kmalloc_eternal(sizeof(IRQHandler*) * 16));
|
||||
for (byte i = 0; i < 16; ++i) {
|
||||
s_irqHandler[i] = nullptr;
|
||||
}
|
||||
|
||||
flushIDT();
|
||||
flush_idt();
|
||||
}
|
||||
|
||||
void load_task_register(word selector)
|
||||
|
@ -450,7 +450,7 @@ void handle_irq()
|
|||
}
|
||||
|
||||
if (s_irqHandler[irq])
|
||||
s_irqHandler[irq]->handleIRQ();
|
||||
s_irqHandler[irq]->handle_irq();
|
||||
PIC::eoi(irq);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,17 +61,17 @@ class IRQHandler;
|
|||
|
||||
void gdt_init();
|
||||
void idt_init();
|
||||
void registerInterruptHandler(byte number, void (*f)());
|
||||
void registerUserCallableInterruptHandler(byte number, void (*f)());
|
||||
void registerIRQHandler(byte number, IRQHandler&);
|
||||
void unregisterIRQHandler(byte number, IRQHandler&);
|
||||
void flushIDT();
|
||||
void flushGDT();
|
||||
void register_interrupt_handler(byte number, void (*f)());
|
||||
void register_user_callable_interrupt_handler(byte number, void (*f)());
|
||||
void register_irq_handler(byte number, IRQHandler&);
|
||||
void unregister_irq_handler(byte number, IRQHandler&);
|
||||
void flush_idt();
|
||||
void flush_gdt();
|
||||
void load_task_register(word selector);
|
||||
word gdt_alloc_entry();
|
||||
void gdt_free_entry(word);
|
||||
Descriptor& getGDTEntry(word selector);
|
||||
void writeGDTEntry(word selector, Descriptor&);
|
||||
Descriptor& get_gdt_entry(word selector);
|
||||
void write_gdt_entry(word selector, Descriptor&);
|
||||
|
||||
#define HANG asm volatile( "cli; hlt" );
|
||||
#define LSW(x) ((dword)(x) & 0xFFFF)
|
||||
|
@ -82,7 +82,7 @@ void writeGDTEntry(word selector, Descriptor&);
|
|||
#define cli() asm volatile("cli")
|
||||
#define sti() asm volatile("sti")
|
||||
|
||||
static inline dword cpuFlags()
|
||||
static inline dword cpu_flags()
|
||||
{
|
||||
dword flags;
|
||||
asm volatile(
|
||||
|
@ -95,14 +95,14 @@ static inline dword cpuFlags()
|
|||
|
||||
inline bool are_interrupts_enabled()
|
||||
{
|
||||
return cpuFlags() & 0x200;
|
||||
return cpu_flags() & 0x200;
|
||||
}
|
||||
|
||||
class InterruptDisabler {
|
||||
public:
|
||||
InterruptDisabler()
|
||||
{
|
||||
m_flags = cpuFlags();
|
||||
m_flags = cpu_flags();
|
||||
cli();
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void initialize()
|
|||
IO::out8(TIMER0_CTL, LSB(timer_reload));
|
||||
IO::out8(TIMER0_CTL, MSB(timer_reload));
|
||||
|
||||
registerInterruptHandler(IRQ_VECTOR_BASE + IRQ_TIMER, tick_ISR);
|
||||
register_interrupt_handler(IRQ_VECTOR_BASE + IRQ_TIMER, tick_ISR);
|
||||
|
||||
PIC::enable(IRQ_TIMER);
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ static void init_stage2()
|
|||
if (!descriptor) {
|
||||
kprintf("Failed to open /kernel.map\n");
|
||||
} else {
|
||||
auto buffer = descriptor->readEntireFile();
|
||||
auto buffer = descriptor->read_entire_file();
|
||||
ASSERT(buffer);
|
||||
loadKsyms(buffer);
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@ void __assertion_failed(const char* msg, const char* file, unsigned line, const
|
|||
#define CRASH() do { asm volatile("ud2"); } while(0)
|
||||
#define RELEASE_ASSERT(x) do { if (!(x)) CRASH(); } while(0)
|
||||
#define ASSERT_NOT_REACHED() ASSERT(false)
|
||||
#define ASSERT_INTERRUPTS_DISABLED() ASSERT(!(cpuFlags() & 0x200))
|
||||
#define ASSERT_INTERRUPTS_ENABLED() ASSERT(cpuFlags() & 0x200)
|
||||
#define ASSERT_INTERRUPTS_DISABLED() ASSERT(!(cpu_flags() & 0x200))
|
||||
#define ASSERT_INTERRUPTS_ENABLED() ASSERT(cpu_flags() & 0x200)
|
||||
|
|
|
@ -12,7 +12,7 @@ public:
|
|||
|
||||
RetainPtr<FileDescriptor> open(int options);
|
||||
|
||||
virtual bool hasDataAvailableForRead() const = 0;
|
||||
virtual bool has_data_available_for_reading() const = 0;
|
||||
|
||||
virtual ssize_t read(byte* buffer, size_t bufferSize) = 0;
|
||||
virtual ssize_t write(const byte* buffer, size_t bufferSize) = 0;
|
||||
|
@ -20,7 +20,7 @@ public:
|
|||
unsigned major() const { return m_major; }
|
||||
unsigned minor() const { return m_minor; }
|
||||
|
||||
virtual bool isTTY() const { return false; }
|
||||
virtual bool is_tty() const { return false; }
|
||||
|
||||
virtual int ioctl(Process&, unsigned request, unsigned arg);
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ RetainPtr<FileDescriptor> FileDescriptor::clone()
|
|||
}
|
||||
if (!descriptor)
|
||||
return nullptr;
|
||||
descriptor->m_currentOffset = m_currentOffset;
|
||||
descriptor->m_current_offset = m_current_offset;
|
||||
#ifdef SERENITY
|
||||
descriptor->m_isBlocking = m_isBlocking;
|
||||
descriptor->m_is_blocking = m_is_blocking;
|
||||
descriptor->m_file_flags = m_file_flags;
|
||||
#endif
|
||||
return descriptor;
|
||||
|
@ -113,7 +113,7 @@ Unix::off_t FileDescriptor::seek(Unix::off_t offset, int whence)
|
|||
newOffset = offset;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
newOffset = m_currentOffset + offset;
|
||||
newOffset = m_current_offset + offset;
|
||||
#ifndef SERENITY
|
||||
if (additionWouldOverflow(m_currentOffset, offset))
|
||||
return -EOVERFLOW;
|
||||
|
@ -129,8 +129,8 @@ Unix::off_t FileDescriptor::seek(Unix::off_t offset, int whence)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
m_currentOffset = newOffset;
|
||||
return m_currentOffset;
|
||||
m_current_offset = newOffset;
|
||||
return m_current_offset;
|
||||
}
|
||||
|
||||
ssize_t FileDescriptor::read(byte* buffer, size_t count)
|
||||
|
@ -143,8 +143,8 @@ ssize_t FileDescriptor::read(byte* buffer, size_t count)
|
|||
// FIXME: What should happen to m_currentOffset?
|
||||
return m_vnode->characterDevice()->read(buffer, count);
|
||||
}
|
||||
ssize_t nread = m_vnode->fileSystem()->read_inode_bytes(m_vnode->inode, m_currentOffset, count, buffer, this);
|
||||
m_currentOffset += nread;
|
||||
ssize_t nread = m_vnode->fileSystem()->read_inode_bytes(m_vnode->inode, m_current_offset, count, buffer, this);
|
||||
m_current_offset += nread;
|
||||
return nread;
|
||||
}
|
||||
|
||||
|
@ -172,18 +172,18 @@ bool FileDescriptor::can_write()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool FileDescriptor::hasDataAvailableForRead()
|
||||
bool FileDescriptor::has_data_available_for_reading()
|
||||
{
|
||||
if (is_fifo()) {
|
||||
ASSERT(fifo_direction() == FIFO::Reader);
|
||||
return m_fifo->can_read();
|
||||
}
|
||||
if (m_vnode->isCharacterDevice())
|
||||
return m_vnode->characterDevice()->hasDataAvailableForRead();
|
||||
return m_vnode->characterDevice()->has_data_available_for_reading();
|
||||
return true;
|
||||
}
|
||||
|
||||
ByteBuffer FileDescriptor::readEntireFile()
|
||||
ByteBuffer FileDescriptor::read_entire_file()
|
||||
{
|
||||
ASSERT(!is_fifo());
|
||||
|
||||
|
@ -199,7 +199,7 @@ ByteBuffer FileDescriptor::readEntireFile()
|
|||
return m_vnode->fileSystem()->read_entire_inode(m_vnode->inode, this);
|
||||
}
|
||||
|
||||
bool FileDescriptor::isDirectory() const
|
||||
bool FileDescriptor::is_directory() const
|
||||
{
|
||||
ASSERT(!is_fifo());
|
||||
return m_vnode->metadata().isDirectory();
|
||||
|
@ -232,12 +232,12 @@ ssize_t FileDescriptor::get_dir_entries(byte* buffer, size_t size)
|
|||
}
|
||||
\
|
||||
#ifdef SERENITY
|
||||
bool FileDescriptor::isTTY() const
|
||||
bool FileDescriptor::is_tty() const
|
||||
{
|
||||
if (is_fifo())
|
||||
return false;
|
||||
if (auto* device = m_vnode->characterDevice())
|
||||
return device->isTTY();
|
||||
return device->is_tty();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -269,8 +269,8 @@ String FileDescriptor::absolute_path()
|
|||
{
|
||||
Stopwatch sw("absolute_path");
|
||||
#ifdef SERENITY
|
||||
if (isTTY())
|
||||
return tty()->ttyName();
|
||||
if (is_tty())
|
||||
return tty()->tty_name();
|
||||
#endif
|
||||
if (is_fifo()) {
|
||||
char buf[32];
|
||||
|
@ -282,7 +282,7 @@ String FileDescriptor::absolute_path()
|
|||
}
|
||||
|
||||
FileDescriptor::FileDescriptor(FIFO& fifo, FIFO::Direction direction)
|
||||
: m_isBlocking(true)
|
||||
: m_is_blocking(true)
|
||||
, m_fifo(fifo)
|
||||
, m_fifo_direction(direction)
|
||||
{
|
||||
|
|
|
@ -27,22 +27,22 @@ public:
|
|||
ssize_t write(const byte* data, size_t);
|
||||
int stat(Unix::stat*);
|
||||
|
||||
bool hasDataAvailableForRead();
|
||||
bool has_data_available_for_reading();
|
||||
bool can_write();
|
||||
|
||||
ssize_t get_dir_entries(byte* buffer, size_t);
|
||||
|
||||
ByteBuffer readEntireFile();
|
||||
ByteBuffer read_entire_file();
|
||||
|
||||
String absolute_path();
|
||||
|
||||
bool isDirectory() const;
|
||||
bool is_directory() const;
|
||||
|
||||
bool is_character_device() const { return m_vnode && m_vnode->isCharacterDevice(); }
|
||||
CharacterDevice* character_device() { return m_vnode ? m_vnode->characterDevice() : nullptr; }
|
||||
|
||||
#ifdef SERENITY
|
||||
bool isTTY() const;
|
||||
bool is_tty() const;
|
||||
const TTY* tty() const;
|
||||
TTY* tty();
|
||||
#endif
|
||||
|
@ -52,8 +52,8 @@ public:
|
|||
Vnode* vnode() { return m_vnode.ptr(); }
|
||||
|
||||
#ifdef SERENITY
|
||||
bool isBlocking() const { return m_isBlocking; }
|
||||
void setBlocking(bool b) { m_isBlocking = b; }
|
||||
bool is_blocking() const { return m_is_blocking; }
|
||||
void set_blocking(bool b) { m_is_blocking = b; }
|
||||
|
||||
dword file_flags() const { return m_file_flags; }
|
||||
void set_file_flags(dword flags) { m_file_flags = flags; }
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
FIFO::Direction fifo_direction() { return m_fifo_direction; }
|
||||
#endif
|
||||
|
||||
ByteBuffer& generatorCache() { return m_generatorCache; }
|
||||
ByteBuffer& generator_cache() { return m_generator_cache; }
|
||||
|
||||
private:
|
||||
friend class VFS;
|
||||
|
@ -72,12 +72,12 @@ private:
|
|||
RetainPtr<Vnode> m_vnode;
|
||||
RetainPtr<CoreInode> m_inode;
|
||||
|
||||
Unix::off_t m_currentOffset { 0 };
|
||||
Unix::off_t m_current_offset { 0 };
|
||||
|
||||
ByteBuffer m_generatorCache;
|
||||
ByteBuffer m_generator_cache;
|
||||
|
||||
#ifdef SERENITY
|
||||
bool m_isBlocking { true };
|
||||
bool m_is_blocking { true };
|
||||
dword m_file_flags { 0 };
|
||||
|
||||
RetainPtr<FIFO> m_fifo;
|
||||
|
|
|
@ -13,7 +13,7 @@ FullDevice::~FullDevice()
|
|||
{
|
||||
}
|
||||
|
||||
bool FullDevice::hasDataAvailableForRead() const
|
||||
bool FullDevice::has_data_available_for_reading() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ public:
|
|||
|
||||
virtual ssize_t read(byte* buffer, size_t bufferSize) override;
|
||||
virtual ssize_t write(const byte* buffer, size_t bufferSize) override;
|
||||
virtual bool hasDataAvailableForRead() const override;
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ NullDevice::~NullDevice()
|
|||
{
|
||||
}
|
||||
|
||||
bool NullDevice::hasDataAvailableForRead() const
|
||||
bool NullDevice::has_data_available_for_reading() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ public:
|
|||
|
||||
virtual ssize_t read(byte* buffer, size_t bufferSize) override;
|
||||
virtual ssize_t write(const byte* buffer, size_t bufferSize) override;
|
||||
virtual bool hasDataAvailableForRead() const override;
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ static void mysrand(unsigned seed)
|
|||
}
|
||||
#endif
|
||||
|
||||
bool RandomDevice::hasDataAvailableForRead() const
|
||||
bool RandomDevice::has_data_available_for_reading() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ public:
|
|||
|
||||
virtual ssize_t read(byte* buffer, size_t bufferSize) override;
|
||||
virtual ssize_t write(const byte* buffer, size_t bufferSize) override;
|
||||
virtual bool hasDataAvailableForRead() const override;
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ bool SynthFS::initialize()
|
|||
|
||||
RetainPtr<SynthFSInode> SynthFS::create_directory(String&& name)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generateInodeIndex()));
|
||||
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
|
||||
file->m_name = move(name);
|
||||
file->m_metadata.size = 0;
|
||||
file->m_metadata.uid = 0;
|
||||
|
@ -58,7 +58,7 @@ RetainPtr<SynthFSInode> SynthFS::create_directory(String&& name)
|
|||
|
||||
RetainPtr<SynthFSInode> SynthFS::create_text_file(String&& name, ByteBuffer&& contents, Unix::mode_t mode)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generateInodeIndex()));
|
||||
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
|
||||
file->m_data = contents;
|
||||
file->m_name = move(name);
|
||||
file->m_metadata.size = file->m_data.size();
|
||||
|
@ -71,7 +71,7 @@ RetainPtr<SynthFSInode> SynthFS::create_text_file(String&& name, ByteBuffer&& co
|
|||
|
||||
RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer()>&& generator, Unix::mode_t mode)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generateInodeIndex()));
|
||||
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
|
||||
file->m_generator = move(generator);
|
||||
file->m_name = move(name);
|
||||
file->m_metadata.size = 0;
|
||||
|
@ -82,7 +82,7 @@ RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<B
|
|||
return file;
|
||||
}
|
||||
|
||||
InodeIdentifier SynthFS::addFile(RetainPtr<SynthFSInode>&& file, InodeIndex parent)
|
||||
InodeIdentifier SynthFS::add_file(RetainPtr<SynthFSInode>&& file, InodeIndex parent)
|
||||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
ASSERT(file);
|
||||
|
@ -96,7 +96,7 @@ InodeIdentifier SynthFS::addFile(RetainPtr<SynthFSInode>&& file, InodeIndex pare
|
|||
return new_inode_id;
|
||||
}
|
||||
|
||||
bool SynthFS::removeFile(InodeIndex inode)
|
||||
bool SynthFS::remove_file(InodeIndex inode)
|
||||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
auto it = m_inodes.find(inode);
|
||||
|
@ -117,7 +117,7 @@ bool SynthFS::removeFile(InodeIndex inode)
|
|||
}
|
||||
|
||||
for (auto& child : file.m_children)
|
||||
removeFile(child->m_metadata.inode.index());
|
||||
remove_file(child->m_metadata.inode.index());
|
||||
m_inodes.remove(inode);
|
||||
return true;
|
||||
}
|
||||
|
@ -193,17 +193,17 @@ ssize_t SynthFS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset, siz
|
|||
if (!handle) {
|
||||
generatedData = file.m_generator();
|
||||
} else {
|
||||
if (!handle->generatorCache())
|
||||
handle->generatorCache() = file.m_generator();
|
||||
generatedData = handle->generatorCache();
|
||||
if (!handle->generator_cache())
|
||||
handle->generator_cache() = file.m_generator();
|
||||
generatedData = handle->generator_cache();
|
||||
}
|
||||
}
|
||||
|
||||
auto* data = generatedData ? &generatedData : &file.m_data;
|
||||
ssize_t nread = min(static_cast<Unix::off_t>(data->size() - offset), static_cast<Unix::off_t>(count));
|
||||
memcpy(buffer, data->pointer() + offset, nread);
|
||||
if (nread == 0 && handle && handle->generatorCache())
|
||||
handle->generatorCache().clear();
|
||||
if (nread == 0 && handle && handle->generator_cache())
|
||||
handle->generator_cache().clear();
|
||||
return nread;
|
||||
}
|
||||
|
||||
|
@ -213,9 +213,9 @@ InodeIdentifier SynthFS::create_directory(InodeIdentifier, const String&, Unix::
|
|||
return { };
|
||||
}
|
||||
|
||||
auto SynthFS::generateInodeIndex() -> InodeIndex
|
||||
auto SynthFS::generate_inode_index() -> InodeIndex
|
||||
{
|
||||
return m_nextInodeIndex++;
|
||||
return m_next_inode_index++;
|
||||
}
|
||||
|
||||
InodeIdentifier SynthFS::find_parent_of_inode(InodeIdentifier inode) const
|
||||
|
@ -262,17 +262,17 @@ ssize_t SynthFSInode::read_bytes(Unix::off_t offset, size_t count, byte* buffer,
|
|||
if (!descriptor) {
|
||||
generatedData = m_generator();
|
||||
} else {
|
||||
if (!descriptor->generatorCache())
|
||||
descriptor->generatorCache() = m_generator();
|
||||
generatedData = descriptor->generatorCache();
|
||||
if (!descriptor->generator_cache())
|
||||
descriptor->generator_cache() = m_generator();
|
||||
generatedData = descriptor->generator_cache();
|
||||
}
|
||||
}
|
||||
|
||||
auto* data = generatedData ? &generatedData : &m_data;
|
||||
ssize_t nread = min(static_cast<Unix::off_t>(data->size() - offset), static_cast<Unix::off_t>(count));
|
||||
memcpy(buffer, data->pointer() + offset, nread);
|
||||
if (nread == 0 && descriptor && descriptor->generatorCache())
|
||||
descriptor->generatorCache().clear();
|
||||
if (nread == 0 && descriptor && descriptor->generator_cache())
|
||||
descriptor->generator_cache().clear();
|
||||
return nread;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
protected:
|
||||
typedef unsigned InodeIndex;
|
||||
|
||||
InodeIndex generateInodeIndex();
|
||||
InodeIndex generate_inode_index();
|
||||
static constexpr InodeIndex RootInodeIndex = 1;
|
||||
|
||||
SynthFS();
|
||||
|
@ -35,11 +35,11 @@ protected:
|
|||
RetainPtr<SynthFSInode> create_text_file(String&& name, ByteBuffer&&, Unix::mode_t = 0010644);
|
||||
RetainPtr<SynthFSInode> create_generated_file(String&& name, Function<ByteBuffer()>&&, Unix::mode_t = 0100644);
|
||||
|
||||
InodeIdentifier addFile(RetainPtr<SynthFSInode>&&, InodeIndex parent = RootInodeIndex);
|
||||
bool removeFile(InodeIndex);
|
||||
InodeIdentifier add_file(RetainPtr<SynthFSInode>&&, InodeIndex parent = RootInodeIndex);
|
||||
bool remove_file(InodeIndex);
|
||||
|
||||
private:
|
||||
InodeIndex m_nextInodeIndex { 2 };
|
||||
InodeIndex m_next_inode_index { 2 };
|
||||
HashMap<InodeIndex, RetainPtr<SynthFSInode>> m_inodes;
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ ZeroDevice::~ZeroDevice()
|
|||
{
|
||||
}
|
||||
|
||||
bool ZeroDevice::hasDataAvailableForRead() const
|
||||
bool ZeroDevice::has_data_available_for_reading() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ public:
|
|||
|
||||
virtual ssize_t read(byte* buffer, size_t bufferSize) override;
|
||||
virtual ssize_t write(const byte* buffer, size_t bufferSize) override;
|
||||
virtual bool hasDataAvailableForRead() const override;
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ int main(int c, char** v)
|
|||
printf("failed to open %s inside fs image\n", v[2]);
|
||||
return 1;
|
||||
}
|
||||
auto contents = descriptor->readEntireFile();
|
||||
auto contents = descriptor->read_entire_file();
|
||||
|
||||
FILE* fout = fopen(v[3], "w");
|
||||
if (!fout) {
|
||||
|
@ -142,7 +142,7 @@ int main(int c, char** v)
|
|||
}
|
||||
int error;
|
||||
auto new_cwd = vfs.open(new_path.string(), error, 0, cwd);
|
||||
if (new_cwd && new_cwd->isDirectory()) {
|
||||
if (new_cwd && new_cwd->is_directory()) {
|
||||
currentDirectory = new_path.string();
|
||||
cwd = new_cwd->metadata().inode;
|
||||
} else {
|
||||
|
@ -198,7 +198,7 @@ int main(int c, char** v)
|
|||
printf("failed to open %s\n", pathbuf);
|
||||
continue;
|
||||
}
|
||||
auto contents = descriptor->readEntireFile();
|
||||
auto contents = descriptor->read_entire_file();
|
||||
fwrite(contents.pointer(), sizeof(char), contents.size(), stdout);
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue