Modules/Ext2 - Fixed bugs in read/write support
[tpg/acess2.git] / KernelLand / Modules / Filesystems / Ext2 / ext2_common.h
1 /*
2  * Acess OS
3  * Ext2 Driver Version 1
4  */
5 #ifndef _EXT2_COMMON_H
6 #define _EXT2_COMMON_H
7 #include <acess.h>
8 #include <vfs.h>
9 #include "ext2fs.h"
10
11 #define EXT2_UPDATE_WRITEBACK   1
12
13 // === STRUCTURES ===
14 typedef struct {
15          int    FD;
16         tInodeCache     *CacheID;
17         tVFS_Node       RootNode;
18         tExt2_Inode     RootInode;
19         
20         tExt2_SuperBlock        SuperBlock;
21         Uint    BlockSize;
22          
23          int    GroupCount;
24         tExt2_Group             Groups[];
25 } tExt2_Disk;
26
27 // === GLOBALS ===
28 extern tVFS_NodeType    gExt2_FileType;
29 extern tVFS_NodeType    gExt2_DirType;
30
31 // === FUNCTIONS ===
32 // --- Common ---
33 extern void     Ext2_CloseFile(tVFS_Node *Node);
34 extern Uint64   Ext2_int_GetBlockAddr(tExt2_Disk *Disk, Uint32 *Blocks, int BlockNum);
35 extern void     Ext2_int_UpdateSuperblock(tExt2_Disk *Disk);
36 extern Uint32   Ext2_int_AllocateInode(tExt2_Disk *Disk, Uint32 Parent);
37 extern void     Ext2_int_DereferenceInode(tExt2_Disk *Disk, Uint32 Inode);
38 extern int      Ext2_int_ReadInode(tExt2_Disk *Disk, Uint32 InodeId, tExt2_Inode *Inode);
39 extern int      Ext2_int_WriteInode(tExt2_Disk *Disk, Uint32 InodeId, tExt2_Inode *Inode);
40 // --- Dir ---
41 extern int      Ext2_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]);
42 extern tVFS_Node        *Ext2_FindDir(tVFS_Node *Node, const char *FileName, Uint Flags);
43 extern tVFS_Node        *Ext2_MkNod(tVFS_Node *Node, const char *Name, Uint Mode);
44 extern int      Ext2_Link(tVFS_Node *Parent, const char *Name, tVFS_Node *Node);
45 extern tVFS_Node        *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeId);
46 extern int      Ext2_int_WritebackNode(tExt2_Disk *Disk, tVFS_Node *Node);
47 // --- Read ---
48 extern size_t   Ext2_Read(tVFS_Node *node, off_t offset, size_t length, void *buffer, Uint Flags);
49 // --- Write ---
50 extern size_t   Ext2_Write(tVFS_Node *node, off_t offset, size_t length, const void *buffer, Uint Flags);
51 extern Uint32   Ext2_int_AllocateBlock(tExt2_Disk *Disk, Uint32 LastBlock);
52 extern void     Ext2_int_DeallocateBlock(tExt2_Disk *Disk, Uint32 Block);
53 extern int      Ext2_int_AppendBlock(tVFS_Node *Node, tExt2_Inode *Inode, Uint32 Block);
54
55 #endif

UCC git Repository :: git.ucc.asn.au