mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:17:45 +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
|
@ -3,9 +3,12 @@
|
|||
#include "CharacterDevice.h"
|
||||
#include "sys-errno.h"
|
||||
#include "UnixTypes.h"
|
||||
#include "TTY.h"
|
||||
#include <AK/BufferStream.h>
|
||||
|
||||
#ifdef SERENITY
|
||||
#include "TTY.h"
|
||||
#endif
|
||||
|
||||
RetainPtr<FileDescriptor> FileDescriptor::create(RetainPtr<VirtualFileSystem::Node>&& 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());
|
||||
return stream.offset();
|
||||
}
|
||||
|
||||
\
|
||||
#ifdef SERENITY
|
||||
bool FileDescriptor::isTTY() const
|
||||
{
|
||||
if (auto* device = m_vnode->characterDevice())
|
||||
|
@ -199,6 +203,7 @@ TTY* FileDescriptor::tty()
|
|||
return static_cast<TTY*>(device);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
int FileDescriptor::close()
|
||||
{
|
||||
|
@ -207,7 +212,9 @@ int FileDescriptor::close()
|
|||
|
||||
String FileDescriptor::absolute_path() const
|
||||
{
|
||||
#ifdef SERENITY
|
||||
if (isTTY())
|
||||
return tty()->ttyName();
|
||||
#endif
|
||||
return VirtualFileSystem::the().absolutePath(m_vnode->inode);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Retainable.h>
|
||||
|
||||
#ifdef SERENITY
|
||||
class TTY;
|
||||
#endif
|
||||
|
||||
class FileDescriptor : public Retainable<FileDescriptor> {
|
||||
public:
|
||||
|
@ -31,9 +33,11 @@ public:
|
|||
|
||||
bool isDirectory() const;
|
||||
|
||||
#ifdef SERENITY
|
||||
bool isTTY() const;
|
||||
const TTY* tty() const;
|
||||
TTY* tty();
|
||||
#endif
|
||||
|
||||
InodeMetadata metadata() const { return m_vnode->metadata(); }
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ VFS_OBJS = \
|
|||
FileSystem.o \
|
||||
Ext2FileSystem.o \
|
||||
VirtualFileSystem.o \
|
||||
FileHandle.o \
|
||||
FileDescriptor.o \
|
||||
DiskBackedFileSystem.o \
|
||||
SyntheticFileSystem.o \
|
||||
InodeIdentifier.o \
|
||||
|
|
|
@ -37,8 +37,8 @@ bool SyntheticFileSystem::initialize()
|
|||
m_inodes.set(RootInodeIndex, move(rootDir));
|
||||
|
||||
#ifndef SERENITY
|
||||
addFile(createTextFile("file", "I'm a synthetic file!\n"));
|
||||
addFile(createTextFile("message", "Hey! This isn't my bottle!\n"));
|
||||
addFile(createTextFile("file", String("I'm a synthetic file!\n").toByteBuffer(), 0100644));
|
||||
addFile(createTextFile("message", String("Hey! This isn't my bottle!\n").toByteBuffer(), 0100644));
|
||||
addFile(createGeneratedFile("lunk", [] { return String("/home/andreas/file1").toByteBuffer(); }, 00120777));
|
||||
#endif
|
||||
return true;
|
||||
|
|
|
@ -12,24 +12,19 @@
|
|||
|
||||
static VirtualFileSystem* s_the;
|
||||
|
||||
#ifndef SERENITY
|
||||
typedef int InterruptDisabler;
|
||||
#endif
|
||||
|
||||
VirtualFileSystem& VirtualFileSystem::the()
|
||||
{
|
||||
ASSERT(s_the);
|
||||
return *s_the;
|
||||
}
|
||||
|
||||
static SpinLock* s_vfsLock;
|
||||
|
||||
SpinLock& VirtualFileSystem::lock()
|
||||
{
|
||||
ASSERT(s_vfsLock);
|
||||
return *s_vfsLock;
|
||||
}
|
||||
|
||||
void VirtualFileSystem::initializeGlobals()
|
||||
{
|
||||
s_the = nullptr;
|
||||
s_vfsLock = new SpinLock;
|
||||
FileSystem::initializeGlobals();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <AK/RetainPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/Lock.h>
|
||||
#include <AK/Function.h>
|
||||
#include "InodeIdentifier.h"
|
||||
#include "InodeMetadata.h"
|
||||
|
@ -31,7 +30,6 @@ class VirtualFileSystem {
|
|||
AK_MAKE_ETERNAL
|
||||
public:
|
||||
static void initializeGlobals();
|
||||
static SpinLock& lock();
|
||||
|
||||
class Mount {
|
||||
public:
|
||||
|
|
|
@ -26,16 +26,16 @@ int main(int c, char** v)
|
|||
VirtualFileSystem vfs;
|
||||
|
||||
auto zero = make<ZeroDevice>();
|
||||
vfs.registerCharacterDevice(1, 5, *zero);
|
||||
vfs.registerCharacterDevice(*zero);
|
||||
|
||||
auto null = make<NullDevice>();
|
||||
vfs.registerCharacterDevice(1, 3, *null);
|
||||
vfs.registerCharacterDevice(*null);
|
||||
|
||||
auto full = make<FullDevice>();
|
||||
vfs.registerCharacterDevice(1, 7, *full);
|
||||
vfs.registerCharacterDevice(*full);
|
||||
|
||||
auto random = make<RandomDevice>();
|
||||
vfs.registerCharacterDevice(1, 8, *random);
|
||||
vfs.registerCharacterDevice(*random);
|
||||
|
||||
if (!vfs.mountRoot(makeFileSystem(filename))) {
|
||||
printf("Failed to mount root :(\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue