18#include <FreeNOS/User.h>
27 , m_inodeData(inodeData)
43 Size bytes = 0, blockNr = 0, blockCount;
44 u64 storageOffset, copyOffset = offset;
50 while ((sb->
blockSize * (blockNr + 1)) <= copyOffset)
59 while (blockNr < inodeNumBlocks && total < size && m_inodeData->size - (offset + total) > 0)
65 bytes = (blockCount * sb->
blockSize) - copyOffset;
74 if (bytes > size - total)
90 blockNr += blockCount;
Represents a file present on a FileSystem.
FileSystem::FileModes m_access
Access permissions.
Size m_size
Size of the file, in bytes.
Abstract Input/Output buffer.
void addCount(const Size bytes)
Increment byte counter.
u8 * getBuffer()
Get raw buffer.
Linnenbank FileSystem (LinnFS).
LinnSuperBlock * getSuperBlock()
Retrieve the superblock pointer.
Storage * getStorage()
Get the underlying Storage object.
u64 getOffsetRange(const LinnInode *inode, const u32 blk, Size &numContiguous)
Calculates the offset inside storage for a given block.
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read bytes from the file.
virtual ~LinnFile()
Destructor function.
LinnFileSystem * m_fs
Filesystem pointer.
LinnFile(LinnFileSystem *fs, const u32 inode, LinnInode *inodeData)
Constructor function.
LinnInode * m_inodeData
Inode pointer.
virtual FileSystem::Result read(const u64 offset, void *buffer, const Size size) const =0
Read a contiguous set of data.
#define assert(exp)
Insert program diagnostics.
unsigned int u32
Unsigned 32-bit number.
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_INODE_NUM_BLOCKS(super, inode)
Calculate the number of blocks used in an LinnInode.
Result
Result code for filesystem Actions.
Structure of an inode on the disk in the LinnFS filesystem.
le16 mode
Access permissions, as an FileMode.
Linnenbank Filesystem (LinnFS) super block.
le32 blockSize
Size of each data block.