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

#include <Ext2Node.h>

+ Inheritance diagram for Ext2Node:
+ Collaboration diagram for Ext2Node:

Classes

class  DataShrinkPlan
 
struct  MappingPage
 
struct  TrimPlan
 

Public Member Functions

 Ext2Node (uintptr_t inode_num, Inode *pInode, class Ext2Filesystem *pFs)
 
virtual ~Ext2Node ()
 
Inode * getInode ()
 
uint32_t getInodeNumber ()
 
void fileAttributeChanged (size_t size, size_t atime, size_t mtime, size_t ctime)
 
File::Attributes inodeAttributes () const
 
void updateInodeAttributes (const File::Attributes &attributes, uint32_t mask)
 
bool changeInodeOwnership (size_t uid, size_t gid, bool changeUid, bool changeGid)
 
bool wipe (bool allocationLockHeld=false)
 
void extend (size_t newSize)
 
void extend (size_t newSize, uint64_t location, uint64_t size)
 
uint64_t maximumFileSize () const
 
bool isInlineSymlink () const
 
void updateAllocatedSectorCount ()
 
XattrStatus getXattr (const StringView &, void *, size_t, size_t &)
 
XattrStatus listXattrs (void *, size_t, size_t &)
 
XattrStatus setXattr (const StringView &, const void *, size_t, unsigned)
 
XattrStatus removeXattr (const StringView &)
 
uintptr_t readBlock (uint64_t location)
 
void writeBlock (uint64_t location)
 
void trackBlock (uint32_t block, bool writeInode=true)
 
bool pinBlock (uint64_t location)
 
void unpinBlock (uint64_t location)
 
bool sync (size_t offset, bool async)
 

Static Public Member Functions

static bool decodeAllocation (const Inode &, uint32_t blockSize, uint32_t &blocks, bool &inlineSymlink)
 
static bool encodeAllocation (uint32_t data, uint32_t indirect, bool hasEa, uint32_t blockSize, uint32_t &sectors)
 

Protected Member Functions

XattrStatus changeXattr (const StringView &, const void *, size_t, unsigned, bool remove)
 
bool resizeData (size_t size)
 
bool trimToBlocks (size_t keep, bool allocationLockHeld=false)
 
bool zeroRange (size_t start, size_t end)
 
bool collectMappingPages (uint32_t block, unsigned depth, size_t first, size_t span, Vector< MappingPage > &pages)
 
bool prepareTrim (size_t keep, TrimPlan &plan, bool allocationLockHeld=false)
 
void commitTrim (TrimPlan &plan, bool allocationLockHeld=false)
 
bool prepareDataShrink (size_t size, UniquePointer< File::PreparedShrink > &prepared)
 
bool ensureLargeEnough (size_t size, uint64_t location, uint64_t opsize, bool onlyBlocks=false, bool nozeroblocks=false)
 
bool addBlock (uint32_t blockValue, Vector< uint32_t > *pendingWrites=0)
 
void writeBlockOrQueue (uint32_t block, Vector< uint32_t > *pendingWrites)
 
bool ensureBlockLoaded (size_t nBlock)
 
bool getBlockNumber (size_t nBlock)
 
bool getBlockNumberIndirect (uint32_t inode_block, size_t nBlocks, size_t nBlock)
 
bool getBlockNumberBiindirect (uint32_t inode_block, size_t nBlocks, size_t nBlock)
 
bool getBlockNumberTriindirect (uint32_t inode_block, size_t nBlocks, size_t nBlock)
 
bool setBlockNumber (size_t blockNum, uint32_t blockValue, Vector< uint32_t > *pendingWrites=nullptr)
 
bool ensureWritableRange (size_t location, size_t length)
 
uint32_t modeToPermissions (uint32_t mode) const
 
uint32_t permissionsToMode (uint32_t permissions) const
 

Protected Attributes

Ext2InodeState * m_State
 
Inode *& m_pInode
 
uint32_t m_InodeNumber
 
