The Pedigree Project  0.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Ext2Filesystem Class Reference

#include <Ext2Filesystem.h>

+ Inheritance diagram for Ext2Filesystem:
+ Collaboration diagram for Ext2Filesystem:

Public Member Functions

virtual bool initialise (Disk *pDisk)
 
virtual FilegetRoot () const
 
virtual String getVolumeLabel () const
 
- Public Member Functions inherited from Filesystem
 Filesystem ()
 
virtual ~Filesystem ()
 
virtual Filefind (const StringView &path)
 
virtual Filefind (const String &path)
 
virtual Filefind (const StringView &path, File *pStartNode)
 
virtual Filefind (const String &path, File *pStartNode)
 
bool createFile (const StringView &path, uint32_t mask, File *pStartNode=0)
 
bool createDirectory (const StringView &path, uint32_t mask, File *pStartNode=0)
 
bool createSymlink (const StringView &path, const String &value, File *pStartNode=0)
 
bool createLink (const StringView &path, File *target, File *pStartNode=0)
 
bool remove (const StringView &path, File *pStartNode=0)
 
DiskgetDisk ()
 
bool isReadOnly ()
 
virtual bool isCaseSensitive ()
 

Static Public Member Functions

static Filesystemprobe (Disk *pDisk)
 

Protected Member Functions

virtual bool createFile (File *parent, const String &filename, uint32_t mask)
 
virtual bool createDirectory (File *parent, const String &filename, uint32_t mask)
 
virtual bool createSymlink (File *parent, const String &filename, const String &value)
 
virtual bool createLink (File *parent, const String &filename, File *target)
 
virtual bool remove (File *parent, File *file)
 

Private Member Functions

virtual bool createNode (File *parent, const String &filename, uint32_t mask, const String &value, size_t type, uint32_t inodeOverride=0)
 
 Ext2Filesystem (const Ext2Filesystem &)
 
void operator= (const Ext2Filesystem &)
 
uintptr_t readBlock (uint32_t block)
 
void writeBlock (uint32_t block)
 
void pinBlock (uint64_t location)
 
void unpinBlock (uint64_t location)
 
void sync (size_t offset, bool async)
 
uint32_t findFreeBlock (uint32_t inode)
 
bool findFreeBlocks (uint32_t inode, size_t count, Vector< uint32_t > &blocks)
 
size_t findFreeBlocksInGroup (uint32_t group, size_t maxCount, Vector< uint32_t > &blocks)
 
uint32_t findFreeInode ()
 
void releaseBlock (uint32_t block)
 
bool releaseInode (uint32_t inode)
 
InodegetInode (uint32_t num)
 
void writeInode (uint32_t num)
 
void ensureFreeBlockBitmapLoaded (size_t group)
 
void ensureFreeInodeBitmapLoaded (size_t group)
 
void ensureInodeTableLoaded (size_t group)
 
bool checkOptionalFeature (size_t feature)
 
bool checkRequiredFeature (size_t feature)
 
bool checkReadOnlyFeature (size_t feature)
 
void increaseInodeRefcount (uint32_t inode)
 
bool decreaseInodeRefcount (uint32_t inode)
 

Private Attributes

Superblockm_pSuperblock
 
GroupDesc ** m_pGroupDescriptors
 
Vector< size_t > * m_pInodeTables
 
Vector< size_t > * m_pInodeBitmaps
 
Vector< size_t > * m_pBlockBitmaps
 
uint32_t m_BlockSize
 
uint32_t m_InodeSize
 
size_t m_nGroupDescriptors
 
Mutex m_WriteLock
 
Filem_pRoot
 
String m_VolumeLabel
 

Friends

class Ext2File
 
class Ext2Node
 
class Ext2Directory
 
class Ext2Symlink
 

Additional Inherited Members

- Public Types inherited from Filesystem
typedef Filesystem *(* ProbeCallback) (Disk *)
 
- Protected Attributes inherited from Filesystem
bool m_bReadOnly
 
Diskm_pDisk
 

Detailed Description

This class provides an implementation of the second extended filesystem.

Definition at line 37 of file Ext2Filesystem.h.

Constructor & Destructor Documentation

Ext2Filesystem::Ext2Filesystem ( const Ext2Filesystem )
private

Inaccessible copy constructor and operator=

Member Function Documentation

bool Ext2Filesystem::createDirectory ( File parent,
const String filename,
uint32_t  mask 
)
protectedvirtual

createDirectory calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 448 of file Ext2Filesystem.cc.

bool Ext2Filesystem::createFile ( File parent,
const String filename,
uint32_t  mask 
)
protectedvirtual

createFile calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 442 of file Ext2Filesystem.cc.

bool Ext2Filesystem::createLink ( File parent,
const String filename,
File target 
)
protectedvirtual

createLink calls this after it has parsed the string path.

Reimplemented from Filesystem.

Definition at line 464 of file Ext2Filesystem.cc.

References File::isDirectory(), and File::isSymlink().

bool Ext2Filesystem::createNode ( File parent,
const String filename,
uint32_t  mask,
const String value,
size_t  type,
uint32_t  inodeOverride = 0 
)
privatevirtual
bool Ext2Filesystem::createSymlink ( File parent,
const String filename,
const String value 
)
protectedvirtual

createSymlink calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 458 of file Ext2Filesystem.cc.

bool Ext2Filesystem::findFreeBlocks ( uint32_t  inode,
size_t  count,
Vector< uint32_t > &  blocks 
)
private
Todo:
should release blocks if we failed to allocate enough blocks.

Definition at line 604 of file Ext2Filesystem.cc.

References ERROR.

