Orion
Barry Importing existing Orion kernel d41a53c (3 years, 2 months ago)
#ifndef KERNEL_VFS_EXT2FS_H
#define KERNEL_VFS_EXT2FS_H
#include "../vfs.h"
typedef struct Ext2Super Ext2Super;
typedef struct Ext2BlockGroupDesc Ext2BlockGroupDesc;
typedef struct Ext2Inode Ext2Inode;
typedef struct Ext2DirEntry Ext2DirEntry;
/* 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));
/* Operations */
extern SuperOps ext2fsSuperOps;
extern InodeOps ext2fsInodeOps;
extern FileOps ext2fsFileOps;
extern FileSystemType ext2fsType;
void ext2_read_vnode(SuperBlock *super, uint32_t index, Inode *res);
void ext2_read_inode(SuperBlock *super, uint32_t index, Ext2Inode *res);
void ext2_read_block(SuperBlock *super, uint32_t index, char *buf);
uint32_t ext2_get_data_addr(SuperBlock *super, Ext2Inode *node, uint32_t index);
#endif