class Ext2Filesystem * m_pExt2Fs
 
Vector< uint32_t > & m_Blocks
 
uint32_t & m_nMetadataBlocks
 
size_t & m_nSize
 

Private Member Functions

 Ext2Node (uintptr_t inode, Inode *metadata, Ext2Filesystem *filesystem, Ext2InodeState &admitted)
 
 Ext2Node (const Ext2Node &file)
 
Ext2Node & operator= (const Ext2Node &)
 

Friends

class Ext2Filesystem
 

Detailed Description

A node in an ext2 filesystem.

Definition at line 65 of file Ext2Node.h.

Constructor & Destructor Documentation

◆ Ext2Node() [1/2]

Ext2Node::Ext2Node ( uintptr_t  inode,
Inode *  metadata,
Ext2Filesystem *  filesystem,
Ext2InodeState &  admitted 
)
private

Copy constructors are hidden - unused!

Definition at line 145 of file Ext2Node.cc.

◆ Ext2Node() [2/2]

Ext2Node::Ext2Node ( uintptr_t  inode_num,
Inode *  pInode,
class Ext2Filesystem *  pFs 
)

Constructor, should be called only by a Filesystem.

Definition at line 136 of file Ext2Node.cc.

◆ ~Ext2Node()

Ext2Node::~Ext2Node ( )
virtual

Destructor

Definition at line 155 of file Ext2Node.cc.

Member Function Documentation

◆ addBlock()

bool Ext2Node::addBlock ( uint32_t  blockValue,
Vector< uint32_t > *  pendingWrites = 0 
)
protected

Definition at line 519 of file Ext2Node.cc.

◆ changeInodeOwnership()

bool Ext2Node::changeInodeOwnership ( size_t  uid,
size_t  gid,
bool  changeUid,
bool  changeGid 
)

Definition at line 11 of file Ext2Node-quota.cc.

◆ changeXattr()

XattrStatus Ext2Node::changeXattr ( const StringView &  name,
const void *  value,
size_t  length,
unsigned  flags,
bool  remove 
)
protected

Definition at line 31 of file Ext2Xattr-write.cc.

◆ collectMappingPages()

bool Ext2Node::collectMappingPages ( uint32_t  block,
unsigned  depth,
size_t  first,
size_t  span,
Vector< MappingPage > &  pages 
)
protected

Definition at line 42 of file Ext2Resize.cc.

◆ commitTrim()

void Ext2Node::commitTrim ( TrimPlan &  plan,
bool  allocationLockHeld = false 
)
protected

Definition at line 123 of file Ext2Resize.cc.

◆ decodeAllocation()

bool Ext2Node::decodeAllocation ( const Inode &  inode,
uint32_t  blockSize,
uint32_t &  blocks,
bool &  inlineSymlink 
)
static

Definition at line 308 of file Ext2Xattr.cc.

◆ encodeAllocation()

bool Ext2Node::encodeAllocation ( uint32_t  data,
uint32_t  indirect,
bool  hasEa,
uint32_t  blockSize,
uint32_t &  sectors 
)
static

Definition at line 321 of file Ext2Xattr.cc.

◆ ensureBlockLoaded()

bool Ext2Node::ensureBlockLoaded ( size_t  nBlock)
protected

Definition at line 331 of file Ext2Node.cc.

◆ ensureLargeEnough()

bool Ext2Node::ensureLargeEnough ( size_t  size,
uint64_t  location,
uint64_t  opsize,
bool  onlyBlocks = false,
bool  nozeroblocks = false 
)
protected

Ensures the inode is at least 'size' big. Set onlyBlocks to true to not change the actual data size, which can be useful for preallocation.

Definition at line 258 of file Ext2Node.cc.

References Vector< T >::count(), Ext2Filesystem::m_BlockSize, Filesystem::m_pDisk, Ext2Filesystem::writeBlock(), and Disk::zero().

Referenced by Ext2Filesystem::createNode(), Ext2File::preallocate(), and Ext2Symlink::writeBytewise().

