X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fvfs%2Fmemfile.c;h=14b39481d0c82d7adc503d605ace864855f27ead;hb=5f2024e5977e0cca0993a20dad5ab794c94d5711;hp=3c756713e52faea441b0d0e143bb05ec0a2e7486;hpb=4ab9a574c9301d9590c91209f62c348e1d8c8883;p=tpg%2Facess2.git diff --git a/Kernel/vfs/memfile.c b/Kernel/vfs/memfile.c index 3c756713..14b39481 100644 --- a/Kernel/vfs/memfile.c +++ b/Kernel/vfs/memfile.c @@ -7,27 +7,26 @@ #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 '$' @@ -73,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; } @@ -110,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; } @@ -119,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; @@ -132,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; }