X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fvfs%2Fio.c;h=24aa78baa44a7152169744319ca75e7f8de4b7dd;hb=cfe799a87802878b22f3c1c71007c722696af4dc;hp=dc55fe2ac856fed44df6579804383140fba70aaf;hpb=e4342ad9de52043cb8f820643794dc44076f9bd9;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/vfs/io.c b/KernelLand/Kernel/vfs/io.c index dc55fe2a..24aa78ba 100644 --- a/KernelLand/Kernel/vfs/io.c +++ b/KernelLand/Kernel/vfs/io.c @@ -18,7 +18,7 @@ size_t VFS_Read(int FD, size_t Length, void *Buffer) tVFS_Handle *h; size_t ret; - ENTER("iFD XLength pBuffer", FD, Length, Buffer); + ENTER("xFD xLength pBuffer", FD, Length, Buffer); h = VFS_GetHandle(FD); if(!h) { @@ -41,16 +41,18 @@ size_t VFS_Read(int FD, size_t Length, void *Buffer) } if( !MM_GetPhysAddr(h->Node->Type->Read) ) { - Log_Error("VFS", "Node type %p(%s) read method is junk %p", h->Node->Type, h->Node, h->Node->Type->TypeName, + Log_Error("VFS", "Node type %p(%s) read method is junk %p", + h->Node->Type, h->Node, h->Node->Type->TypeName, h->Node->Type->Read); LEAVE_RET('i', -1); } + LOG("Position=%llx", h->Position); ret = h->Node->Type->Read(h->Node, h->Position, Length, Buffer); if(ret == (size_t)-1) LEAVE_RET('i', -1); h->Position += ret; - LEAVE('X', ret); + LEAVE('x', ret); return ret; } @@ -97,10 +99,19 @@ size_t VFS_Write(int FD, size_t Length, const void *Buffer) h = VFS_GetHandle(FD); if(!h) return -1; - if( !(h->Mode & VFS_OPENFLAG_WRITE) ) return -1; - if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) return -1; + if( !(h->Mode & VFS_OPENFLAG_WRITE) ) { + LOG("FD%i not opened for writing", FD); + return -1; + } + if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) { + LOG("FD%i is a director", FD); + return -1; + } - if( !h->Node->Type || !h->Node->Type->Write ) return 0; + if( !h->Node->Type || !h->Node->Type->Write ) { + LOG("FD%i has no write method", FD); + return 0; + } if( !MM_GetPhysAddr(h->Node->Type->Write) ) { Log_Error("VFS", "Node type %p(%s) write method is junk %p", h->Node->Type, h->Node, h->Node->Type->TypeName, @@ -170,11 +181,9 @@ int VFS_Seek(int FD, Sint64 Offset, int Whence) h = VFS_GetHandle(FD); if(!h) return -1; - //Log_Debug("VFS", "VFS_Seek: (fd=0x%x, Offset=0x%llx, Whence=%i)", - // FD, Offset, Whence); - // Set relative to current position if(Whence == 0) { + LOG("(FD%x)->Position += %lli", FD, Offset); h->Position += Offset; return 0; } @@ -183,11 +192,13 @@ int VFS_Seek(int FD, Sint64 Offset, int Whence) if(Whence < 0) { if( h->Node->Size == (Uint64)-1 ) return -1; + LOG("(FD%x)->Position = %llx - %llx", FD, h->Node->Size, Offset); h->Position = h->Node->Size - Offset; return 0; } // Set relative to start of file + LOG("(FD%x)->Position = %llx", FD, Offset); h->Position = Offset; return 0; }