+ Here is the caller graph for this function:

◆ ensureWritableRange()

bool Ext2Node::ensureWritableRange ( size_t  location,
size_t  length 
)
protected

Definition at line 527 of file Ext2Node.cc.

◆ extend() [1/2]

void Ext2Node::extend ( size_t  newSize)

Definition at line 242 of file Ext2Node.cc.

◆ extend() [2/2]

void Ext2Node::extend ( size_t  newSize,
uint64_t  location,
uint64_t  size 
)

Definition at line 246 of file Ext2Node.cc.

◆ fileAttributeChanged()

void Ext2Node::fileAttributeChanged ( size_t  size,
size_t  atime,
size_t  mtime,
size_t  ctime 
)

Updates inode attributes.

Todo:
4GB files.

Definition at line 567 of file Ext2Node.cc.

Referenced by Ext2Symlink::fileAttributeChanged(), Ext2Directory::fileAttributeChanged(), and Ext2File::fileAttributeChanged().

+ Here is the caller graph for this function:

◆ getBlockNumber()

bool Ext2Node::getBlockNumber ( size_t  nBlock)
protected

Definition at line 343 of file Ext2Node.cc.

◆ getBlockNumberBiindirect()

bool Ext2Node::getBlockNumberBiindirect ( uint32_t  inode_block,
size_t  nBlocks,
size_t  nBlock 
)
protected

Definition at line 381 of file Ext2Node.cc.

◆ getBlockNumberIndirect()

bool Ext2Node::getBlockNumberIndirect ( uint32_t  inode_block,
size_t  nBlocks,
size_t  nBlock 
)
protected

Definition at line 361 of file Ext2Node.cc.

◆ getBlockNumberTriindirect()

bool Ext2Node::getBlockNumberTriindirect ( uint32_t  inode_block,
size_t  nBlocks,
size_t  nBlock 
)
protected

Definition at line 404 of file Ext2Node.cc.

◆ getInode()

Inode * Ext2Node::getInode ( )
inline

Definition at line 80 of file Ext2Node.h.

◆ getInodeNumber()

uint32_t Ext2Node::getInodeNumber ( )
inline

Definition at line 84 of file Ext2Node.h.

◆ getXattr()

XattrStatus Ext2Node::getXattr ( const StringView &  name,
void *  output,
size_t  capacity,
size_t &  required 
)

Definition at line 266 of file Ext2Xattr.cc.

◆ inodeAttributes()

File::Attributes Ext2Node::inodeAttributes ( ) const

Definition at line 584 of file Ext2Node.cc.

◆ isInlineSymlink()

bool Ext2Node::isInlineSymlink ( ) const

Definition at line 330 of file Ext2Xattr.cc.

◆ listXattrs()

XattrStatus Ext2Node::listXattrs ( void *  output,
size_t  capacity,
size_t &  required 
)

Definition at line 287 of file Ext2Xattr.cc.

◆ maximumFileSize()

uint64_t Ext2Node::maximumFileSize ( ) const

Definition at line 250 of file Ext2Node.cc.

◆ modeToPermissions()

uint32_t Ext2Node::modeToPermissions ( uint32_t  mode) const
protected

Definition at line 672 of file Ext2Node.cc.

◆ permissionsToMode()

uint32_t Ext2Node::permissionsToMode ( uint32_t  permissions) const
protected

Definition at line 697 of file Ext2Node.cc.

◆ pinBlock()

bool Ext2Node::pinBlock ( uint64_t  location)

Definition at line 644 of file Ext2Node.cc.

◆ prepareDataShrink()

bool Ext2Node::prepareDataShrink ( size_t  size,
UniquePointer< File::PreparedShrink > &  prepared 
)
protected

Definition at line 201 of file Ext2Resize.cc.

◆ prepareTrim()

bool Ext2Node::prepareTrim ( size_t  keep,
TrimPlan &  plan,
bool  allocationLockHeld = false 
)
protected

Definition at line 68 of file Ext2Resize.cc.

