mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 11:37:35 +00:00
Make VFS test environment build again.
This commit is contained in:
parent
83172e6a4b
commit
981a3ae4b3
12 changed files with 40 additions and 34 deletions
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
#ifdef SERENITY
|
#ifdef SERENITY
|
||||||
#include "i386.h"
|
#include "i386.h"
|
||||||
|
int sched_yield();
|
||||||
#else
|
#else
|
||||||
|
#include <sched.h>
|
||||||
typedef int InterruptDisabler;
|
typedef int InterruptDisabler;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -14,8 +16,6 @@ void log_try_lock(const char*);
|
||||||
void log_locked(const char*);
|
void log_locked(const char*);
|
||||||
void log_unlocked(const char*);
|
void log_unlocked(const char*);
|
||||||
|
|
||||||
void yield();
|
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
static inline dword CAS(volatile dword* mem, dword newval, dword oldval)
|
static inline dword CAS(volatile dword* mem, dword newval, dword oldval)
|
||||||
|
@ -51,7 +51,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
yield();
|
sched_yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "IO.h"
|
#include "IO.h"
|
||||||
#include "i386.h"
|
#include "i386.h"
|
||||||
#include "PIC.h"
|
#include "PIC.h"
|
||||||
|
#include <AK/Lock.h>
|
||||||
|
|
||||||
//#define DISK_DEBUG
|
//#define DISK_DEBUG
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ static bool waitForInterrupt()
|
||||||
#endif
|
#endif
|
||||||
// FIXME: Add timeout.
|
// FIXME: Add timeout.
|
||||||
while (!interrupted) {
|
while (!interrupted) {
|
||||||
yield();
|
sched_yield();
|
||||||
}
|
}
|
||||||
#ifdef DISK_DEBUG
|
#ifdef DISK_DEBUG
|
||||||
kprintf("disk: got interrupt!\n");
|
kprintf("disk: got interrupt!\n");
|
||||||
|
|
|
@ -388,7 +388,7 @@ int Process::exec(const String& path, Vector<String>&& arguments, Vector<String>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (current == this)
|
if (current == this)
|
||||||
yield();
|
sched_yield();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -814,7 +814,7 @@ void Process::send_signal(int signal, Process* sender)
|
||||||
dbgprintf("signal: %s(%u) sent %d to %s(%u)\n", sender->name().characters(), sender->pid(), signal, name().characters(), pid());
|
dbgprintf("signal: %s(%u) sent %d to %s(%u)\n", sender->name().characters(), sender->pid(), signal, name().characters(), pid());
|
||||||
|
|
||||||
if (sender == this) {
|
if (sender == this) {
|
||||||
yield();
|
sched_yield();
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -865,7 +865,7 @@ void Process::doHouseKeeping()
|
||||||
s_deadProcesses->clear();
|
s_deadProcesses->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void yield()
|
int sched_yield()
|
||||||
{
|
{
|
||||||
if (!current) {
|
if (!current) {
|
||||||
kprintf( "PANIC: yield() with !current" );
|
kprintf( "PANIC: yield() with !current" );
|
||||||
|
@ -876,10 +876,11 @@ void yield()
|
||||||
|
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
if (!scheduleNewProcess())
|
if (!scheduleNewProcess())
|
||||||
return;
|
return 1;
|
||||||
|
|
||||||
//kprintf("yield() jumping to new process: %x (%s)\n", current->farPtr().selector, current->name().characters());
|
//kprintf("yield() jumping to new process: %x (%s)\n", current->farPtr().selector, current->name().characters());
|
||||||
switchNow();
|
switchNow();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchNow()
|
void switchNow()
|
||||||
|
@ -1121,7 +1122,7 @@ ssize_t Process::sys$read(int fd, void* outbuf, size_t nread)
|
||||||
if (!descriptor->hasDataAvailableForRead()) {
|
if (!descriptor->hasDataAvailableForRead()) {
|
||||||
m_fdBlockedOnRead = fd;
|
m_fdBlockedOnRead = fd;
|
||||||
block(BlockedRead);
|
block(BlockedRead);
|
||||||
yield();
|
sched_yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nread = descriptor->read((byte*)outbuf, nread);
|
nread = descriptor->read((byte*)outbuf, nread);
|
||||||
|
@ -1351,7 +1352,7 @@ pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options)
|
||||||
m_waitee = waitee;
|
m_waitee = waitee;
|
||||||
m_waiteeStatus = 0;
|
m_waiteeStatus = 0;
|
||||||
block(BlockedWait);
|
block(BlockedWait);
|
||||||
yield();
|
sched_yield();
|
||||||
if (wstatus)
|
if (wstatus)
|
||||||
*wstatus = m_waiteeStatus;
|
*wstatus = m_waiteeStatus;
|
||||||
return m_waitee;
|
return m_waitee;
|
||||||
|
@ -1374,7 +1375,7 @@ void Process::block(Process::State state)
|
||||||
void block(Process::State state)
|
void block(Process::State state)
|
||||||
{
|
{
|
||||||
current->block(state);
|
current->block(state);
|
||||||
yield();
|
sched_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sleep(DWORD ticks)
|
void sleep(DWORD ticks)
|
||||||
|
@ -1382,7 +1383,7 @@ void sleep(DWORD ticks)
|
||||||
ASSERT(current->state() == Process::Running);
|
ASSERT(current->state() == Process::Running);
|
||||||
current->setWakeupTime(system.uptime + ticks);
|
current->setWakeupTime(system.uptime + ticks);
|
||||||
current->block(Process::BlockedSleep);
|
current->block(Process::BlockedSleep);
|
||||||
yield();
|
sched_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
Process* Process::kernelProcess()
|
Process* Process::kernelProcess()
|
||||||
|
|
|
@ -284,7 +284,7 @@ static inline const char* toString(Process::State state)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void yield();
|
extern int sched_yield();
|
||||||
extern bool scheduleNewProcess();
|
extern bool scheduleNewProcess();
|
||||||
extern void switchNow();
|
extern void switchNow();
|
||||||
extern void block(Process::State);
|
extern void block(Process::State);
|
||||||
|
|
|
@ -48,7 +48,7 @@ static DWORD handle(RegisterDump& regs, DWORD function, DWORD arg1, DWORD arg2,
|
||||||
ASSERT_INTERRUPTS_ENABLED();
|
ASSERT_INTERRUPTS_ENABLED();
|
||||||
switch (function) {
|
switch (function) {
|
||||||
case Syscall::SC_yield:
|
case Syscall::SC_yield:
|
||||||
yield();
|
sched_yield();
|
||||||
break;
|
break;
|
||||||
case Syscall::SC_putch:
|
case Syscall::SC_putch:
|
||||||
Console::the().putChar(arg1 & 0xff);
|
Console::the().putChar(arg1 & 0xff);
|
||||||
|
|
|
@ -3,9 +3,12 @@
|
||||||
#include "CharacterDevice.h"
|
#include "CharacterDevice.h"
|
||||||
#include "sys-errno.h"
|
#include "sys-errno.h"
|
||||||
#include "UnixTypes.h"
|
#include "UnixTypes.h"
|
||||||
#include "TTY.h"
|
|
||||||
#include <AK/BufferStream.h>
|
#include <AK/BufferStream.h>
|
||||||
|
|
||||||
|
#ifdef SERENITY
|
||||||
|
#include "TTY.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
RetainPtr<FileDescriptor> FileDescriptor::create(RetainPtr<VirtualFileSystem::Node>&& vnode)
|
RetainPtr<FileDescriptor> FileDescriptor::create(RetainPtr<VirtualFileSystem::Node>&& vnode)
|
||||||
{
|
{
|
||||||
return adopt(*new FileDescriptor(move(vnode)));
|
return adopt(*new FileDescriptor(move(vnode)));
|
||||||
|
@ -178,7 +181,8 @@ ssize_t FileDescriptor::get_dir_entries(byte* buffer, Unix::size_t size)
|
||||||
memcpy(buffer, tempBuffer.pointer(), stream.offset());
|
memcpy(buffer, tempBuffer.pointer(), stream.offset());
|
||||||
return stream.offset();
|
return stream.offset();
|
||||||
}
|
}
|
||||||
|
\
|
||||||
|
#ifdef SERENITY
|
||||||
bool FileDescriptor::isTTY() const
|
bool FileDescriptor::isTTY() const
|
||||||
{
|
{
|
||||||
if (auto* device = m_vnode->characterDevice())
|
if (auto* device = m_vnode->characterDevice())
|
||||||
|
@ -199,6 +203,7 @@ TTY* FileDescriptor::tty()
|
||||||
return static_cast<TTY*>(device);
|
return static_cast<TTY*>(device);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int FileDescriptor::close()
|
int FileDescriptor::close()
|
||||||
{
|
{
|
||||||
|
@ -207,7 +212,9 @@ int FileDescriptor::close()
|
||||||
|
|
||||||
String FileDescriptor::absolute_path() const
|
String FileDescriptor::absolute_path() const
|
||||||
{
|
{
|
||||||
|
#ifdef SERENITY
|
||||||
if (isTTY())
|
if (isTTY())
|
||||||
return tty()->ttyName();
|
return tty()->ttyName();
|
||||||
|
#endif
|
||||||
return VirtualFileSystem::the().absolutePath(m_vnode->inode);
|
return VirtualFileSystem::the().absolutePath(m_vnode->inode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
#include <AK/ByteBuffer.h>
|
#include <AK/ByteBuffer.h>
|
||||||
#include <AK/Retainable.h>
|
#include <AK/Retainable.h>
|
||||||
|
|
||||||
|
#ifdef SERENITY
|
||||||
class TTY;
|
class TTY;
|
||||||
|
#endif
|
||||||
|
|
||||||
class FileDescriptor : public Retainable<FileDescriptor> {
|
class FileDescriptor : public Retainable<FileDescriptor> {
|
||||||
public:
|
public:
|
||||||
|
@ -31,9 +33,11 @@ public:
|
||||||
|
|
||||||
bool isDirectory() const;
|
bool isDirectory() const;
|
||||||
|
|
||||||
|
#ifdef SERENITY
|
||||||
bool isTTY() const;
|
bool isTTY() const;
|
||||||
const TTY* tty() const;
|
const TTY* tty() const;
|
||||||
TTY* tty();
|
TTY* tty();
|
||||||
|
#endif
|
||||||
|
|
||||||
InodeMetadata metadata() const { return m_vnode->metadata(); }
|
InodeMetadata metadata() const { return m_vnode->metadata(); }
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ VFS_OBJS = \
|
||||||
FileSystem.o \
|
FileSystem.o \
|
||||||
Ext2FileSystem.o \
|
Ext2FileSystem.o \
|
||||||
VirtualFileSystem.o \
|
VirtualFileSystem.o \
|
||||||
FileHandle.o \
|
FileDescriptor.o \
|
||||||
DiskBackedFileSystem.o \
|
DiskBackedFileSystem.o \
|
||||||
SyntheticFileSystem.o \
|
SyntheticFileSystem.o \
|
||||||
InodeIdentifier.o \
|
InodeIdentifier.o \
|
||||||
|
|
|
@ -37,8 +37,8 @@ bool SyntheticFileSystem::initialize()
|
||||||
m_inodes.set(RootInodeIndex, move(rootDir));
|
m_inodes.set(RootInodeIndex, move(rootDir));
|
||||||
|
|
||||||
#ifndef SERENITY
|
#ifndef SERENITY
|
||||||
addFile(createTextFile("file", "I'm a synthetic file!\n"));
|
addFile(createTextFile("file", String("I'm a synthetic file!\n").toByteBuffer(), 0100644));
|
||||||
addFile(createTextFile("message", "Hey! This isn't my bottle!\n"));
|
addFile(createTextFile("message", String("Hey! This isn't my bottle!\n").toByteBuffer(), 0100644));
|
||||||
addFile(createGeneratedFile("lunk", [] { return String("/home/andreas/file1").toByteBuffer(); }, 00120777));
|
addFile(createGeneratedFile("lunk", [] { return String("/home/andreas/file1").toByteBuffer(); }, 00120777));
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -12,24 +12,19 @@
|
||||||
|
|
||||||
static VirtualFileSystem* s_the;
|
static VirtualFileSystem* s_the;
|
||||||
|
|
||||||
|
#ifndef SERENITY
|
||||||
|
typedef int InterruptDisabler;
|
||||||
|
#endif
|
||||||
|
|
||||||
VirtualFileSystem& VirtualFileSystem::the()
|
VirtualFileSystem& VirtualFileSystem::the()
|
||||||
{
|
{
|
||||||
ASSERT(s_the);
|
ASSERT(s_the);
|
||||||
return *s_the;
|
return *s_the;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpinLock* s_vfsLock;
|
|
||||||
|
|
||||||
SpinLock& VirtualFileSystem::lock()
|
|
||||||
{
|
|
||||||
ASSERT(s_vfsLock);
|
|
||||||
return *s_vfsLock;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VirtualFileSystem::initializeGlobals()
|
void VirtualFileSystem::initializeGlobals()
|
||||||
{
|
{
|
||||||
s_the = nullptr;
|
s_the = nullptr;
|
||||||
s_vfsLock = new SpinLock;
|
|
||||||
FileSystem::initializeGlobals();
|
FileSystem::initializeGlobals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <AK/RetainPtr.h>
|
#include <AK/RetainPtr.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <AK/Lock.h>
|
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include "InodeIdentifier.h"
|
#include "InodeIdentifier.h"
|
||||||
#include "InodeMetadata.h"
|
#include "InodeMetadata.h"
|
||||||
|
@ -31,7 +30,6 @@ class VirtualFileSystem {
|
||||||
AK_MAKE_ETERNAL
|
AK_MAKE_ETERNAL
|
||||||
public:
|
public:
|
||||||
static void initializeGlobals();
|
static void initializeGlobals();
|
||||||
static SpinLock& lock();
|
|
||||||
|
|
||||||
class Mount {
|
class Mount {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -26,16 +26,16 @@ int main(int c, char** v)
|
||||||
VirtualFileSystem vfs;
|
VirtualFileSystem vfs;
|
||||||
|
|
||||||
auto zero = make<ZeroDevice>();
|
auto zero = make<ZeroDevice>();
|
||||||
vfs.registerCharacterDevice(1, 5, *zero);
|
vfs.registerCharacterDevice(*zero);
|
||||||
|
|
||||||
auto null = make<NullDevice>();
|
auto null = make<NullDevice>();
|
||||||
vfs.registerCharacterDevice(1, 3, *null);
|
vfs.registerCharacterDevice(*null);
|
||||||
|
|
||||||
auto full = make<FullDevice>();
|
auto full = make<FullDevice>();
|
||||||
vfs.registerCharacterDevice(1, 7, *full);
|
vfs.registerCharacterDevice(*full);
|
||||||
|
|
||||||
auto random = make<RandomDevice>();
|
auto random = make<RandomDevice>();
|
||||||
vfs.registerCharacterDevice(1, 8, *random);
|
vfs.registerCharacterDevice(*random);
|
||||||
|
|
||||||
if (!vfs.mountRoot(makeFileSystem(filename))) {
|
if (!vfs.mountRoot(makeFileSystem(filename))) {
|
||||||
printf("Failed to mount root :(\n");
|
printf("Failed to mount root :(\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue