X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fvfs%2Fmemfile.c;h=14b39481d0c82d7adc503d605ace864855f27ead;hb=5f2024e5977e0cca0993a20dad5ab794c94d5711;hp=2fc38e76846d57157ffff786870015f84db129ac;hpb=8bc40333b1401d7616b225945fee53d972c2f418;p=tpg%2Facess2.git diff --git a/Kernel/vfs/memfile.c b/Kernel/vfs/memfile.c index 2fc38e76..14b39481 100644 --- a/Kernel/vfs/memfile.c +++ b/Kernel/vfs/memfile.c @@ -1,30 +1,32 @@ -/* +/* + * Acess 2 + * Virtual File System + * - Memory Pseudo Files */ -#include +#include #include // === PROTOTYPES === -tVFS_Node *VFS_MemFile_Create(tVFS_Node *Unused, char *Path); +tVFS_Node *VFS_MemFile_Create(const char *Path); void VFS_MemFile_Close(tVFS_Node *Node); Uint64 VFS_MemFile_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); -Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); +Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer); // === GLOBALS === -tVFS_Node gVFS_MemRoot = { - .Flags = VFS_FFLAG_DIRECTORY, - .NumACLs = 0, - .FindDir = VFS_MemFile_Create +tVFS_NodeType gVFS_MemFileType = { + .Close = VFS_MemFile_Close, + .Read = VFS_MemFile_Read, + .Write = VFS_MemFile_Write }; // === CODE === /** - * \fn tVFS_Node *VFS_MemFile_Create(tVFS_Node *Unused, char *Path) - * \note Treated as finddir by VFS_ParsePath + * \fn tVFS_Node *VFS_MemFile_Create(const char *Path) */ -tVFS_Node *VFS_MemFile_Create(tVFS_Node *Unused, char *Path) +tVFS_Node *VFS_MemFile_Create(const char *Path) { Uint base, size; - char *str = Path; + const char *str = Path; tVFS_Node *ret; str++; // Eat '$' @@ -57,8 +59,6 @@ tVFS_Node *VFS_MemFile_Create(tVFS_Node *Unused, char *Path) // Check for NULL byte if(*str != '\0') return NULL; - Log(" VFS_MemFile_Create: base=0x%x, size=0x%x", base, size); - // Allocate and fill node ret = malloc(sizeof(tVFS_Node)); memset(ret, 0, sizeof(tVFS_Node)); @@ -72,9 +72,7 @@ tVFS_Node *VFS_MemFile_Create(tVFS_Node *Unused, char *Path) ret->ACLs = &gVFS_ACL_EveryoneRWX; // Functions - ret->Close = VFS_MemFile_Close; - ret->Read = VFS_MemFile_Read; - ret->Write = VFS_MemFile_Write; + ret->Type = &gVFS_MemFileType; return ret; } @@ -109,7 +107,7 @@ Uint64 VFS_MemFile_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buf Length = Node->Size - Offset; // Copy Data - memcpy(Buffer, Node->ImplPtr+Offset, Length); + memcpy(Buffer, (Uint8*)Node->ImplPtr + Offset, Length); return Length; } @@ -118,7 +116,7 @@ Uint64 VFS_MemFile_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buf * \fn Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) * \brief Write to a memory file */ -Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) +Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer) { // Check for use of free'd file if(Node->ImplPtr == NULL) return 0; @@ -131,7 +129,7 @@ Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Bu Length = Node->Size - Offset; // Copy Data - memcpy(Node->ImplPtr+Offset, Buffer, Length); + memcpy((Uint8*)Node->ImplPtr + Offset, Buffer, Length); return Length; }