◆ readBlock()

uintptr_t Ext2Node::readBlock ( uint64_t  location)

Definition at line 159 of file Ext2Node.cc.

◆ removeXattr()

XattrStatus Ext2Node::removeXattr ( const StringView &  name)

Definition at line 119 of file Ext2Xattr-write.cc.

◆ resizeData()

bool Ext2Node::resizeData ( size_t  size)
protected

Definition at line 255 of file Ext2Resize.cc.

◆ setBlockNumber()

bool Ext2Node::setBlockNumber ( size_t  blockNum,
uint32_t  blockValue,
Vector< uint32_t > *  pendingWrites = nullptr 
)
protected

Definition at line 450 of file Ext2Node.cc.

◆ setXattr()

XattrStatus Ext2Node::setXattr ( const StringView &  name,
const void *  value,
size_t  length,
unsigned  flags 
)

Definition at line 115 of file Ext2Xattr-write.cc.

◆ sync()

bool Ext2Node::sync ( size_t  offset,
bool  async 
)

Definition at line 629 of file Ext2Node.cc.

◆ trackBlock()

void Ext2Node::trackBlock ( uint32_t  block,
bool  writeInode = true 
)

Definition at line 203 of file Ext2Node.cc.

◆ trimToBlocks()

bool Ext2Node::trimToBlocks ( size_t  keep,
bool  allocationLockHeld = false 
)
protected

Definition at line 164 of file Ext2Resize.cc.

◆ unpinBlock()

void Ext2Node::unpinBlock ( uint64_t  location)

Definition at line 658 of file Ext2Node.cc.

◆ updateAllocatedSectorCount()

void Ext2Node::updateAllocatedSectorCount ( )

Definition at line 337 of file Ext2Xattr.cc.

◆ updateInodeAttributes()

void Ext2Node::updateInodeAttributes ( const File::Attributes &  attributes,
uint32_t  mask 
)

Definition at line 599 of file Ext2Node.cc.

◆ wipe()

bool Ext2Node::wipe ( bool  allocationLockHeld = false)

Wipes the node of data - frees all blocks.

Definition at line 217 of file Ext2Node.cc.

Referenced by Ext2Filesystem::retireInodeLocked(), and Ext2Symlink::truncate().

+ Here is the caller graph for this function:

◆ writeBlock()

void Ext2Node::writeBlock ( uint64_t  location)

Definition at line 188 of file Ext2Node.cc.

◆ writeBlockOrQueue()

void Ext2Node::writeBlockOrQueue ( uint32_t  block,
Vector< uint32_t > *  pendingWrites 
)
protected

Definition at line 427 of file Ext2Node.cc.

◆ zeroRange()

bool Ext2Node::zeroRange ( size_t  start,
size_t  end 
)
protected

Definition at line 230 of file Ext2Resize.cc.

Friends And Related Symbol Documentation

◆ Ext2Filesystem

friend class Ext2Filesystem
friend

Definition at line 66 of file Ext2Node.h.

Member Data Documentation

◆ m_Blocks

Vector<uint32_t>& Ext2Node::m_Blocks
protected

Definition at line 182 of file Ext2Node.h.

◆ m_InodeNumber

uint32_t Ext2Node::m_InodeNumber
protected

Definition at line 179 of file Ext2Node.h.

◆ m_nMetadataBlocks

uint32_t& Ext2Node::m_nMetadataBlocks
protected

Definition at line 183 of file Ext2Node.h.

◆ m_nSize

size_t& Ext2Node::m_nSize
protected

Definition at line 185 of file Ext2Node.h.

◆ m_pExt2Fs

class Ext2Filesystem* Ext2Node::m_pExt2Fs
protected

Definition at line 180 of file Ext2Node.h.

◆ m_pInode

Inode*& Ext2Node::m_pInode
protected

Definition at line 178 of file Ext2Node.h.

◆ m_State

Ext2InodeState* Ext2Node::m_State
protected

Definition at line 177 of file Ext2Node.h.


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