mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
AK: Rename RetainPtr => RefPtr and Retained => NonnullRefPtr.
This commit is contained in:
parent
77b9fa89dd
commit
90b1354688
188 changed files with 562 additions and 562 deletions
|
@ -2,12 +2,12 @@
|
|||
|
||||
// #define OFFD_DEBUG
|
||||
|
||||
Retained<DiskPartition> DiskPartition::create(Retained<DiskDevice>&& device, unsigned block_offset)
|
||||
NonnullRefPtr<DiskPartition> DiskPartition::create(NonnullRefPtr<DiskDevice>&& device, unsigned block_offset)
|
||||
{
|
||||
return adopt(*new DiskPartition(move(device), block_offset));
|
||||
}
|
||||
|
||||
DiskPartition::DiskPartition(Retained<DiskDevice>&& device, unsigned block_offset)
|
||||
DiskPartition::DiskPartition(NonnullRefPtr<DiskDevice>&& device, unsigned block_offset)
|
||||
: m_device(move(device))
|
||||
, m_block_offset(block_offset)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class DiskPartition final : public DiskDevice {
|
||||
public:
|
||||
static Retained<DiskPartition> create(Retained<DiskDevice>&& device, unsigned block_offset);
|
||||
static NonnullRefPtr<DiskPartition> create(NonnullRefPtr<DiskDevice>&& device, unsigned block_offset);
|
||||
virtual ~DiskPartition();
|
||||
|
||||
virtual unsigned block_size() const override;
|
||||
|
@ -17,8 +17,8 @@ public:
|
|||
private:
|
||||
virtual const char* class_name() const override;
|
||||
|
||||
DiskPartition(Retained<DiskDevice>&&, unsigned);
|
||||
DiskPartition(NonnullRefPtr<DiskDevice>&&, unsigned);
|
||||
|
||||
Retained<DiskDevice> m_device;
|
||||
NonnullRefPtr<DiskDevice> m_device;
|
||||
unsigned m_block_offset;
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
//#define FBBD_DEBUG
|
||||
#define IGNORE_FILE_LENGTH // Useful for e.g /dev/hda2
|
||||
|
||||
RetainPtr<FileBackedDiskDevice> FileBackedDiskDevice::create(String&& image_path, unsigned block_size)
|
||||
RefPtr<FileBackedDiskDevice> FileBackedDiskDevice::create(String&& image_path, unsigned block_size)
|
||||
{
|
||||
return adopt(*new FileBackedDiskDevice(move(image_path), block_size));
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
class FileBackedDiskDevice final : public DiskDevice {
|
||||
public:
|
||||
static RetainPtr<FileBackedDiskDevice> create(String&& image_path, unsigned block_size);
|
||||
static RefPtr<FileBackedDiskDevice> create(String&& image_path, unsigned block_size);
|
||||
virtual ~FileBackedDiskDevice() override;
|
||||
|
||||
bool is_valid() const { return m_file; }
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
#define ATA_REG_ALTSTATUS 0x0C
|
||||
#define ATA_REG_DEVADDRESS 0x0D
|
||||
|
||||
Retained<IDEDiskDevice> IDEDiskDevice::create()
|
||||
NonnullRefPtr<IDEDiskDevice> IDEDiskDevice::create()
|
||||
{
|
||||
return adopt(*new IDEDiskDevice);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class IDEDiskDevice final : public IRQHandler
|
|||
, public DiskDevice {
|
||||
AK_MAKE_ETERNAL
|
||||
public:
|
||||
static Retained<IDEDiskDevice> create();
|
||||
static NonnullRefPtr<IDEDiskDevice> create();
|
||||
virtual ~IDEDiskDevice() override;
|
||||
|
||||
// ^DiskDevice
|
||||
|
@ -55,7 +55,7 @@ private:
|
|||
|
||||
PCI::Address m_pci_address;
|
||||
PhysicalRegionDescriptor m_prdt;
|
||||
RetainPtr<PhysicalPage> m_dma_buffer_page;
|
||||
RefPtr<PhysicalPage> m_dma_buffer_page;
|
||||
word m_bus_master_base { 0 };
|
||||
Lockable<bool> m_dma_enabled;
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#define MBR_DEBUG
|
||||
|
||||
MBRPartitionTable::MBRPartitionTable(Retained<DiskDevice>&& device)
|
||||
MBRPartitionTable::MBRPartitionTable(NonnullRefPtr<DiskDevice>&& device)
|
||||
: m_device(move(device))
|
||||
{
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ bool MBRPartitionTable::initialize()
|
|||
return true;
|
||||
}
|
||||
|
||||
RetainPtr<DiskPartition> MBRPartitionTable::partition(unsigned index)
|
||||
RefPtr<DiskPartition> MBRPartitionTable::partition(unsigned index)
|
||||
{
|
||||
ASSERT(index >= 1 && index <= 4);
|
||||
|
||||
|
|
|
@ -31,14 +31,14 @@ class MBRPartitionTable {
|
|||
AK_MAKE_ETERNAL
|
||||
|
||||
public:
|
||||
MBRPartitionTable(Retained<DiskDevice>&& device);
|
||||
MBRPartitionTable(NonnullRefPtr<DiskDevice>&& device);
|
||||
~MBRPartitionTable();
|
||||
|
||||
bool initialize();
|
||||
RetainPtr<DiskPartition> partition(unsigned index);
|
||||
RefPtr<DiskPartition> partition(unsigned index);
|
||||
|
||||
private:
|
||||
Retained<DiskDevice> m_device;
|
||||
NonnullRefPtr<DiskDevice> m_device;
|
||||
|
||||
ByteBuffer read_header() const;
|
||||
const MBRPartitionHeader& header() const;
|
||||
|
|
|
@ -9,7 +9,7 @@ File::~File()
|
|||
{
|
||||
}
|
||||
|
||||
KResultOr<Retained<FileDescription>> File::open(int options)
|
||||
KResultOr<NonnullRefPtr<FileDescription>> File::open(int options)
|
||||
{
|
||||
UNUSED_PARAM(options);
|
||||
return FileDescription::create(this);
|
||||
|
|
|
@ -43,7 +43,7 @@ class File : public RefCounted<File> {
|
|||
public:
|
||||
virtual ~File();
|
||||
|
||||
virtual KResultOr<Retained<FileDescription>> open(int options);
|
||||
virtual KResultOr<NonnullRefPtr<FileDescription>> open(int options);
|
||||
virtual void close();
|
||||
|
||||
virtual bool can_read(FileDescription&) const = 0;
|
||||
|
|
|
@ -26,9 +26,9 @@ Custody* Custody::get_if_cached(Custody* parent, const String& name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Retained<Custody> Custody::get_or_create(Custody* parent, const String& name, Inode& inode)
|
||||
NonnullRefPtr<Custody> Custody::get_or_create(Custody* parent, const String& name, Inode& inode)
|
||||
{
|
||||
if (RetainPtr<Custody> cached_custody = get_if_cached(parent, name)) {
|
||||
if (RefPtr<Custody> cached_custody = get_if_cached(parent, name)) {
|
||||
if (&cached_custody->inode() != &inode) {
|
||||
dbgprintf("WTF! cached custody for name '%s' has inode=%s, new inode=%s\n",
|
||||
name.characters(),
|
||||
|
|
|
@ -13,8 +13,8 @@ class VFS;
|
|||
class Custody : public RefCounted<Custody> {
|
||||
public:
|
||||
static Custody* get_if_cached(Custody* parent, const String& name);
|
||||
static Retained<Custody> get_or_create(Custody* parent, const String& name, Inode&);
|
||||
static Retained<Custody> create(Custody* parent, const String& name, Inode& inode)
|
||||
static NonnullRefPtr<Custody> get_or_create(Custody* parent, const String& name, Inode&);
|
||||
static NonnullRefPtr<Custody> create(Custody* parent, const String& name, Inode& inode)
|
||||
{
|
||||
return adopt(*new Custody(parent, name, inode));
|
||||
}
|
||||
|
@ -38,9 +38,9 @@ public:
|
|||
private:
|
||||
Custody(Custody* parent, const String& name, Inode&);
|
||||
|
||||
RetainPtr<Custody> m_parent;
|
||||
RefPtr<Custody> m_parent;
|
||||
String m_name;
|
||||
Retained<Inode> m_inode;
|
||||
NonnullRefPtr<Inode> m_inode;
|
||||
bool m_deleted { false };
|
||||
bool m_mounted_on { false };
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@ DevPtsFS& DevPtsFS::the()
|
|||
return *s_the;
|
||||
}
|
||||
|
||||
Retained<DevPtsFS> DevPtsFS::create()
|
||||
NonnullRefPtr<DevPtsFS> DevPtsFS::create()
|
||||
{
|
||||
return adopt(*new DevPtsFS);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ const char* DevPtsFS::class_name() const
|
|||
return "DevPtsFS";
|
||||
}
|
||||
|
||||
Retained<SynthFSInode> DevPtsFS::create_slave_pty_device_file(unsigned index)
|
||||
NonnullRefPtr<SynthFSInode> DevPtsFS::create_slave_pty_device_file(unsigned index)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ public:
|
|||
[[gnu::pure]] static DevPtsFS& the();
|
||||
|
||||
virtual ~DevPtsFS() override;
|
||||
static Retained<DevPtsFS> create();
|
||||
static NonnullRefPtr<DevPtsFS> create();
|
||||
|
||||
virtual bool initialize() override;
|
||||
virtual const char* class_name() const override;
|
||||
|
@ -22,7 +22,7 @@ public:
|
|||
private:
|
||||
DevPtsFS();
|
||||
|
||||
Retained<SynthFSInode> create_slave_pty_device_file(unsigned index);
|
||||
NonnullRefPtr<SynthFSInode> create_slave_pty_device_file(unsigned index);
|
||||
|
||||
HashTable<SlavePTY*> m_slave_ptys;
|
||||
};
|
||||
|
|
|
@ -45,7 +45,7 @@ Lockable<InlineLRUCache<BlockIdentifier, CachedBlock>>& block_cache()
|
|||
return *s_cache;
|
||||
}
|
||||
|
||||
DiskBackedFS::DiskBackedFS(Retained<DiskDevice>&& device)
|
||||
DiskBackedFS::DiskBackedFS(NonnullRefPtr<DiskDevice>&& device)
|
||||
: m_device(move(device))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
virtual void flush_writes() override;
|
||||
|
||||
protected:
|
||||
explicit DiskBackedFS(Retained<DiskDevice>&&);
|
||||
explicit DiskBackedFS(NonnullRefPtr<DiskDevice>&&);
|
||||
|
||||
void set_block_size(unsigned);
|
||||
|
||||
|
@ -27,7 +27,7 @@ protected:
|
|||
|
||||
private:
|
||||
int m_block_size { 0 };
|
||||
Retained<DiskDevice> m_device;
|
||||
NonnullRefPtr<DiskDevice> m_device;
|
||||
|
||||
HashMap<unsigned, ByteBuffer> m_write_cache;
|
||||
};
|
||||
|
|
|
@ -31,12 +31,12 @@ static byte to_ext2_file_type(mode_t mode)
|
|||
return EXT2_FT_UNKNOWN;
|
||||
}
|
||||
|
||||
Retained<Ext2FS> Ext2FS::create(Retained<DiskDevice>&& device)
|
||||
NonnullRefPtr<Ext2FS> Ext2FS::create(NonnullRefPtr<DiskDevice>&& device)
|
||||
{
|
||||
return adopt(*new Ext2FS(move(device)));
|
||||
}
|
||||
|
||||
Ext2FS::Ext2FS(Retained<DiskDevice>&& device)
|
||||
Ext2FS::Ext2FS(NonnullRefPtr<DiskDevice>&& device)
|
||||
: DiskBackedFS(move(device))
|
||||
{
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ void Ext2FSInode::flush_metadata()
|
|||
set_metadata_dirty(false);
|
||||
}
|
||||
|
||||
RetainPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
|
||||
RefPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(inode.fsid() == fsid());
|
||||
|
@ -1085,7 +1085,7 @@ bool Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state)
|
|||
return true;
|
||||
}
|
||||
|
||||
RetainPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const String& name, mode_t mode, int& error)
|
||||
RefPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const String& name, mode_t mode, int& error)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(parent_id.fsid() == fsid());
|
||||
|
@ -1125,7 +1125,7 @@ RetainPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const Strin
|
|||
return inode;
|
||||
}
|
||||
|
||||
RetainPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& name, mode_t mode, off_t size, dev_t dev, int& error)
|
||||
RefPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& name, mode_t mode, off_t size, dev_t dev, int& error)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(parent_id.fsid() == fsid());
|
||||
|
|
|
@ -60,7 +60,7 @@ class Ext2FS final : public DiskBackedFS {
|
|||
friend class Ext2FSInode;
|
||||
|
||||
public:
|
||||
static Retained<Ext2FS> create(Retained<DiskDevice>&&);
|
||||
static NonnullRefPtr<Ext2FS> create(NonnullRefPtr<DiskDevice>&&);
|
||||
virtual ~Ext2FS() override;
|
||||
virtual bool initialize() override;
|
||||
|
||||
|
@ -73,7 +73,7 @@ private:
|
|||
typedef unsigned BlockIndex;
|
||||
typedef unsigned GroupIndex;
|
||||
typedef unsigned InodeIndex;
|
||||
explicit Ext2FS(Retained<DiskDevice>&&);
|
||||
explicit Ext2FS(NonnullRefPtr<DiskDevice>&&);
|
||||
|
||||
const ext2_super_block& super_block() const;
|
||||
const ext2_group_desc& group_descriptor(unsigned groupIndex) const;
|
||||
|
@ -92,9 +92,9 @@ private:
|
|||
|
||||
virtual const char* class_name() const override;
|
||||
virtual InodeIdentifier root_inode() const override;
|
||||
virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) override;
|
||||
virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override;
|
||||
virtual RetainPtr<Inode> get_inode(InodeIdentifier) const override;
|
||||
virtual RefPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) override;
|
||||
virtual RefPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override;
|
||||
virtual RefPtr<Inode> get_inode(InodeIdentifier) const override;
|
||||
|
||||
InodeIndex allocate_inode(GroupIndex preferred_group, off_t expected_size);
|
||||
Vector<BlockIndex> allocate_blocks(GroupIndex, int count);
|
||||
|
@ -126,7 +126,7 @@ private:
|
|||
mutable ByteBuffer m_cached_super_block;
|
||||
mutable ByteBuffer m_cached_group_descriptor_table;
|
||||
|
||||
mutable HashMap<BlockIndex, RetainPtr<Ext2FSInode>> m_inode_cache;
|
||||
mutable HashMap<BlockIndex, RefPtr<Ext2FSInode>> m_inode_cache;
|
||||
};
|
||||
|
||||
inline Ext2FS& Ext2FSInode::fs()
|
||||
|
|
|
@ -16,7 +16,7 @@ Lockable<HashTable<FIFO*>>& all_fifos()
|
|||
return *s_table;
|
||||
}
|
||||
|
||||
RetainPtr<FIFO> FIFO::from_fifo_id(dword id)
|
||||
RefPtr<FIFO> FIFO::from_fifo_id(dword id)
|
||||
{
|
||||
auto* ptr = reinterpret_cast<FIFO*>(id);
|
||||
LOCKER(all_fifos().lock());
|
||||
|
@ -25,12 +25,12 @@ RetainPtr<FIFO> FIFO::from_fifo_id(dword id)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
Retained<FIFO> FIFO::create(uid_t uid)
|
||||
NonnullRefPtr<FIFO> FIFO::create(uid_t uid)
|
||||
{
|
||||
return adopt(*new FIFO(uid));
|
||||
}
|
||||
|
||||
Retained<FileDescription> FIFO::open_direction(FIFO::Direction direction)
|
||||
NonnullRefPtr<FileDescription> FIFO::open_direction(FIFO::Direction direction)
|
||||
{
|
||||
auto description = FileDescription::create(this);
|
||||
attach(direction);
|
||||
|
|
|
@ -14,14 +14,14 @@ public:
|
|||
Writer
|
||||
};
|
||||
|
||||
static RetainPtr<FIFO> from_fifo_id(dword);
|
||||
static RefPtr<FIFO> from_fifo_id(dword);
|
||||
|
||||
static Retained<FIFO> create(uid_t);
|
||||
static NonnullRefPtr<FIFO> create(uid_t);
|
||||
virtual ~FIFO() override;
|
||||
|
||||
uid_t uid() const { return m_uid; }
|
||||
|
||||
Retained<FileDescription> open_direction(Direction);
|
||||
NonnullRefPtr<FileDescription> open_direction(Direction);
|
||||
|
||||
void attach(Direction);
|
||||
void detach(Direction);
|
||||
|
|
|
@ -15,19 +15,19 @@
|
|||
#include <Kernel/VM/MemoryManager.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
|
||||
Retained<FileDescription> FileDescription::create(RetainPtr<Custody>&& custody)
|
||||
NonnullRefPtr<FileDescription> FileDescription::create(RefPtr<Custody>&& custody)
|
||||
{
|
||||
auto description = adopt(*new FileDescription(InodeFile::create(custody->inode())));
|
||||
description->m_custody = move(custody);
|
||||
return description;
|
||||
}
|
||||
|
||||
Retained<FileDescription> FileDescription::create(RetainPtr<File>&& file, SocketRole role)
|
||||
NonnullRefPtr<FileDescription> FileDescription::create(RefPtr<File>&& file, SocketRole role)
|
||||
{
|
||||
return adopt(*new FileDescription(move(file), role));
|
||||
}
|
||||
|
||||
FileDescription::FileDescription(RetainPtr<File>&& file, SocketRole role)
|
||||
FileDescription::FileDescription(RefPtr<File>&& file, SocketRole role)
|
||||
: m_file(move(file))
|
||||
{
|
||||
if (m_file->is_inode())
|
||||
|
@ -58,9 +58,9 @@ void FileDescription::set_socket_role(SocketRole role)
|
|||
socket()->attach(*this);
|
||||
}
|
||||
|
||||
Retained<FileDescription> FileDescription::clone()
|
||||
NonnullRefPtr<FileDescription> FileDescription::clone()
|
||||
{
|
||||
RetainPtr<FileDescription> description;
|
||||
RefPtr<FileDescription> description;
|
||||
if (is_fifo()) {
|
||||
description = fifo()->open_direction(m_fifo_direction);
|
||||
} else {
|
||||
|
|
|
@ -21,11 +21,11 @@ class SharedMemory;
|
|||
|
||||
class FileDescription : public RefCounted<FileDescription> {
|
||||
public:
|
||||
static Retained<FileDescription> create(RetainPtr<Custody>&&);
|
||||
static Retained<FileDescription> create(RetainPtr<File>&&, SocketRole = SocketRole::None);
|
||||
static NonnullRefPtr<FileDescription> create(RefPtr<Custody>&&);
|
||||
static NonnullRefPtr<FileDescription> create(RefPtr<File>&&, SocketRole = SocketRole::None);
|
||||
~FileDescription();
|
||||
|
||||
Retained<FileDescription> clone();
|
||||
NonnullRefPtr<FileDescription> clone();
|
||||
|
||||
int close();
|
||||
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
|
||||
ByteBuffer& generator_cache() { return m_generator_cache; }
|
||||
|
||||
void set_original_inode(Badge<VFS>, Retained<Inode>&& inode) { m_inode = move(inode); }
|
||||
void set_original_inode(Badge<VFS>, NonnullRefPtr<Inode>&& inode) { m_inode = move(inode); }
|
||||
|
||||
SocketRole socket_role() const { return m_socket_role; }
|
||||
void set_socket_role(SocketRole);
|
||||
|
@ -105,12 +105,12 @@ public:
|
|||
|
||||
private:
|
||||
friend class VFS;
|
||||
FileDescription(RetainPtr<File>&&, SocketRole = SocketRole::None);
|
||||
FileDescription(RefPtr<File>&&, SocketRole = SocketRole::None);
|
||||
FileDescription(FIFO&, FIFO::Direction);
|
||||
|
||||
RetainPtr<Custody> m_custody;
|
||||
RetainPtr<Inode> m_inode;
|
||||
RetainPtr<File> m_file;
|
||||
RefPtr<Custody> m_custody;
|
||||
RefPtr<Inode> m_inode;
|
||||
RefPtr<File> m_file;
|
||||
|
||||
off_t m_current_offset { 0 };
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void FS::sync()
|
|||
{
|
||||
Inode::sync();
|
||||
|
||||
Vector<Retained<FS>, 32> fses;
|
||||
Vector<NonnullRefPtr<FS>, 32> fses;
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
for (auto& it : all_fses())
|
||||
|
|
|
@ -54,10 +54,10 @@ public:
|
|||
byte file_type { 0 };
|
||||
};
|
||||
|
||||
virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) = 0;
|
||||
virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) = 0;
|
||||
virtual RefPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) = 0;
|
||||
virtual RefPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) = 0;
|
||||
|
||||
virtual RetainPtr<Inode> get_inode(InodeIdentifier) const = 0;
|
||||
virtual RefPtr<Inode> get_inode(InodeIdentifier) const = 0;
|
||||
|
||||
virtual void flush_writes() {}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ HashTable<Inode*>& all_inodes()
|
|||
|
||||
void Inode::sync()
|
||||
{
|
||||
Vector<Retained<Inode>, 32> inodes;
|
||||
Vector<NonnullRefPtr<Inode>, 32> inodes;
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
for (auto* inode : all_inodes()) {
|
||||
|
|
|
@ -85,6 +85,6 @@ private:
|
|||
FS& m_fs;
|
||||
unsigned m_index { 0 };
|
||||
WeakPtr<VMObject> m_vmo;
|
||||
RetainPtr<LocalSocket> m_socket;
|
||||
RefPtr<LocalSocket> m_socket;
|
||||
bool m_metadata_dirty { false };
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/Process.h>
|
||||
|
||||
InodeFile::InodeFile(Retained<Inode>&& inode)
|
||||
InodeFile::InodeFile(NonnullRefPtr<Inode>&& inode)
|
||||
: m_inode(move(inode))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ class Inode;
|
|||
|
||||
class InodeFile final : public File {
|
||||
public:
|
||||
static Retained<InodeFile> create(Retained<Inode>&& inode)
|
||||
static NonnullRefPtr<InodeFile> create(NonnullRefPtr<Inode>&& inode)
|
||||
{
|
||||
return adopt(*new InodeFile(move(inode)));
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ public:
|
|||
virtual bool is_inode() const override { return true; }
|
||||
|
||||
private:
|
||||
explicit InodeFile(Retained<Inode>&&);
|
||||
Retained<Inode> m_inode;
|
||||
explicit InodeFile(NonnullRefPtr<Inode>&&);
|
||||
NonnullRefPtr<Inode> m_inode;
|
||||
};
|
||||
|
|
|
@ -174,7 +174,7 @@ ProcFS& ProcFS::the()
|
|||
return *s_the;
|
||||
}
|
||||
|
||||
Retained<ProcFS> ProcFS::create()
|
||||
NonnullRefPtr<ProcFS> ProcFS::create()
|
||||
{
|
||||
return adopt(*new ProcFS);
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ ByteBuffer procfs$inodes(InodeIdentifier)
|
|||
extern HashTable<Inode*>& all_inodes();
|
||||
StringBuilder builder;
|
||||
for (auto it : all_inodes()) {
|
||||
RetainPtr<Inode> inode = *it;
|
||||
RefPtr<Inode> inode = *it;
|
||||
builder.appendf("Inode{K%x} %02u:%08u (%u)\n", inode.ptr(), inode->fsid(), inode->index(), inode->ref_count());
|
||||
}
|
||||
return builder.to_byte_buffer();
|
||||
|
@ -747,13 +747,13 @@ const char* ProcFS::class_name() const
|
|||
return "ProcFS";
|
||||
}
|
||||
|
||||
RetainPtr<Inode> ProcFS::create_inode(InodeIdentifier, const String&, mode_t, off_t, dev_t, int&)
|
||||
RefPtr<Inode> ProcFS::create_inode(InodeIdentifier, const String&, mode_t, off_t, dev_t, int&)
|
||||
{
|
||||
kprintf("FIXME: Implement ProcFS::create_inode()?\n");
|
||||
return {};
|
||||
}
|
||||
|
||||
RetainPtr<Inode> ProcFS::create_directory(InodeIdentifier, const String&, mode_t, int& error)
|
||||
RefPtr<Inode> ProcFS::create_directory(InodeIdentifier, const String&, mode_t, int& error)
|
||||
{
|
||||
error = -EROFS;
|
||||
return nullptr;
|
||||
|
@ -764,7 +764,7 @@ InodeIdentifier ProcFS::root_inode() const
|
|||
return { fsid(), FI_Root };
|
||||
}
|
||||
|
||||
RetainPtr<Inode> ProcFS::get_inode(InodeIdentifier inode_id) const
|
||||
RefPtr<Inode> ProcFS::get_inode(InodeIdentifier inode_id) const
|
||||
{
|
||||
#ifdef PROCFS_DEBUG
|
||||
dbgprintf("ProcFS::get_inode(%u)\n", inode_id.index());
|
||||
|
|
|
@ -16,16 +16,16 @@ public:
|
|||
[[gnu::pure]] static ProcFS& the();
|
||||
|
||||
virtual ~ProcFS() override;
|
||||
static Retained<ProcFS> create();
|
||||
static NonnullRefPtr<ProcFS> create();
|
||||
|
||||
virtual bool initialize() override;
|
||||
virtual const char* class_name() const override;
|
||||
|
||||
virtual InodeIdentifier root_inode() const override;
|
||||
virtual RetainPtr<Inode> get_inode(InodeIdentifier) const override;
|
||||
virtual RefPtr<Inode> get_inode(InodeIdentifier) const override;
|
||||
|
||||
virtual RetainPtr<Inode> create_inode(InodeIdentifier parent_id, const String& name, mode_t, off_t size, dev_t, int& error) override;
|
||||
virtual RetainPtr<Inode> create_directory(InodeIdentifier parent_id, const String& name, mode_t, int& error) override;
|
||||
virtual RefPtr<Inode> create_inode(InodeIdentifier parent_id, const String& name, mode_t, off_t size, dev_t, int& error) override;
|
||||
virtual RefPtr<Inode> create_directory(InodeIdentifier parent_id, const String& name, mode_t, int& error) override;
|
||||
|
||||
void add_sys_file(String&&, Function<ByteBuffer(ProcFSInode&)>&& read_callback, Function<ssize_t(ProcFSInode&, const ByteBuffer&)>&& write_callback);
|
||||
void add_sys_bool(String&&, Lockable<bool>&, Function<void()>&& notify_callback = nullptr);
|
||||
|
@ -36,7 +36,7 @@ private:
|
|||
|
||||
struct ProcFSDirectoryEntry {
|
||||
ProcFSDirectoryEntry() {}
|
||||
ProcFSDirectoryEntry(const char* a_name, unsigned a_proc_file_type, Function<ByteBuffer(InodeIdentifier)>&& a_read_callback = nullptr, Function<ssize_t(InodeIdentifier, const ByteBuffer&)>&& a_write_callback = nullptr, RetainPtr<ProcFSInode>&& a_inode = nullptr)
|
||||
ProcFSDirectoryEntry(const char* a_name, unsigned a_proc_file_type, Function<ByteBuffer(InodeIdentifier)>&& a_read_callback = nullptr, Function<ssize_t(InodeIdentifier, const ByteBuffer&)>&& a_write_callback = nullptr, RefPtr<ProcFSInode>&& a_inode = nullptr)
|
||||
: name(a_name)
|
||||
, proc_file_type(a_proc_file_type)
|
||||
, read_callback(move(a_read_callback))
|
||||
|
@ -49,7 +49,7 @@ private:
|
|||
unsigned proc_file_type { 0 };
|
||||
Function<ByteBuffer(InodeIdentifier)> read_callback;
|
||||
Function<ssize_t(InodeIdentifier, const ByteBuffer&)> write_callback;
|
||||
RetainPtr<ProcFSInode> inode;
|
||||
RefPtr<ProcFSInode> inode;
|
||||
InodeIdentifier identifier(unsigned fsid) const;
|
||||
};
|
||||
|
||||
|
@ -60,7 +60,7 @@ private:
|
|||
|
||||
mutable Lock m_inodes_lock;
|
||||
mutable HashMap<unsigned, ProcFSInode*> m_inodes;
|
||||
RetainPtr<ProcFSInode> m_root_inode;
|
||||
RefPtr<ProcFSInode> m_root_inode;
|
||||
Lockable<bool> m_kmalloc_stack_helper;
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
//#define SYNTHFS_DEBUG
|
||||
|
||||
Retained<SynthFS> SynthFS::create()
|
||||
NonnullRefPtr<SynthFS> SynthFS::create()
|
||||
{
|
||||
return adopt(*new SynthFS);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ bool SynthFS::initialize()
|
|||
return true;
|
||||
}
|
||||
|
||||
Retained<SynthFSInode> SynthFS::create_directory(String&& name)
|
||||
NonnullRefPtr<SynthFSInode> SynthFS::create_directory(String&& name)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
|
||||
file->m_name = move(name);
|
||||
|
@ -45,7 +45,7 @@ Retained<SynthFSInode> SynthFS::create_directory(String&& name)
|
|||
return file;
|
||||
}
|
||||
|
||||
Retained<SynthFSInode> SynthFS::create_text_file(String&& name, ByteBuffer&& contents, mode_t mode)
|
||||
NonnullRefPtr<SynthFSInode> SynthFS::create_text_file(String&& name, ByteBuffer&& contents, mode_t mode)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
|
||||
file->m_data = contents;
|
||||
|
@ -58,7 +58,7 @@ Retained<SynthFSInode> SynthFS::create_text_file(String&& name, ByteBuffer&& con
|
|||
return file;
|
||||
}
|
||||
|
||||
Retained<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&& generator, mode_t mode)
|
||||
NonnullRefPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&& generator, mode_t mode)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
|
||||
file->m_generator = move(generator);
|
||||
|
@ -71,7 +71,7 @@ Retained<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<By
|
|||
return file;
|
||||
}
|
||||
|
||||
Retained<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&& read_callback, Function<ssize_t(SynthFSInode&, const ByteBuffer&)>&& write_callback, mode_t mode)
|
||||
NonnullRefPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&& read_callback, Function<ssize_t(SynthFSInode&, const ByteBuffer&)>&& write_callback, mode_t mode)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
|
||||
file->m_generator = move(read_callback);
|
||||
|
@ -85,7 +85,7 @@ Retained<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<By
|
|||
return file;
|
||||
}
|
||||
|
||||
InodeIdentifier SynthFS::add_file(RetainPtr<SynthFSInode>&& file, InodeIndex parent)
|
||||
InodeIdentifier SynthFS::add_file(RefPtr<SynthFSInode>&& file, InodeIndex parent)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(file);
|
||||
|
@ -138,7 +138,7 @@ InodeIdentifier SynthFS::root_inode() const
|
|||
return { fsid(), 1 };
|
||||
}
|
||||
|
||||
RetainPtr<Inode> SynthFS::create_inode(InodeIdentifier parentInode, const String& name, mode_t mode, off_t size, dev_t, int& error)
|
||||
RefPtr<Inode> SynthFS::create_inode(InodeIdentifier parentInode, const String& name, mode_t mode, off_t size, dev_t, int& error)
|
||||
{
|
||||
(void)parentInode;
|
||||
(void)name;
|
||||
|
@ -149,7 +149,7 @@ RetainPtr<Inode> SynthFS::create_inode(InodeIdentifier parentInode, const String
|
|||
return {};
|
||||
}
|
||||
|
||||
RetainPtr<Inode> SynthFS::create_directory(InodeIdentifier, const String&, mode_t, int& error)
|
||||
RefPtr<Inode> SynthFS::create_directory(InodeIdentifier, const String&, mode_t, int& error)
|
||||
{
|
||||
error = -EROFS;
|
||||
return nullptr;
|
||||
|
@ -161,7 +161,7 @@ auto SynthFS::generate_inode_index() -> InodeIndex
|
|||
return m_next_inode_index++;
|
||||
}
|
||||
|
||||
RetainPtr<Inode> SynthFS::get_inode(InodeIdentifier inode) const
|
||||
RefPtr<Inode> SynthFS::get_inode(InodeIdentifier inode) const
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
auto it = m_inodes.find(inode.index());
|
||||
|
|
|
@ -10,14 +10,14 @@ class SynthFSInode;
|
|||
class SynthFS : public FS {
|
||||
public:
|
||||
virtual ~SynthFS() override;
|
||||
static Retained<SynthFS> create();
|
||||
static NonnullRefPtr<SynthFS> create();
|
||||
|
||||
virtual bool initialize() override;
|
||||
virtual const char* class_name() const override;
|
||||
virtual InodeIdentifier root_inode() const override;
|
||||
virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) override;
|
||||
virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override;
|
||||
virtual RetainPtr<Inode> get_inode(InodeIdentifier) const override;
|
||||
virtual RefPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) override;
|
||||
virtual RefPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override;
|
||||
virtual RefPtr<Inode> get_inode(InodeIdentifier) const override;
|
||||
|
||||
protected:
|
||||
typedef unsigned InodeIndex;
|
||||
|
@ -27,17 +27,17 @@ protected:
|
|||
|
||||
SynthFS();
|
||||
|
||||
Retained<SynthFSInode> create_directory(String&& name);
|
||||
Retained<SynthFSInode> create_text_file(String&& name, ByteBuffer&&, mode_t = 0010644);
|
||||
Retained<SynthFSInode> create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&&, mode_t = 0100644);
|
||||
Retained<SynthFSInode> create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&&, Function<ssize_t(SynthFSInode&, const ByteBuffer&)>&&, mode_t = 0100644);
|
||||
NonnullRefPtr<SynthFSInode> create_directory(String&& name);
|
||||
NonnullRefPtr<SynthFSInode> create_text_file(String&& name, ByteBuffer&&, mode_t = 0010644);
|
||||
NonnullRefPtr<SynthFSInode> create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&&, mode_t = 0100644);
|
||||
NonnullRefPtr<SynthFSInode> create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&&, Function<ssize_t(SynthFSInode&, const ByteBuffer&)>&&, mode_t = 0100644);
|
||||
|
||||
InodeIdentifier add_file(RetainPtr<SynthFSInode>&&, InodeIndex parent = RootInodeIndex);
|
||||
InodeIdentifier add_file(RefPtr<SynthFSInode>&&, InodeIndex parent = RootInodeIndex);
|
||||
bool remove_file(InodeIndex);
|
||||
|
||||
private:
|
||||
InodeIndex m_next_inode_index { 2 };
|
||||
HashMap<InodeIndex, RetainPtr<SynthFSInode>> m_inodes;
|
||||
HashMap<InodeIndex, RefPtr<SynthFSInode>> m_inodes;
|
||||
};
|
||||
|
||||
struct SynthFSInodeCustomData {
|
||||
|
|
|
@ -36,7 +36,7 @@ InodeIdentifier VFS::root_inode_id() const
|
|||
return m_root_inode->identifier();
|
||||
}
|
||||
|
||||
bool VFS::mount(Retained<FS>&& file_system, StringView path)
|
||||
bool VFS::mount(NonnullRefPtr<FS>&& file_system, StringView path)
|
||||
{
|
||||
auto result = resolve_path(path, root_custody());
|
||||
if (result.is_error()) {
|
||||
|
@ -53,7 +53,7 @@ bool VFS::mount(Retained<FS>&& file_system, StringView path)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool VFS::mount_root(Retained<FS>&& file_system)
|
||||
bool VFS::mount_root(NonnullRefPtr<FS>&& file_system)
|
||||
{
|
||||
if (m_root_inode) {
|
||||
kprintf("VFS: mount_root can't mount another root\n");
|
||||
|
@ -149,9 +149,9 @@ KResult VFS::stat(StringView path, int options, Custody& base, struct stat& stat
|
|||
return custody_or_error.value()->inode().metadata().stat(statbuf);
|
||||
}
|
||||
|
||||
KResultOr<Retained<FileDescription>> VFS::open(StringView path, int options, mode_t mode, Custody& base)
|
||||
KResultOr<NonnullRefPtr<FileDescription>> VFS::open(StringView path, int options, mode_t mode, Custody& base)
|
||||
{
|
||||
RetainPtr<Custody> parent_custody;
|
||||
RefPtr<Custody> parent_custody;
|
||||
auto custody_or_error = resolve_path(path, base, &parent_custody, options);
|
||||
if (options & O_CREAT) {
|
||||
if (!parent_custody)
|
||||
|
@ -208,7 +208,7 @@ KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base)
|
|||
if (!is_regular_file(mode) && !is_block_device(mode) && !is_character_device(mode) && !is_fifo(mode) && !is_socket(mode))
|
||||
return KResult(-EINVAL);
|
||||
|
||||
RetainPtr<Custody> parent_custody;
|
||||
RefPtr<Custody> parent_custody;
|
||||
auto existing_file_or_error = resolve_path(path, base, &parent_custody);
|
||||
if (!existing_file_or_error.is_error())
|
||||
return KResult(-EEXIST);
|
||||
|
@ -230,7 +230,7 @@ KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base)
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
KResultOr<Retained<FileDescription>> VFS::create(StringView path, int options, mode_t mode, Custody& parent_custody)
|
||||
KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int options, mode_t mode, Custody& parent_custody)
|
||||
{
|
||||
(void)options;
|
||||
|
||||
|
@ -255,7 +255,7 @@ KResultOr<Retained<FileDescription>> VFS::create(StringView path, int options, m
|
|||
|
||||
KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
|
||||
{
|
||||
RetainPtr<Custody> parent_custody;
|
||||
RefPtr<Custody> parent_custody;
|
||||
auto result = resolve_path(path, base, &parent_custody);
|
||||
if (!result.is_error())
|
||||
return KResult(-EEXIST);
|
||||
|
@ -300,7 +300,7 @@ KResult VFS::access(StringView path, int mode, Custody& base)
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
KResultOr<Retained<Custody>> VFS::open_directory(StringView path, Custody& base)
|
||||
KResultOr<NonnullRefPtr<Custody>> VFS::open_directory(StringView path, Custody& base)
|
||||
{
|
||||
auto inode_or_error = resolve_path(path, base);
|
||||
if (inode_or_error.is_error())
|
||||
|
@ -339,14 +339,14 @@ KResult VFS::chmod(StringView path, mode_t mode, Custody& base)
|
|||
|
||||
KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)
|
||||
{
|
||||
RetainPtr<Custody> old_parent_custody;
|
||||
RefPtr<Custody> old_parent_custody;
|
||||
auto old_custody_or_error = resolve_path(old_path, base, &old_parent_custody);
|
||||
if (old_custody_or_error.is_error())
|
||||
return old_custody_or_error.error();
|
||||
auto& old_custody = *old_custody_or_error.value();
|
||||
auto& old_inode = old_custody.inode();
|
||||
|
||||
RetainPtr<Custody> new_parent_custody;
|
||||
RefPtr<Custody> new_parent_custody;
|
||||
auto new_custody_or_error = resolve_path(new_path, base, &new_parent_custody);
|
||||
if (new_custody_or_error.is_error()) {
|
||||
if (new_custody_or_error.error() != -ENOENT)
|
||||
|
@ -445,7 +445,7 @@ KResult VFS::link(StringView old_path, StringView new_path, Custody& base)
|
|||
auto& old_custody = *old_custody_or_error.value();
|
||||
auto& old_inode = old_custody.inode();
|
||||
|
||||
RetainPtr<Custody> parent_custody;
|
||||
RefPtr<Custody> parent_custody;
|
||||
auto new_custody_or_error = resolve_path(new_path, base, &parent_custody);
|
||||
if (!new_custody_or_error.is_error())
|
||||
return KResult(-EEXIST);
|
||||
|
@ -469,7 +469,7 @@ KResult VFS::link(StringView old_path, StringView new_path, Custody& base)
|
|||
|
||||
KResult VFS::unlink(StringView path, Custody& base)
|
||||
{
|
||||
RetainPtr<Custody> parent_custody;
|
||||
RefPtr<Custody> parent_custody;
|
||||
auto custody_or_error = resolve_path(path, base, &parent_custody);
|
||||
if (custody_or_error.is_error())
|
||||
return custody_or_error.error();
|
||||
|
@ -498,7 +498,7 @@ KResult VFS::unlink(StringView path, Custody& base)
|
|||
|
||||
KResult VFS::symlink(StringView target, StringView linkpath, Custody& base)
|
||||
{
|
||||
RetainPtr<Custody> parent_custody;
|
||||
RefPtr<Custody> parent_custody;
|
||||
auto existing_custody_or_error = resolve_path(linkpath, base, &parent_custody);
|
||||
if (!existing_custody_or_error.is_error())
|
||||
return KResult(-EEXIST);
|
||||
|
@ -524,7 +524,7 @@ KResult VFS::symlink(StringView target, StringView linkpath, Custody& base)
|
|||
|
||||
KResult VFS::rmdir(StringView path, Custody& base)
|
||||
{
|
||||
RetainPtr<Custody> parent_custody;
|
||||
RefPtr<Custody> parent_custody;
|
||||
auto custody_or_error = resolve_path(path, base, &parent_custody);
|
||||
if (custody_or_error.is_error())
|
||||
return KResult(custody_or_error.error());
|
||||
|
@ -559,14 +559,14 @@ KResult VFS::rmdir(StringView path, Custody& base)
|
|||
return parent_inode.remove_child(FileSystemPath(path).basename());
|
||||
}
|
||||
|
||||
RetainPtr<Inode> VFS::get_inode(InodeIdentifier inode_id)
|
||||
RefPtr<Inode> VFS::get_inode(InodeIdentifier inode_id)
|
||||
{
|
||||
if (!inode_id.is_valid())
|
||||
return nullptr;
|
||||
return inode_id.fs()->get_inode(inode_id);
|
||||
}
|
||||
|
||||
VFS::Mount::Mount(RetainPtr<Custody>&& host_custody, Retained<FS>&& guest_fs)
|
||||
VFS::Mount::Mount(RefPtr<Custody>&& host_custody, NonnullRefPtr<FS>&& guest_fs)
|
||||
: m_guest(guest_fs->root_inode())
|
||||
, m_guest_fs(move(guest_fs))
|
||||
, m_host_custody(move(host_custody))
|
||||
|
@ -624,7 +624,7 @@ Custody& VFS::root_custody()
|
|||
return *m_root_custody;
|
||||
}
|
||||
|
||||
KResultOr<Retained<Custody>> VFS::resolve_path(StringView path, Custody& base, RetainPtr<Custody>* parent_custody, int options)
|
||||
KResultOr<NonnullRefPtr<Custody>> VFS::resolve_path(StringView path, Custody& base, RefPtr<Custody>* parent_custody, int options)
|
||||
{
|
||||
if (path.is_empty())
|
||||
return KResult(-EINVAL);
|
||||
|
@ -632,7 +632,7 @@ KResultOr<Retained<Custody>> VFS::resolve_path(StringView path, Custody& base, R
|
|||
auto parts = path.split_view('/');
|
||||
InodeIdentifier crumb_id;
|
||||
|
||||
Vector<Retained<Custody>, 32> custody_chain;
|
||||
Vector<NonnullRefPtr<Custody>, 32> custody_chain;
|
||||
|
||||
if (path[0] == '/') {
|
||||
custody_chain.append(root_custody());
|
||||
|
|
|
@ -35,7 +35,7 @@ class VFS {
|
|||
public:
|
||||
class Mount {
|
||||
public:
|
||||
Mount(RetainPtr<Custody>&&, Retained<FS>&&);
|
||||
Mount(RefPtr<Custody>&&, NonnullRefPtr<FS>&&);
|
||||
|
||||
InodeIdentifier host() const;
|
||||
InodeIdentifier guest() const { return m_guest; }
|
||||
|
@ -47,8 +47,8 @@ public:
|
|||
private:
|
||||
InodeIdentifier m_host;
|
||||
InodeIdentifier m_guest;
|
||||
Retained<FS> m_guest_fs;
|
||||
RetainPtr<Custody> m_host_custody;
|
||||
NonnullRefPtr<FS> m_guest_fs;
|
||||
RefPtr<Custody> m_host_custody;
|
||||
};
|
||||
|
||||
[[gnu::pure]] static VFS& the();
|
||||
|
@ -56,12 +56,12 @@ public:
|
|||
VFS();
|
||||
~VFS();
|
||||
|
||||
bool mount_root(Retained<FS>&&);
|
||||
bool mount(Retained<FS>&&, StringView path);
|
||||
bool mount_root(NonnullRefPtr<FS>&&);
|
||||
bool mount(NonnullRefPtr<FS>&&, StringView path);
|
||||
|
||||
KResultOr<Retained<FileDescription>> open(RetainPtr<Device>&&, int options);
|
||||
KResultOr<Retained<FileDescription>> open(StringView path, int options, mode_t mode, Custody& base);
|
||||
KResultOr<Retained<FileDescription>> create(StringView path, int options, mode_t mode, Custody& parent_custody);
|
||||
KResultOr<NonnullRefPtr<FileDescription>> open(RefPtr<Device>&&, int options);
|
||||
KResultOr<NonnullRefPtr<FileDescription>> open(StringView path, int options, mode_t mode, Custody& base);
|
||||
KResultOr<NonnullRefPtr<FileDescription>> create(StringView path, int options, mode_t mode, Custody& parent_custody);
|
||||
KResult mkdir(StringView path, mode_t mode, Custody& base);
|
||||
KResult link(StringView old_path, StringView new_path, Custody& base);
|
||||
KResult unlink(StringView path, Custody& base);
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
KResult utime(StringView path, Custody& base, time_t atime, time_t mtime);
|
||||
KResult rename(StringView oldpath, StringView newpath, Custody& base);
|
||||
KResult mknod(StringView path, mode_t, dev_t, Custody& base);
|
||||
KResultOr<Retained<Custody>> open_directory(StringView path, Custody& base);
|
||||
KResultOr<NonnullRefPtr<Custody>> open_directory(StringView path, Custody& base);
|
||||
|
||||
void register_device(Badge<Device>, Device&);
|
||||
void unregister_device(Badge<Device>, Device&);
|
||||
|
@ -91,12 +91,12 @@ public:
|
|||
Device* get_device(unsigned major, unsigned minor);
|
||||
|
||||
Custody& root_custody();
|
||||
KResultOr<Retained<Custody>> resolve_path(StringView path, Custody& base, RetainPtr<Custody>* parent = nullptr, int options = 0);
|
||||
KResultOr<NonnullRefPtr<Custody>> resolve_path(StringView path, Custody& base, RefPtr<Custody>* parent = nullptr, int options = 0);
|
||||
|
||||
private:
|
||||
friend class FileDescription;
|
||||
|
||||
RetainPtr<Inode> get_inode(InodeIdentifier);
|
||||
RefPtr<Inode> get_inode(InodeIdentifier);
|
||||
|
||||
bool is_vfs_root(InodeIdentifier) const;
|
||||
|
||||
|
@ -105,9 +105,9 @@ private:
|
|||
Mount* find_mount_for_host(InodeIdentifier);
|
||||
Mount* find_mount_for_guest(InodeIdentifier);
|
||||
|
||||
RetainPtr<Inode> m_root_inode;
|
||||
RefPtr<Inode> m_root_inode;
|
||||
Vector<OwnPtr<Mount>> m_mounts;
|
||||
HashMap<dword, Device*> m_devices;
|
||||
|
||||
RetainPtr<Custody> m_root_custody;
|
||||
RefPtr<Custody> m_root_custody;
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ Lockable<HashTable<IPv4Socket*>>& IPv4Socket::all_sockets()
|
|||
return *s_table;
|
||||
}
|
||||
|
||||
Retained<IPv4Socket> IPv4Socket::create(int type, int protocol)
|
||||
NonnullRefPtr<IPv4Socket> IPv4Socket::create(int type, int protocol)
|
||||
{
|
||||
if (type == SOCK_STREAM)
|
||||
return TCPSocket::create(protocol);
|
||||
|
|
|
@ -15,7 +15,7 @@ class TCPSocket;
|
|||
|
||||
class IPv4Socket : public Socket {
|
||||
public:
|
||||
static Retained<IPv4Socket> create(int type, int protocol);
|
||||
static NonnullRefPtr<IPv4Socket> create(int type, int protocol);
|
||||
virtual ~IPv4Socket() override;
|
||||
|
||||
static Lockable<HashTable<IPv4Socket*>>& all_sockets();
|
||||
|
@ -88,7 +88,7 @@ class IPv4SocketHandle : public SocketHandle {
|
|||
public:
|
||||
IPv4SocketHandle() {}
|
||||
|
||||
IPv4SocketHandle(RetainPtr<IPv4Socket>&& socket)
|
||||
IPv4SocketHandle(RefPtr<IPv4Socket>&& socket)
|
||||
: SocketHandle(move(socket))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
//#define DEBUG_LOCAL_SOCKET
|
||||
|
||||
Retained<LocalSocket> LocalSocket::create(int type)
|
||||
NonnullRefPtr<LocalSocket> LocalSocket::create(int type)
|
||||
{
|
||||
return adopt(*new LocalSocket(type));
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ class FileDescription;
|
|||
|
||||
class LocalSocket final : public Socket {
|
||||
public:
|
||||
static Retained<LocalSocket> create(int type);
|
||||
static NonnullRefPtr<LocalSocket> create(int type);
|
||||
virtual ~LocalSocket() override;
|
||||
|
||||
virtual KResult bind(const sockaddr*, socklen_t) override;
|
||||
|
@ -28,7 +28,7 @@ private:
|
|||
virtual bool is_local() const override { return true; }
|
||||
bool has_attached_peer(const FileDescription&) const;
|
||||
|
||||
RetainPtr<FileDescription> m_file;
|
||||
RefPtr<FileDescription> m_file;
|
||||
|
||||
bool m_bound { false };
|
||||
int m_accepted_fds_open { 0 };
|
||||
|
|
|
@ -209,7 +209,7 @@ void handle_icmp(const EthernetFrameHeader& eth, int frame_size)
|
|||
|
||||
{
|
||||
LOCKER(IPv4Socket::all_sockets().lock());
|
||||
for (RetainPtr<IPv4Socket> socket : IPv4Socket::all_sockets().resource()) {
|
||||
for (RefPtr<IPv4Socket> socket : IPv4Socket::all_sockets().resource()) {
|
||||
LOCKER(socket->lock());
|
||||
if (socket->protocol() != (unsigned)IPv4Protocol::ICMP)
|
||||
continue;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <Kernel/UnixTypes.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
|
||||
KResultOr<Retained<Socket>> Socket::create(int domain, int type, int protocol)
|
||||
KResultOr<NonnullRefPtr<Socket>> Socket::create(int domain, int type, int protocol)
|
||||
{
|
||||
(void)protocol;
|
||||
switch (domain) {
|
||||
|
@ -41,7 +41,7 @@ KResult Socket::listen(int backlog)
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
RetainPtr<Socket> Socket::accept()
|
||||
RefPtr<Socket> Socket::accept()
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
if (m_pending.is_empty())
|
||||
|
|
|
@ -25,7 +25,7 @@ class FileDescription;
|
|||
|
||||
class Socket : public File {
|
||||
public:
|
||||
static KResultOr<Retained<Socket>> create(int domain, int type, int protocol);
|
||||
static KResultOr<NonnullRefPtr<Socket>> create(int domain, int type, int protocol);
|
||||
virtual ~Socket() override;
|
||||
|
||||
int domain() const { return m_domain; }
|
||||
|
@ -33,7 +33,7 @@ public:
|
|||
int protocol() const { return m_protocol; }
|
||||
|
||||
bool can_accept() const { return !m_pending.is_empty(); }
|
||||
RetainPtr<Socket> accept();
|
||||
RefPtr<Socket> accept();
|
||||
bool is_connected() const { return m_connected; }
|
||||
KResult listen(int backlog);
|
||||
|
||||
|
@ -89,14 +89,14 @@ private:
|
|||
timeval m_receive_deadline { 0, 0 };
|
||||
timeval m_send_deadline { 0, 0 };
|
||||
|
||||
Vector<RetainPtr<Socket>> m_pending;
|
||||
Vector<RefPtr<Socket>> m_pending;
|
||||
};
|
||||
|
||||
class SocketHandle {
|
||||
public:
|
||||
SocketHandle() {}
|
||||
|
||||
SocketHandle(RetainPtr<Socket>&& socket)
|
||||
SocketHandle(RefPtr<Socket>&& socket)
|
||||
: m_socket(move(socket))
|
||||
{
|
||||
if (m_socket)
|
||||
|
@ -126,5 +126,5 @@ public:
|
|||
const Socket& socket() const { return *m_socket; }
|
||||
|
||||
private:
|
||||
RetainPtr<Socket> m_socket;
|
||||
RefPtr<Socket> m_socket;
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ Lockable<HashMap<word, TCPSocket*>>& TCPSocket::sockets_by_port()
|
|||
|
||||
TCPSocketHandle TCPSocket::from_port(word port)
|
||||
{
|
||||
RetainPtr<TCPSocket> socket;
|
||||
RefPtr<TCPSocket> socket;
|
||||
{
|
||||
LOCKER(sockets_by_port().lock());
|
||||
auto it = sockets_by_port().resource().find(port);
|
||||
|
@ -38,7 +38,7 @@ TCPSocket::~TCPSocket()
|
|||
sockets_by_port().resource().remove(local_port());
|
||||
}
|
||||
|
||||
Retained<TCPSocket> TCPSocket::create(int protocol)
|
||||
NonnullRefPtr<TCPSocket> TCPSocket::create(int protocol)
|
||||
{
|
||||
return adopt(*new TCPSocket(protocol));
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
class TCPSocket final : public IPv4Socket {
|
||||
public:
|
||||
static Retained<TCPSocket> create(int protocol);
|
||||
static NonnullRefPtr<TCPSocket> create(int protocol);
|
||||
virtual ~TCPSocket() override;
|
||||
|
||||
enum class State {
|
||||
|
@ -49,7 +49,7 @@ class TCPSocketHandle : public SocketHandle {
|
|||
public:
|
||||
TCPSocketHandle() {}
|
||||
|
||||
TCPSocketHandle(RetainPtr<TCPSocket>&& socket)
|
||||
TCPSocketHandle(RefPtr<TCPSocket>&& socket)
|
||||
: SocketHandle(move(socket))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ Lockable<HashMap<word, UDPSocket*>>& UDPSocket::sockets_by_port()
|
|||
|
||||
UDPSocketHandle UDPSocket::from_port(word port)
|
||||
{
|
||||
RetainPtr<UDPSocket> socket;
|
||||
RefPtr<UDPSocket> socket;
|
||||
{
|
||||
LOCKER(sockets_by_port().lock());
|
||||
auto it = sockets_by_port().resource().find(port);
|
||||
|
@ -38,7 +38,7 @@ UDPSocket::~UDPSocket()
|
|||
sockets_by_port().resource().remove(local_port());
|
||||
}
|
||||
|
||||
Retained<UDPSocket> UDPSocket::create(int protocol)
|
||||
NonnullRefPtr<UDPSocket> UDPSocket::create(int protocol)
|
||||
{
|
||||
return adopt(*new UDPSocket(protocol));
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ class UDPSocketHandle;
|
|||
|
||||
class UDPSocket final : public IPv4Socket {
|
||||
public:
|
||||
static Retained<UDPSocket> create(int protocol);
|
||||
static NonnullRefPtr<UDPSocket> create(int protocol);
|
||||
virtual ~UDPSocket() override;
|
||||
|
||||
static UDPSocketHandle from_port(word);
|
||||
|
@ -27,7 +27,7 @@ class UDPSocketHandle : public SocketHandle {
|
|||
public:
|
||||
UDPSocketHandle() {}
|
||||
|
||||
UDPSocketHandle(RetainPtr<UDPSocket>&& socket)
|
||||
UDPSocketHandle(RefPtr<UDPSocket>&& socket)
|
||||
: SocketHandle(move(socket))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ Region* Process::allocate_region(VirtualAddress vaddr, size_t size, const String
|
|||
return m_regions.last().ptr();
|
||||
}
|
||||
|
||||
Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size, RetainPtr<Inode>&& inode, const String& name, int prot)
|
||||
Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size, RefPtr<Inode>&& inode, const String& name, int prot)
|
||||
{
|
||||
auto range = allocate_range(vaddr, size);
|
||||
if (!range.is_valid())
|
||||
|
@ -115,7 +115,7 @@ Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size,
|
|||
return m_regions.last().ptr();
|
||||
}
|
||||
|
||||
Region* Process::allocate_region_with_vmo(VirtualAddress vaddr, size_t size, Retained<VMObject>&& vmo, size_t offset_in_vmo, const String& name, int prot)
|
||||
Region* Process::allocate_region_with_vmo(VirtualAddress vaddr, size_t size, NonnullRefPtr<VMObject>&& vmo, size_t offset_in_vmo, const String& name, int prot)
|
||||
{
|
||||
auto range = allocate_range(vaddr, size);
|
||||
if (!range.is_valid())
|
||||
|
@ -334,7 +334,7 @@ int Process::do_exec(String path, Vector<String> arguments, Vector<String> envir
|
|||
|
||||
auto vmo = VMObject::create_file_backed(description->inode());
|
||||
vmo->set_name(description->absolute_path());
|
||||
RetainPtr<Region> region = allocate_region_with_vmo(VirtualAddress(), metadata.size, vmo.copy_ref(), 0, vmo->name(), PROT_READ);
|
||||
RefPtr<Region> region = allocate_region_with_vmo(VirtualAddress(), metadata.size, vmo.copy_ref(), 0, vmo->name(), PROT_READ);
|
||||
ASSERT(region);
|
||||
|
||||
if (this != ¤t->process()) {
|
||||
|
@ -516,7 +516,7 @@ Process* Process::create_user_process(const String& path, uid_t uid, gid_t gid,
|
|||
if (arguments.is_empty()) {
|
||||
arguments.append(parts.last());
|
||||
}
|
||||
RetainPtr<Custody> cwd;
|
||||
RefPtr<Custody> cwd;
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
if (auto* parent = Process::from_pid(parent_pid))
|
||||
|
@ -562,7 +562,7 @@ Process* Process::create_kernel_process(String&& name, void (*e)())
|
|||
return process;
|
||||
}
|
||||
|
||||
Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring, RetainPtr<Custody>&& cwd, RetainPtr<Custody>&& executable, TTY* tty, Process* fork_parent)
|
||||
Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring, RefPtr<Custody>&& cwd, RefPtr<Custody>&& executable, TTY* tty, Process* fork_parent)
|
||||
: m_name(move(name))
|
||||
, m_pid(next_pid++) // FIXME: RACE: This variable looks racy!
|
||||
, m_uid(uid)
|
||||
|
@ -2445,7 +2445,7 @@ struct SharedBuffer {
|
|||
Region* m_pid2_region { nullptr };
|
||||
bool m_pid1_writable { false };
|
||||
bool m_pid2_writable { false };
|
||||
Retained<VMObject> m_vmo;
|
||||
NonnullRefPtr<VMObject> m_vmo;
|
||||
};
|
||||
|
||||
static int s_next_shared_buffer_id;
|
||||
|
@ -2734,7 +2734,7 @@ void Process::FileDescriptionAndFlags::clear()
|
|||
flags = 0;
|
||||
}
|
||||
|
||||
void Process::FileDescriptionAndFlags::set(Retained<FileDescription>&& d, dword f)
|
||||
void Process::FileDescriptionAndFlags::set(NonnullRefPtr<FileDescription>&& d, dword f)
|
||||
{
|
||||
description = move(d);
|
||||
flags = f;
|
||||
|
|
|
@ -211,7 +211,7 @@ public:
|
|||
void set_tty(TTY* tty) { m_tty = tty; }
|
||||
|
||||
size_t region_count() const { return m_regions.size(); }
|
||||
const Vector<Retained<Region>>& regions() const { return m_regions; }
|
||||
const Vector<NonnullRefPtr<Region>>& regions() const { return m_regions; }
|
||||
void dump_regions();
|
||||
|
||||
ProcessTracer* tracer() { return m_tracer.ptr(); }
|
||||
|
@ -248,8 +248,8 @@ public:
|
|||
|
||||
bool is_superuser() const { return m_euid == 0; }
|
||||
|
||||
Region* allocate_region_with_vmo(VirtualAddress, size_t, Retained<VMObject>&&, size_t offset_in_vmo, const String& name, int prot);
|
||||
Region* allocate_file_backed_region(VirtualAddress, size_t, RetainPtr<Inode>&&, const String& name, int prot);
|
||||
Region* allocate_region_with_vmo(VirtualAddress, size_t, NonnullRefPtr<VMObject>&&, size_t offset_in_vmo, const String& name, int prot);
|
||||
Region* allocate_file_backed_region(VirtualAddress, size_t, RefPtr<Inode>&&, const String& name, int prot);
|
||||
Region* allocate_region(VirtualAddress, size_t, const String& name, int prot = PROT_READ | PROT_WRITE, bool commit = true);
|
||||
bool deallocate_region(Region& region);
|
||||
|
||||
|
@ -273,7 +273,7 @@ private:
|
|||
friend class Scheduler;
|
||||
friend class Region;
|
||||
|
||||
Process(String&& name, uid_t, gid_t, pid_t ppid, RingLevel, RetainPtr<Custody>&& cwd = nullptr, RetainPtr<Custody>&& executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr);
|
||||
Process(String&& name, uid_t, gid_t, pid_t ppid, RingLevel, RefPtr<Custody>&& cwd = nullptr, RefPtr<Custody>&& executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr);
|
||||
|
||||
Range allocate_range(VirtualAddress, size_t);
|
||||
|
||||
|
@ -287,7 +287,7 @@ private:
|
|||
|
||||
Thread* m_main_thread { nullptr };
|
||||
|
||||
RetainPtr<PageDirectory> m_page_directory;
|
||||
RefPtr<PageDirectory> m_page_directory;
|
||||
|
||||
Process* m_prev { nullptr };
|
||||
Process* m_next { nullptr };
|
||||
|
@ -307,8 +307,8 @@ private:
|
|||
struct FileDescriptionAndFlags {
|
||||
operator bool() const { return !!description; }
|
||||
void clear();
|
||||
void set(Retained<FileDescription>&& d, dword f = 0);
|
||||
RetainPtr<FileDescription> description;
|
||||
void set(NonnullRefPtr<FileDescription>&& d, dword f = 0);
|
||||
RefPtr<FileDescription> description;
|
||||
dword flags { 0 };
|
||||
};
|
||||
Vector<FileDescriptionAndFlags> m_fds;
|
||||
|
@ -319,14 +319,14 @@ private:
|
|||
byte m_termination_status { 0 };
|
||||
byte m_termination_signal { 0 };
|
||||
|
||||
RetainPtr<Custody> m_executable;
|
||||
RetainPtr<Custody> m_cwd;
|
||||
RefPtr<Custody> m_executable;
|
||||
RefPtr<Custody> m_cwd;
|
||||
|
||||
TTY* m_tty { nullptr };
|
||||
|
||||
Region* region_from_range(VirtualAddress, size_t);
|
||||
|
||||
Vector<Retained<Region>> m_regions;
|
||||
Vector<NonnullRefPtr<Region>> m_regions;
|
||||
|
||||
VirtualAddress m_return_to_ring3_from_signal_trampoline;
|
||||
VirtualAddress m_return_to_ring0_from_signal_trampoline;
|
||||
|
@ -345,7 +345,7 @@ private:
|
|||
|
||||
unsigned m_syscall_count { 0 };
|
||||
|
||||
RetainPtr<ProcessTracer> m_tracer;
|
||||
RefPtr<ProcessTracer> m_tracer;
|
||||
OwnPtr<ELFLoader> m_elf_loader;
|
||||
|
||||
Lock m_big_lock { "Process" };
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
class ProcessTracer : public File {
|
||||
public:
|
||||
static Retained<ProcessTracer> create(pid_t pid) { return adopt(*new ProcessTracer(pid)); }
|
||||
static NonnullRefPtr<ProcessTracer> create(pid_t pid) { return adopt(*new ProcessTracer(pid)); }
|
||||
virtual ~ProcessTracer() override;
|
||||
|
||||
bool is_dead() const { return m_dead; }
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
#include <Kernel/SharedMemory.h>
|
||||
#include <Kernel/VM/VMObject.h>
|
||||
|
||||
Lockable<HashMap<String, RetainPtr<SharedMemory>>>& shared_memories()
|
||||
Lockable<HashMap<String, RefPtr<SharedMemory>>>& shared_memories()
|
||||
{
|
||||
static Lockable<HashMap<String, RetainPtr<SharedMemory>>>* map;
|
||||
static Lockable<HashMap<String, RefPtr<SharedMemory>>>* map;
|
||||
if (!map)
|
||||
map = new Lockable<HashMap<String, RetainPtr<SharedMemory>>>;
|
||||
map = new Lockable<HashMap<String, RefPtr<SharedMemory>>>;
|
||||
return *map;
|
||||
}
|
||||
|
||||
KResultOr<Retained<SharedMemory>> SharedMemory::open(const String& name, int flags, mode_t mode)
|
||||
KResultOr<NonnullRefPtr<SharedMemory>> SharedMemory::open(const String& name, int flags, mode_t mode)
|
||||
{
|
||||
UNUSED_PARAM(flags);
|
||||
LOCKER(shared_memories().lock());
|
||||
|
|
|
@ -11,7 +11,7 @@ class VMObject;
|
|||
|
||||
class SharedMemory : public File {
|
||||
public:
|
||||
static KResultOr<Retained<SharedMemory>> open(const String& name, int flags, mode_t);
|
||||
static KResultOr<NonnullRefPtr<SharedMemory>> open(const String& name, int flags, mode_t);
|
||||
static KResult unlink(const String& name);
|
||||
virtual ~SharedMemory() override;
|
||||
|
||||
|
@ -39,5 +39,5 @@ private:
|
|||
uid_t m_uid { 0 };
|
||||
gid_t m_gid { 0 };
|
||||
mode_t m_mode { 0 };
|
||||
RetainPtr<VMObject> m_vmo;
|
||||
RefPtr<VMObject> m_vmo;
|
||||
};
|
||||
|
|
|
@ -29,7 +29,7 @@ private:
|
|||
virtual int ioctl(FileDescription&, unsigned request, unsigned arg) override;
|
||||
virtual const char* class_name() const override { return "MasterPTY"; }
|
||||
|
||||
RetainPtr<SlavePTY> m_slave;
|
||||
RefPtr<SlavePTY> m_slave;
|
||||
unsigned m_index;
|
||||
bool m_closed { false };
|
||||
DoubleBuffer m_buffer;
|
||||
|
|
|
@ -28,7 +28,7 @@ PTYMultiplexer::~PTYMultiplexer()
|
|||
{
|
||||
}
|
||||
|
||||
KResultOr<Retained<FileDescription>> PTYMultiplexer::open(int options)
|
||||
KResultOr<NonnullRefPtr<FileDescription>> PTYMultiplexer::open(int options)
|
||||
{
|
||||
UNUSED_PARAM(options);
|
||||
LOCKER(m_lock);
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
static PTYMultiplexer& the();
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual KResultOr<Retained<FileDescription>> open(int options) override;
|
||||
virtual KResultOr<NonnullRefPtr<FileDescription>> open(int options) override;
|
||||
virtual ssize_t read(FileDescription&, byte*, ssize_t) override { return 0; }
|
||||
virtual ssize_t write(FileDescription&, const byte*, ssize_t) override { return 0; }
|
||||
virtual bool can_read(FileDescription&) const override { return true; }
|
||||
|
|
|
@ -30,7 +30,7 @@ private:
|
|||
friend class MasterPTY;
|
||||
SlavePTY(MasterPTY&, unsigned index);
|
||||
|
||||
RetainPtr<MasterPTY> m_master;
|
||||
RefPtr<MasterPTY> m_master;
|
||||
unsigned m_index;
|
||||
InodeIdentifier m_devpts_inode_id;
|
||||
String m_tty_name;
|
||||
|
|
|
@ -176,10 +176,10 @@ private:
|
|||
dword m_pending_signals { 0 };
|
||||
dword m_signal_mask { 0 };
|
||||
dword m_kernel_stack_base { 0 };
|
||||
RetainPtr<Region> m_kernel_stack_region;
|
||||
RetainPtr<Region> m_kernel_stack_for_signal_handler_region;
|
||||
RefPtr<Region> m_kernel_stack_region;
|
||||
RefPtr<Region> m_kernel_stack_for_signal_handler_region;
|
||||
pid_t m_waitee_pid { -1 };
|
||||
RetainPtr<FileDescription> m_blocked_description;
|
||||
RefPtr<FileDescription> m_blocked_description;
|
||||
timeval m_select_timeout;
|
||||
SignalActionData m_signal_action_data[32];
|
||||
Region* m_signal_stack_user_region { nullptr };
|
||||
|
|
|
@ -81,7 +81,7 @@ void MemoryManager::initialize_paging()
|
|||
#endif
|
||||
m_quickmap_addr = VirtualAddress((1 * MB) - PAGE_SIZE);
|
||||
|
||||
RetainPtr<PhysicalRegion> region = nullptr;
|
||||
RefPtr<PhysicalRegion> region = nullptr;
|
||||
bool region_is_super = false;
|
||||
|
||||
for (auto* mmap = (multiboot_memory_map_t*)multiboot_info_ptr->mmap_addr; (unsigned long)mmap < multiboot_info_ptr->mmap_addr + multiboot_info_ptr->mmap_length; mmap = (multiboot_memory_map_t*)((unsigned long)mmap + mmap->size + sizeof(mmap->size))) {
|
||||
|
@ -151,7 +151,7 @@ void MemoryManager::initialize_paging()
|
|||
#endif
|
||||
}
|
||||
|
||||
RetainPtr<PhysicalPage> MemoryManager::allocate_page_table(PageDirectory& page_directory, unsigned index)
|
||||
RefPtr<PhysicalPage> MemoryManager::allocate_page_table(PageDirectory& page_directory, unsigned index)
|
||||
{
|
||||
ASSERT(!page_directory.m_physical_pages.contains(index));
|
||||
auto physical_page = allocate_supervisor_physical_page();
|
||||
|
@ -444,7 +444,7 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
|
|||
return PageFaultResponse::ShouldCrash;
|
||||
}
|
||||
|
||||
RetainPtr<Region> MemoryManager::allocate_kernel_region(size_t size, String&& name)
|
||||
RefPtr<Region> MemoryManager::allocate_kernel_region(size_t size, String&& name)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
|
||||
|
@ -478,11 +478,11 @@ void MemoryManager::deallocate_user_physical_page(PhysicalPage&& page)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
RetainPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill should_zero_fill)
|
||||
RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill should_zero_fill)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
|
||||
RetainPtr<PhysicalPage> page = nullptr;
|
||||
RefPtr<PhysicalPage> page = nullptr;
|
||||
|
||||
for (auto& region : m_user_physical_regions) {
|
||||
page = region->take_free_page(false);
|
||||
|
@ -535,11 +535,11 @@ void MemoryManager::deallocate_supervisor_physical_page(PhysicalPage&& page)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
RetainPtr<PhysicalPage> MemoryManager::allocate_supervisor_physical_page()
|
||||
RefPtr<PhysicalPage> MemoryManager::allocate_supervisor_physical_page()
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
|
||||
RetainPtr<PhysicalPage> page = nullptr;
|
||||
RefPtr<PhysicalPage> page = nullptr;
|
||||
|
||||
for (auto& region : m_super_physical_regions) {
|
||||
page = region->take_free_page(true);
|
||||
|
|
|
@ -61,8 +61,8 @@ public:
|
|||
Yes
|
||||
};
|
||||
|
||||
RetainPtr<PhysicalPage> allocate_user_physical_page(ShouldZeroFill);
|
||||
RetainPtr<PhysicalPage> allocate_supervisor_physical_page();
|
||||
RefPtr<PhysicalPage> allocate_user_physical_page(ShouldZeroFill);
|
||||
RefPtr<PhysicalPage> allocate_supervisor_physical_page();
|
||||
void deallocate_user_physical_page(PhysicalPage&&);
|
||||
void deallocate_supervisor_physical_page(PhysicalPage&&);
|
||||
|
||||
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
void map_for_kernel(VirtualAddress, PhysicalAddress);
|
||||
|
||||
RetainPtr<Region> allocate_kernel_region(size_t, String&& name);
|
||||
RefPtr<Region> allocate_kernel_region(size_t, String&& name);
|
||||
void map_region_at_address(PageDirectory&, Region&, VirtualAddress, bool user_accessible);
|
||||
|
||||
unsigned user_physical_pages() const { return m_user_physical_pages; }
|
||||
|
@ -93,7 +93,7 @@ private:
|
|||
void flush_entire_tlb();
|
||||
void flush_tlb(VirtualAddress);
|
||||
|
||||
RetainPtr<PhysicalPage> allocate_page_table(PageDirectory&, unsigned index);
|
||||
RefPtr<PhysicalPage> allocate_page_table(PageDirectory&, unsigned index);
|
||||
|
||||
void map_protected(VirtualAddress, size_t length);
|
||||
|
||||
|
@ -214,7 +214,7 @@ private:
|
|||
|
||||
PageTableEntry ensure_pte(PageDirectory&, VirtualAddress);
|
||||
|
||||
RetainPtr<PageDirectory> m_kernel_page_directory;
|
||||
RefPtr<PageDirectory> m_kernel_page_directory;
|
||||
dword* m_page_table_zero { nullptr };
|
||||
dword* m_page_table_one { nullptr };
|
||||
|
||||
|
@ -225,8 +225,8 @@ private:
|
|||
unsigned m_super_physical_pages { 0 };
|
||||
unsigned m_super_physical_pages_used { 0 };
|
||||
|
||||
Vector<Retained<PhysicalRegion>> m_user_physical_regions {};
|
||||
Vector<Retained<PhysicalRegion>> m_super_physical_regions {};
|
||||
Vector<NonnullRefPtr<PhysicalRegion>> m_user_physical_regions {};
|
||||
Vector<NonnullRefPtr<PhysicalRegion>> m_super_physical_regions {};
|
||||
|
||||
HashTable<VMObject*> m_vmos;
|
||||
HashTable<Region*> m_user_regions;
|
||||
|
|
|
@ -10,8 +10,8 @@ class PageDirectory : public RefCounted<PageDirectory> {
|
|||
friend class MemoryManager;
|
||||
|
||||
public:
|
||||
static Retained<PageDirectory> create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr) { return adopt(*new PageDirectory(parent_range_allocator)); }
|
||||
static Retained<PageDirectory> create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); }
|
||||
static NonnullRefPtr<PageDirectory> create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr) { return adopt(*new PageDirectory(parent_range_allocator)); }
|
||||
static NonnullRefPtr<PageDirectory> create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); }
|
||||
~PageDirectory();
|
||||
|
||||
dword cr3() const { return m_directory_page->paddr().get(); }
|
||||
|
@ -26,6 +26,6 @@ private:
|
|||
explicit PageDirectory(PhysicalAddress);
|
||||
|
||||
RangeAllocator m_range_allocator;
|
||||
RetainPtr<PhysicalPage> m_directory_page;
|
||||
HashMap<unsigned, RetainPtr<PhysicalPage>> m_physical_pages;
|
||||
RefPtr<PhysicalPage> m_directory_page;
|
||||
HashMap<unsigned, RefPtr<PhysicalPage>> m_physical_pages;
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <Kernel/VM/PhysicalPage.h>
|
||||
#include <Kernel/kmalloc.h>
|
||||
|
||||
Retained<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist)
|
||||
NonnullRefPtr<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist)
|
||||
{
|
||||
void* slot = kmalloc(sizeof(PhysicalPage));
|
||||
new (slot) PhysicalPage(paddr, supervisor, may_return_to_freelist);
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
static Retained<PhysicalPage> create(PhysicalAddress, bool supervisor, bool may_return_to_freelist = true);
|
||||
static NonnullRefPtr<PhysicalPage> create(PhysicalAddress, bool supervisor, bool may_return_to_freelist = true);
|
||||
|
||||
word ref_count() const { return m_retain_count; }
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <Kernel/VM/PhysicalPage.h>
|
||||
#include <Kernel/VM/PhysicalRegion.h>
|
||||
|
||||
Retained<PhysicalRegion> PhysicalRegion::create(PhysicalAddress lower, PhysicalAddress upper)
|
||||
NonnullRefPtr<PhysicalRegion> PhysicalRegion::create(PhysicalAddress lower, PhysicalAddress upper)
|
||||
{
|
||||
return adopt(*new PhysicalRegion(lower, upper));
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ unsigned PhysicalRegion::finalize_capacity()
|
|||
return size();
|
||||
}
|
||||
|
||||
RetainPtr<PhysicalPage> PhysicalRegion::take_free_page(bool supervisor)
|
||||
RefPtr<PhysicalPage> PhysicalRegion::take_free_page(bool supervisor)
|
||||
{
|
||||
ASSERT(m_pages);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class PhysicalRegion : public RefCounted<PhysicalRegion> {
|
|||
AK_MAKE_ETERNAL
|
||||
|
||||
public:
|
||||
static Retained<PhysicalRegion> create(PhysicalAddress lower, PhysicalAddress upper);
|
||||
static NonnullRefPtr<PhysicalRegion> create(PhysicalAddress lower, PhysicalAddress upper);
|
||||
~PhysicalRegion() {}
|
||||
|
||||
void expand(PhysicalAddress lower, PhysicalAddress upper);
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
unsigned free() const { return m_pages - m_used; }
|
||||
bool contains(PhysicalPage& page) const { return page.paddr() >= m_lower && page.paddr() <= m_upper; }
|
||||
|
||||
RetainPtr<PhysicalPage> take_free_page(bool supervisor);
|
||||
RefPtr<PhysicalPage> take_free_page(bool supervisor);
|
||||
void return_page_at(PhysicalAddress addr);
|
||||
void return_page(PhysicalPage&& page) { return_page_at(page.paddr()); }
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ Region::Region(const Range& range, const String& name, byte access, bool cow)
|
|||
MM.register_region(*this);
|
||||
}
|
||||
|
||||
Region::Region(const Range& range, RetainPtr<Inode>&& inode, const String& name, byte access)
|
||||
Region::Region(const Range& range, RefPtr<Inode>&& inode, const String& name, byte access)
|
||||
: m_range(range)
|
||||
, m_vmo(VMObject::create_file_backed(move(inode)))
|
||||
, m_name(name)
|
||||
|
@ -25,7 +25,7 @@ Region::Region(const Range& range, RetainPtr<Inode>&& inode, const String& name,
|
|||
MM.register_region(*this);
|
||||
}
|
||||
|
||||
Region::Region(const Range& range, Retained<VMObject>&& vmo, size_t offset_in_vmo, const String& name, byte access, bool cow)
|
||||
Region::Region(const Range& range, NonnullRefPtr<VMObject>&& vmo, size_t offset_in_vmo, const String& name, byte access, bool cow)
|
||||
: m_range(range)
|
||||
, m_offset_in_vmo(offset_in_vmo)
|
||||
, m_vmo(move(vmo))
|
||||
|
@ -66,7 +66,7 @@ bool Region::page_in()
|
|||
return true;
|
||||
}
|
||||
|
||||
Retained<Region> Region::clone()
|
||||
NonnullRefPtr<Region> Region::clone()
|
||||
{
|
||||
ASSERT(current);
|
||||
if (m_shared || (is_readable() && !is_writable())) {
|
||||
|
|
|
@ -19,8 +19,8 @@ public:
|
|||
};
|
||||
|
||||
Region(const Range&, const String&, byte access, bool cow = false);
|
||||
Region(const Range&, Retained<VMObject>&&, size_t offset_in_vmo, const String&, byte access, bool cow = false);
|
||||
Region(const Range&, RetainPtr<Inode>&&, const String&, byte access);
|
||||
Region(const Range&, NonnullRefPtr<VMObject>&&, size_t offset_in_vmo, const String&, byte access, bool cow = false);
|
||||
Region(const Range&, RefPtr<Inode>&&, const String&, byte access);
|
||||
~Region();
|
||||
|
||||
VirtualAddress vaddr() const { return m_range.base(); }
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
bool is_shared() const { return m_shared; }
|
||||
void set_shared(bool shared) { m_shared = shared; }
|
||||
|
||||
Retained<Region> clone();
|
||||
NonnullRefPtr<Region> clone();
|
||||
|
||||
bool contains(VirtualAddress vaddr) const
|
||||
{
|
||||
|
@ -97,10 +97,10 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
RetainPtr<PageDirectory> m_page_directory;
|
||||
RefPtr<PageDirectory> m_page_directory;
|
||||
Range m_range;
|
||||
size_t m_offset_in_vmo { 0 };
|
||||
Retained<VMObject> m_vmo;
|
||||
NonnullRefPtr<VMObject> m_vmo;
|
||||
String m_name;
|
||||
byte m_access { 0 };
|
||||
bool m_shared { false };
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <Kernel/VM/MemoryManager.h>
|
||||
#include <Kernel/VM/VMObject.h>
|
||||
|
||||
Retained<VMObject> VMObject::create_file_backed(RetainPtr<Inode>&& inode)
|
||||
NonnullRefPtr<VMObject> VMObject::create_file_backed(RefPtr<Inode>&& inode)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
if (inode->vmo())
|
||||
|
@ -13,13 +13,13 @@ Retained<VMObject> VMObject::create_file_backed(RetainPtr<Inode>&& inode)
|
|||
return vmo;
|
||||
}
|
||||
|
||||
Retained<VMObject> VMObject::create_anonymous(size_t size)
|
||||
NonnullRefPtr<VMObject> VMObject::create_anonymous(size_t size)
|
||||
{
|
||||
size = ceil_div(size, PAGE_SIZE) * PAGE_SIZE;
|
||||
return adopt(*new VMObject(size));
|
||||
}
|
||||
|
||||
Retained<VMObject> VMObject::create_for_physical_range(PhysicalAddress paddr, size_t size)
|
||||
NonnullRefPtr<VMObject> VMObject::create_for_physical_range(PhysicalAddress paddr, size_t size)
|
||||
{
|
||||
size = ceil_div(size, PAGE_SIZE) * PAGE_SIZE;
|
||||
auto vmo = adopt(*new VMObject(paddr, size));
|
||||
|
@ -27,7 +27,7 @@ Retained<VMObject> VMObject::create_for_physical_range(PhysicalAddress paddr, si
|
|||
return vmo;
|
||||
}
|
||||
|
||||
Retained<VMObject> VMObject::clone()
|
||||
NonnullRefPtr<VMObject> VMObject::clone()
|
||||
{
|
||||
return adopt(*new VMObject(*this));
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ VMObject::VMObject(PhysicalAddress paddr, size_t size)
|
|||
ASSERT(m_physical_pages.size() == page_count());
|
||||
}
|
||||
|
||||
VMObject::VMObject(RetainPtr<Inode>&& inode)
|
||||
VMObject::VMObject(RefPtr<Inode>&& inode)
|
||||
: m_inode(move(inode))
|
||||
{
|
||||
ASSERT(m_inode);
|
||||
|
|
|
@ -18,10 +18,10 @@ class VMObject : public RefCounted<VMObject>
|
|||
friend class MemoryManager;
|
||||
|
||||
public:
|
||||
static Retained<VMObject> create_file_backed(RetainPtr<Inode>&&);
|
||||
static Retained<VMObject> create_anonymous(size_t);
|
||||
static Retained<VMObject> create_for_physical_range(PhysicalAddress, size_t);
|
||||
Retained<VMObject> clone();
|
||||
static NonnullRefPtr<VMObject> create_file_backed(RefPtr<Inode>&&);
|
||||
static NonnullRefPtr<VMObject> create_anonymous(size_t);
|
||||
static NonnullRefPtr<VMObject> create_for_physical_range(PhysicalAddress, size_t);
|
||||
NonnullRefPtr<VMObject> clone();
|
||||
|
||||
~VMObject();
|
||||
bool is_anonymous() const { return !m_inode; }
|
||||
|
@ -34,8 +34,8 @@ public:
|
|||
void set_name(const String& name) { m_name = name; }
|
||||
|
||||
size_t page_count() const { return m_size / PAGE_SIZE; }
|
||||
const Vector<RetainPtr<PhysicalPage>>& physical_pages() const { return m_physical_pages; }
|
||||
Vector<RetainPtr<PhysicalPage>>& physical_pages() { return m_physical_pages; }
|
||||
const Vector<RefPtr<PhysicalPage>>& physical_pages() const { return m_physical_pages; }
|
||||
Vector<RefPtr<PhysicalPage>>& physical_pages() { return m_physical_pages; }
|
||||
|
||||
void inode_contents_changed(Badge<Inode>, off_t, ssize_t, const byte*);
|
||||
void inode_size_changed(Badge<Inode>, size_t old_size, size_t new_size);
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
size_t size() const { return m_size; }
|
||||
|
||||
private:
|
||||
VMObject(RetainPtr<Inode>&&);
|
||||
VMObject(RefPtr<Inode>&&);
|
||||
explicit VMObject(VMObject&);
|
||||
explicit VMObject(size_t);
|
||||
VMObject(PhysicalAddress, size_t);
|
||||
|
@ -55,7 +55,7 @@ private:
|
|||
bool m_allow_cpu_caching { true };
|
||||
off_t m_inode_offset { 0 };
|
||||
size_t m_size { 0 };
|
||||
RetainPtr<Inode> m_inode;
|
||||
Vector<RetainPtr<PhysicalPage>> m_physical_pages;
|
||||
RefPtr<Inode> m_inode;
|
||||
Vector<RefPtr<PhysicalPage>> m_physical_pages;
|
||||
Lock m_paging_lock { "VMObject" };
|
||||
};
|
||||
|
|
|
@ -86,7 +86,7 @@ VFS* vfs;
|
|||
|
||||
auto dev_hd0 = IDEDiskDevice::create();
|
||||
|
||||
Retained<DiskDevice> root_dev = dev_hd0.copy_ref();
|
||||
NonnullRefPtr<DiskDevice> root_dev = dev_hd0.copy_ref();
|
||||
|
||||
root = root.substring(strlen("/dev/hda"), root.length() - strlen("/dev/hda"));
|
||||
|
||||
|
@ -199,7 +199,7 @@ extern "C" [[noreturn]] void init()
|
|||
|
||||
auto e1000 = E1000NetworkAdapter::autodetect();
|
||||
|
||||
Retained<ProcFS> new_procfs = ProcFS::create();
|
||||
NonnullRefPtr<ProcFS> new_procfs = ProcFS::create();
|
||||
new_procfs->initialize();
|
||||
|
||||
auto devptsfs = DevPtsFS::create();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue