diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-17 10:55:43 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-17 10:57:23 +0200 |
commit | 9171521752b0b382f1f70453b4f24915999144b9 (patch) | |
tree | a3bb1e3533e591c4693ce98b245870e4da5daede /Kernel/Ext2FileSystem.h | |
parent | aec8ab0a606a1ccb3eaf5816ef85e3951c2d5227 (diff) | |
download | serenity-9171521752b0b382f1f70453b4f24915999144b9.zip |
Integrate ext2 from VFS into Kernel.
Diffstat (limited to 'Kernel/Ext2FileSystem.h')
-rw-r--r-- | Kernel/Ext2FileSystem.h | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/Kernel/Ext2FileSystem.h b/Kernel/Ext2FileSystem.h deleted file mode 100644 index 9509531d48..0000000000 --- a/Kernel/Ext2FileSystem.h +++ /dev/null @@ -1,74 +0,0 @@ -#pragma once - -#include "ext2fs.h" -#include "OwnPtr.h" -#include "DataBuffer.h" -#include "FileSystem.h" - -static const size_t bytesPerSector = 512; - -class Ext2VirtualNode; - -class Ext2FileSystem { -public: - Ext2FileSystem() { } - ~Ext2FileSystem(); - - void initialize(); - RefPtr<DataBuffer> loadFile(ext2_dir_entry*); - - ext2_inode* findInode(DWORD index); - ext2_inode* findPath(const String& path, DWORD& inodeIndex); - -private: - friend class Ext2VirtualNode; - - void readSuperBlock(); - void readBlockGroup(DWORD); - void readInodeTable(DWORD); - void dumpDirectory(ext2_inode&); - void dumpFile(ext2_inode&); - - template<typename F> void forEachBlockIn(ext2_inode&, F func); - template<typename F> void traverseDirectory(ext2_dir_entry&, DWORD blockCount, F); - template<typename F> void traverseDirectory(ext2_inode&, F); - RefPtr<DataBuffer> readFile(ext2_inode&); - - RefPtr<DataBuffer> readBlocks(DWORD blockIndex, BYTE count); - void readDiskSector(DWORD sectorIndex, BYTE* buffer); - - size_t blockSize() const { return 1024 << m_superBlock->s_log_frag_size; } - size_t sectorsPerBlock() const { return blockSize() / bytesPerSector; } - DWORD blockGroupForInode(DWORD inode) const; - DWORD toInodeTableIndex(DWORD inode) const; - - ext2_super_block& superBlock() { ASSERT(m_superBlock); return *m_superBlock; } - - OwnPtr<ext2_super_block> m_superBlock; - ext2_inode* m_root { nullptr }; // raw pointer into one of the m_inodeTables - - size_t m_blockGroupCount { 0 }; - ext2_group_descriptor* m_groupTable { nullptr }; - ext2_inode** m_inodeTables { nullptr }; -}; - -class Ext2VirtualNode final : public FileSystem::VirtualNode { -public: - static RefPtr<Ext2VirtualNode> create(DWORD index, String&& path, Ext2FileSystem&, DWORD inodeNumber); - - virtual ~Ext2VirtualNode(); - - virtual size_t size() const override { return m_inode.i_size; } - virtual uid_t uid() const override { return m_inode.i_uid; } - virtual gid_t gid() const override { return m_inode.i_gid; } - virtual size_t mode() const override { return m_inode.i_mode; } - - virtual size_t read(BYTE* outbuf, size_t start, size_t maxLength) override; - -private: - Ext2VirtualNode(DWORD index, String&& path, Ext2FileSystem&, ext2_inode&, DWORD inodeNumber); - - Ext2FileSystem& m_fileSystem; - ext2_inode& m_inode; - DWORD m_inodeNumber { 0 }; -}; |