BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / blob / master / vfs / ext2fs / ext2fs.h

// Related

Nucleus

Barry Read-only Ext2 file system driver 648c56b (3 years, 2 months ago)
#ifndef VFS_EXT2FS_H
#define VFS_EXT2FS_H

/* Structure of the ext2 superblock */
struct Ext2Super {
	uint32_t numInodes;
	uint32_t numBlocks;
	uint32_t reservedBlocks;
	uint32_t unallocBlocks;
	uint32_t unallocInodes;
	uint32_t superBlock;
	uint32_t blockSize;
	uint32_t fragSize;
	uint32_t blocksPerGroup;
	uint32_t fragsPerGroup;
	uint32_t inodesPerGroup;
	uint32_t lastMountTime;
	uint32_t lastWriteTime;
	uint16_t lastCheck;
	uint16_t mustCheck;
	uint16_t signature;
	uint16_t state;
	uint16_t error;
	uint16_t verMinor;
	uint32_t lastCheckTime;
	uint32_t checkInterval;
	uint32_t creator;
	uint32_t verMajor;
	uint16_t uid, gid;
	/* Extended fields */
	uint32_t firstAvailInode;
	uint16_t inodeSize;
	uint16_t blockGroup;
	uint32_t optionalFeatures;
	uint32_t requiredFeatures;
	uint32_t writableFeatures;
	char fsId[16];
	char volumeName[16];
	char lastPath[64];
	uint32_t compression;
	uint8_t preallocFileBlocks;
	uint8_t preallocDirBlocks;
	uint16_t unused;
	char journalId[16];
	uint32_t journalInode;
	uint32_t journalDev;
	uint32_t orphanHead;
} __attribute__((packed));

/* Structure of the ext2 block group descriptor */
struct Ext2BlockGroupDesc {
	uint32_t blockUsage;
	uint32_t inodeUsage;
	uint32_t inodeTable;
	uint16_t unallocBlocks;
	uint16_t unallocInodes;
	uint16_t numDirs;
} __attribute__((packed));

/* Structure of the ext2 inode */
struct Ext2Inode {
	uint16_t type;
	uint16_t uid;
	uint32_t lsize;
	uint32_t lastAccessTime;
	uint32_t creationTime;
	uint32_t lastWriteTime;
	uint32_t deletionTime;
	uint16_t gid;
	uint16_t numHardLinks;
	uint32_t numSectors;
	uint32_t flags;
	uint32_t osA;
	uint32_t directBlock[12];
	uint32_t singleBlock;
	uint32_t doubleBlock;
	uint32_t tripleBlock;
	uint32_t gen;
	uint32_t attr;
	union {
		uint32_t usize;
		uint32_t dirACL;
	};
	uint32_t fragment;
	uint32_t osB[3];
} __attribute__((packed));

/* Structure of the ext2 directory entry */
struct Ext2DirEntry {
	uint32_t ino;
	uint16_t size;
	uint8_t namelen;
	uint8_t type;
	char name[];
} __attribute__((packed));

extern SuperOps ext2fsSuperOps;
extern InodeOps ext2fsInodeOps;
extern FileOps ext2fsFileOps;

void ext2fs_read_inode(SuperBlock *sb, uint32_t index, struct Ext2Inode *res);
void ext2fs_read_vnode(SuperBlock *sb, uint32_t index, Inode *res);
void ext2fs_read_block(SuperBlock *super, uint32_t index, char *buf);
uint32_t ext2fs_get_data_addr(SuperBlock *super, struct Ext2Inode *inode,
                              uint32_t index);

#endif