mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08:10 +00:00
Rename:
VirtualFileSystem -> VFS VirtualFileSystem::Node -> Vnode
This commit is contained in:
parent
c735c56e4c
commit
457a5df7d5
13 changed files with 143 additions and 137 deletions
|
@ -33,7 +33,46 @@ inline constexpr dword encodedDevice(unsigned major, unsigned minor)
|
|||
return (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
|
||||
}
|
||||
|
||||
class VirtualFileSystem {
|
||||
class VFS;
|
||||
|
||||
class Vnode {
|
||||
public:
|
||||
InodeIdentifier inode;
|
||||
const InodeMetadata& metadata() const;
|
||||
|
||||
bool inUse() const { return inode.isValid() || m_characterDevice; }
|
||||
|
||||
bool isCharacterDevice() const { return m_characterDevice; }
|
||||
CharacterDevice* characterDevice() { return m_characterDevice; }
|
||||
const CharacterDevice* characterDevice() const { return m_characterDevice; }
|
||||
|
||||
void retain();
|
||||
void release();
|
||||
|
||||
FileSystem* fileSystem() { return inode.fileSystem(); }
|
||||
const FileSystem* fileSystem() const { return inode.fileSystem(); }
|
||||
|
||||
VFS* vfs() { return m_vfs; }
|
||||
const VFS* vfs() const { return m_vfs; }
|
||||
|
||||
void* vmo() { return m_vmo; }
|
||||
void set_vmo(void* vmo) { m_vmo = vmo; }
|
||||
|
||||
unsigned retain_count() const { return retainCount; }
|
||||
|
||||
CoreInode* core_inode() { return m_core_inode.ptr(); }
|
||||
|
||||
private:
|
||||
friend class VFS;
|
||||
VFS* m_vfs { nullptr };
|
||||
unsigned retainCount { 0 };
|
||||
CharacterDevice* m_characterDevice { nullptr };
|
||||
mutable InodeMetadata m_cachedMetadata;
|
||||
void* m_vmo { nullptr };
|
||||
RetainPtr<CoreInode> m_core_inode;
|
||||
};
|
||||
|
||||
class VFS {
|
||||
AK_MAKE_ETERNAL
|
||||
friend ByteBuffer procfs$vnodes();
|
||||
public:
|
||||
|
@ -54,56 +93,22 @@ public:
|
|||
RetainPtr<FileSystem> m_fileSystem;
|
||||
};
|
||||
|
||||
struct Node {
|
||||
InodeIdentifier inode;
|
||||
const InodeMetadata& metadata() const;
|
||||
static VFS& the() PURE;
|
||||
|
||||
bool inUse() const { return inode.isValid() || m_characterDevice; }
|
||||
|
||||
bool isCharacterDevice() const { return m_characterDevice; }
|
||||
CharacterDevice* characterDevice() { return m_characterDevice; }
|
||||
const CharacterDevice* characterDevice() const { return m_characterDevice; }
|
||||
|
||||
void retain();
|
||||
void release();
|
||||
|
||||
FileSystem* fileSystem() { return inode.fileSystem(); }
|
||||
const FileSystem* fileSystem() const { return inode.fileSystem(); }
|
||||
|
||||
VirtualFileSystem* vfs() { return m_vfs; }
|
||||
const VirtualFileSystem* vfs() const { return m_vfs; }
|
||||
|
||||
void* vmo() { return m_vmo; }
|
||||
void set_vmo(void* vmo) { m_vmo = vmo; }
|
||||
|
||||
unsigned retain_count() const { return retainCount; }
|
||||
|
||||
CoreInode* core_inode() { return m_core_inode.ptr(); }
|
||||
|
||||
private:
|
||||
friend class VirtualFileSystem;
|
||||
VirtualFileSystem* m_vfs { nullptr };
|
||||
unsigned retainCount { 0 };
|
||||
CharacterDevice* m_characterDevice { nullptr };
|
||||
mutable InodeMetadata m_cachedMetadata;
|
||||
void* m_vmo { nullptr };
|
||||
RetainPtr<CoreInode> m_core_inode;
|
||||
};
|
||||
|
||||
static VirtualFileSystem& the() PURE;
|
||||
|
||||
VirtualFileSystem();
|
||||
~VirtualFileSystem();
|
||||
VFS();
|
||||
~VFS();
|
||||
|
||||
#ifndef SERENITY
|
||||
bool isDirectory(const String& path, InodeIdentifier base = InodeIdentifier());
|
||||
void listDirectory(const String& path, InodeIdentifier base);
|
||||
void listDirectoryRecursively(const String& path, InodeIdentifier base);
|
||||
#endif
|
||||
|
||||
unsigned maxNodeCount() const { return m_maxNodeCount; }
|
||||
unsigned allocatedNodeCount() const { return m_maxNodeCount - m_nodeFreeList.size(); }
|
||||
|
||||
Node* root() { return m_rootNode.ptr(); }
|
||||
const Node* root() const { return m_rootNode.ptr(); }
|
||||
Vnode* root() { return m_rootNode.ptr(); }
|
||||
const Vnode* root() const { return m_rootNode.ptr(); }
|
||||
|
||||
bool mountRoot(RetainPtr<FileSystem>&&);
|
||||
bool mount(RetainPtr<FileSystem>&&, const String& path);
|
||||
|
@ -113,8 +118,6 @@ public:
|
|||
RetainPtr<FileDescriptor> create(const String& path, InodeIdentifier base = InodeIdentifier());
|
||||
RetainPtr<FileDescriptor> mkdir(const String& path, InodeIdentifier base = InodeIdentifier());
|
||||
|
||||
bool isRoot(InodeIdentifier) const;
|
||||
|
||||
bool touch(const String&path);
|
||||
|
||||
void registerCharacterDevice(CharacterDevice&);
|
||||
|
@ -126,36 +129,39 @@ public:
|
|||
|
||||
private:
|
||||
friend class FileDescriptor;
|
||||
friend class Vnode;
|
||||
|
||||
RetainPtr<CoreInode> get_inode(InodeIdentifier);
|
||||
|
||||
bool is_vfs_root(InodeIdentifier) const;
|
||||
|
||||
void enumerateDirectoryInode(InodeIdentifier, Function<bool(const FileSystem::DirectoryEntry&)>);
|
||||
InodeIdentifier resolve_path(const String& path, int& error, CoreInode& base, int options = 0);
|
||||
InodeIdentifier resolvePath(const String& path, int& error, InodeIdentifier base = InodeIdentifier(), int options = 0);
|
||||
InodeIdentifier resolveSymbolicLink(InodeIdentifier base, InodeIdentifier symlinkInode, int& error);
|
||||
|
||||
RetainPtr<Node> allocateNode();
|
||||
void freeNode(Node*);
|
||||
RetainPtr<Vnode> allocateNode();
|
||||
void freeNode(Vnode*);
|
||||
|
||||
RetainPtr<Node> makeNode(InodeIdentifier);
|
||||
RetainPtr<Node> makeNode(CharacterDevice&);
|
||||
RetainPtr<Node> getOrCreateNode(InodeIdentifier);
|
||||
RetainPtr<Node> getOrCreateNode(CharacterDevice&);
|
||||
RetainPtr<Vnode> makeNode(InodeIdentifier);
|
||||
RetainPtr<Vnode> makeNode(CharacterDevice&);
|
||||
RetainPtr<Vnode> getOrCreateNode(InodeIdentifier);
|
||||
RetainPtr<Vnode> getOrCreateNode(CharacterDevice&);
|
||||
|
||||
Mount* findMountForHost(InodeIdentifier);
|
||||
Mount* findMountForGuest(InodeIdentifier);
|
||||
|
||||
HashMap<InodeIdentifier, Node*> m_inode2vnode;
|
||||
HashMap<dword, Node*> m_device2vnode;
|
||||
HashMap<InodeIdentifier, Vnode*> m_inode2vnode;
|
||||
HashMap<dword, Vnode*> m_device2vnode;
|
||||
|
||||
Vector<OwnPtr<Mount>> m_mounts;
|
||||
|
||||
unsigned m_maxNodeCount { 0 };
|
||||
Node* m_nodes { nullptr };
|
||||
Vnode* m_nodes { nullptr };
|
||||
|
||||
Vector<Node*> m_nodeFreeList;
|
||||
Vector<Vnode*> m_nodeFreeList;
|
||||
|
||||
RetainPtr<Node> m_rootNode;
|
||||
RetainPtr<Vnode> m_rootNode;
|
||||
|
||||
HashMap<dword, CharacterDevice*> m_characterDevices;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue