37 FATAL(
"reading superblock failed: result = " << (
int) e);
43 FATAL(
"magic mismatch");
62 FATAL(
"reading group descriptor failed: result = " << (
int) e);
80 NOTICE(
"mounted at " << p);
114 ERROR(
"reading inode failed: result = " << (
int) e);
124 return (*
groups)[groupNum];
134 Size & numContiguous)
147 const u32 offsetBlock = inode->
block[blk];
152 if (inode->
block[i] == offsetBlock + numContiguous)
189 for (
Size i = 0; i < depth - 1; i++)
211 for (
Size i = blk + 1; i < numBlocks && (i % numPerBlock) != 0; i++)
virtual bool contains(const K &key) const
Check if the given key exists.
Abstract filesystem class.
void setRoot(Directory *newRoot)
Change the filesystem root directory.
void sendResponse(FileSystemMessage *msg) const
Send response for a FileSystemMessage.
virtual const V value(const K &key, const V defaultValue=V()) const
Return the first value for the given key.
virtual bool insert(const K &key, const V &value)
Inserts the given item to the HashTable.
Represents an directory on a LinnFS filesystem.
void notSupportedHandler(FileSystemMessage *msg)
Callback handler for unsupported operations.
LinnInode * getInode(u32 inodeNum)
Read an inode from the filesystem.
LinnSuperBlock super
Describes the filesystem.
Storage * storage
Provides storage.
LinnGroup * getGroupByInode(u32 inodeNum)
Read a group descriptor from the filesystem, given an inode number.
LinnFileSystem(const char *path, Storage *storage)
Class constructor function.
Vector< LinnGroup * > * groups
Group descriptors.
LinnGroup * getGroup(u32 groupNum)
Read a group descriptor from the filesystem.
u64 getOffsetRange(const LinnInode *inode, const u32 blk, Size &numContiguous)
Calculates the offset inside storage for a given block.
HashTable< u32, LinnInode * > inodes
Inode cache.
virtual void fill(T value)
Fill the Sequence with the given value.
Provides a storage device to build filesystems on top.
virtual FileSystem::Result read(const u64 offset, void *buffer, const Size size) const =0
Read a contiguous set of data.
Vectors are dynamically resizeable Arrays.
virtual int insert(const T &item)
Adds the given item to the Vector, if possible.
#define assert(exp)
Insert program diagnostics.
#define NULL
NULL means zero.
unsigned int u32
Unsigned 32-bit number.
#define INFO(msg)
Output a regular message to standard output.
#define ERROR(msg)
Output an error message.
#define NOTICE(msg)
Output a notice message.
#define FATAL(msg)
Output a critical message and terminate program immediatly.
unsigned int Size
Any sane size indicator cannot go negative.
unsigned long long u64
Unsigned 64-bit number.
#define LINN_MAX_BLOCK_SIZE
Maximum blocksize.
#define LINN_SUPER_MAGIC1
Second magic number (randomly chosen bytes).
#define LINN_SUPER_MAGIC0
First magic number ('Linn').
#define LINN_INODE_DIR_BLOCKS
Direct blocks.
#define LINN_GROUP_COUNT(sb)
Calculate the number of LinnGroups in a filesystem.
#define LINN_SUPER_OFFSET
Fixed offset in storage of the superblock.
#define LINN_INODE_ROOT
Root inode.
#define LINN_SUPER_NUM_PTRS(sb)
Calculate the number of block address pointers fitting in one block.
#define LINN_INODE_NUM_BLOCKS(super, inode)
Calculate the number of blocks used in an LinnInode.
Result
Result code for filesystem Actions.
FileSystem::Result result
Result code.
Structure of a group descriptor.
le32 inodeTable
Inode table contains pre-allocated inodes.
Structure of an inode on the disk in the LinnFS filesystem.
le32 block[LINN_INODE_BLOCKS]
Pointers to blocks.
le32 groupsTable
Block address of the LinnGroup table.
le32 inodesCount
Total number of inodes.
le32 magic0
Allows detection of valid superblocks.
le32 freeInodesCount
Free inodes remaining.
le32 blockSize
Size of each data block.
le32 magic1
Allows detection of valid superblocks.
le32 inodesPerGroup
Number of inodes per group.
le32 blocksCount
Total number of data blocks.
le32 freeBlocksCount
Number of free data blocks.