Referenced by Ext2Node::ensureLargeEnough().

+ Here is the caller graph for this function:

size_t Ext2Filesystem::findFreeBlocksInGroup ( uint32_t  group,
size_t  maxCount,
Vector< uint32_t > &  blocks 
)
private
Todo:
Endianness - to ensure correct operation, must ptr be little endian?
Todo:
save group descriptor block number elsewhere

Definition at line 635 of file Ext2Filesystem.cc.

References Vector< T >::pushBack(), and Ext2File::writeBlock().

uint32_t Ext2Filesystem::findFreeInode ( )
private
Todo:
Endianness - to ensure correct operation, must ptr be little endian?
Todo:
save group descriptor block number elsewhere

Definition at line 773 of file Ext2Filesystem.cc.

References assert, and Ext2File::writeBlock().

File * Ext2Filesystem::getRoot ( ) const
virtual

Returns the root filesystem node.

Implements Filesystem.

Definition at line 247 of file Ext2Filesystem.cc.

String Ext2Filesystem::getVolumeLabel ( ) const
virtual

Returns a string identifying the volume label.

Implements Filesystem.

Definition at line 252 of file Ext2Filesystem.cc.

bool Ext2Filesystem::initialise ( Disk pDisk)
virtual

Populates this filesystem with data from the given Disk device.

Returns
true on success, false on failure.
Todo:
Check for journal required features.
Todo:
Check all read-only features.
Todo:
Set g_pSparseBlock as read-only.

Implements Filesystem.

Definition at line 85 of file Ext2Filesystem.cc.

References assert, ERROR, Disk::getName(), initialise(), NOTICE, Ext2File::readBlock(), and WARNING.

Referenced by initialise().

+ Here is the caller graph for this function:

uintptr_t Ext2Filesystem::readBlock ( uint32_t  block)
private

Reads a block of data from the disk.

Definition at line 557 of file Ext2Filesystem.cc.

Referenced by Ext2Directory::addEntry(), Ext2Directory::cacheDirectoryContents(), Ext2Node::ensureLargeEnough(), Ext2Directory::removeEntry(), and Ext2Node::~Ext2Node().

+ Here is the caller graph for this function:

void Ext2Filesystem::releaseBlock ( uint32_t  block)
private
Todo:
save group descriptor block number elsewhere

Definition at line 860 of file Ext2Filesystem.cc.

References Dec, ERROR, FATAL, Hex, and Ext2File::writeBlock().

Referenced by Ext2Node::wipe().

+ Here is the caller graph for this function:

bool Ext2Filesystem::releaseInode ( uint32_t  inode)
private

Releases the given inode, returns true if the inode had no more links.

Todo:
save group descriptor block number elsewhere

Definition at line 915 of file Ext2Filesystem.cc.

References VFS::addProbeCallback(), assert, VFS::instance(), Ext2File::pinBlock(), Vector< T >::pushBack(), Ext2File::readBlock(), Vector< T >::size(), WARNING, and Ext2File::writeBlock().

Referenced by Ext2Directory::removeEntry().

+ Here is the caller graph for this function:

bool Ext2Filesystem::remove ( File parent,
File file 
)
protectedvirtual

Remove a file given a parent and file, assuming path parsing already completed.

Todo:
save group descriptor block number elsewhere

Implements Filesystem.

Definition at line 500 of file Ext2Filesystem.cc.

References File::getName(), File::isDirectory(), File::isSymlink(), NOTICE, Ext2Directory::removeEntry(), and Ext2File::writeBlock().

void Ext2Filesystem::writeBlock ( uint32_t  block)
private

Writes a block of data to the disk.

Definition at line 566 of file Ext2Filesystem.cc.

Referenced by Ext2Directory::addEntry(), Ext2Node::ensureLargeEnough(), Ext2Directory::removeEntry(), and Ext2Node::~Ext2Node().

+ Here is the caller graph for this function:

Member Data Documentation

uint32_t Ext2Filesystem::m_BlockSize
private
uint32_t Ext2Filesystem::m_InodeSize
private

Size of an Inode.

Definition at line 129 of file Ext2Filesystem.h.

size_t Ext2Filesystem::m_nGroupDescriptors
private

Number of group descriptors.

Definition at line 132 of file Ext2Filesystem.h.

Vector<size_t>* Ext2Filesystem::m_pBlockBitmaps
private

Free block bitmaps, indexed by group descriptor.

Definition at line 123 of file Ext2Filesystem.h.

GroupDesc** Ext2Filesystem::m_pGroupDescriptors
private

Group descriptors, in a tree because each GroupDesc* may be in a different block.

Definition at line 116 of file Ext2Filesystem.h.

Vector<size_t>* Ext2Filesystem::m_pInodeBitmaps
private

Free inode bitmaps, indexed by group descriptor.

Definition at line 121 of file Ext2Filesystem.h.

Vector<size_t>* Ext2Filesystem::m_pInodeTables
private

Inode tables, indexed by group descriptor.

Definition at line 119 of file Ext2Filesystem.h.

File* Ext2Filesystem::m_pRoot
private

The root filesystem node.

Definition at line 141 of file Ext2Filesystem.h.

Superblock* Ext2Filesystem::m_pSuperblock
private

Our superblock.

Definition at line 112 of file Ext2Filesystem.h.

String Ext2Filesystem::m_VolumeLabel
private

Cached volume label.

Definition at line 144 of file Ext2Filesystem.h.

Mutex Ext2Filesystem::m_WriteLock
private

Write lock - we're finding some inodes and updating the superblock and block group structures.

Definition at line 137 of file Ext2Filesystem.h.


The documentation for this class was generated from the following files: