/* * fileio.h * * Created on: Aug 23, 2011 * Author: Tiberiu */ #ifndef FILEIO_H_ #define FILEIO_H_ #include enum FsFlags { FsFile = 0x1, FsDirectory = 0x2, FsCharDevice = 0x3, FsBlockDevice = 0x4, FsPipe = 0x5, FsSymbolLink = 0x6, FsMountPoint = 0x8 }; typedef uint32 (*ReadRoutine)(struct _FsNode*, uint32, uint32, uint8*); typedef uint32 (*WriteRoutine)(struct _FsNode*, uint32, uint32, uint8*); typedef void (*OpenRoutine)(struct _FsNode*); typedef void (*CloseRoutine)(struct _FsNode*); typedef struct _DirectoryEntry (*ReadDirRoutine)(struct _FsNode*,uint32); typedef struct _FsNode* (*FindDirRoutine)(struct _FsNode*,char *name); typedef struct _FsNode { char Name[128]; // The filename. uint32 Permissions; // The permissions mask. uint32 UserId; // The owning user. uint32 GroupId; // The owning group. uint32 Flags; // Includes the node type. See enum above. uint32 INode; // This is device-specific - provides a way for a filesystem to identify files. uint32 Length; // Size of the file, in bytes. uint32 Implementation; // An implementation-defined number. ReadRoutine Read; WriteRoutine Write; OpenRoutine Open; CloseRoutine Close; ReadDirRoutine ReadDir; FindDirRoutine FindDir; struct _FsNode *Ptr; // Used by mountpoints and symlinks. } FsNode; typedef struct _DirectoryEntry { char Name[128]; uint32 INode; } DirectoryEntry; extern uint32 FsRead(FsNode *node, uint32 offset, uint32 size, uint8 *buffer); extern uint32 FsWrite(FsNode *node, uint32 offset, uint32 size, uint8 *buffer); extern void FsOpen(FsNode *node, uint8 read, uint8 write); extern void FsClose(FsNode *node); extern DirectoryEntry *FsReadDir(FsNode *node, uint32 index); extern FsNode *FsFindDir(FsNode *node, char *name); #ifdef NEVER void VfsRegisterFilesys(); void VfsMount(); #endif #endif /* FILEIO_H_ */