X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fvfs%2Fio.c;h=f5b16cc1cc39f58f18a37e3c43fc5408ca442250;hb=5dc3cea45b3cb43e26a6ed51e98f923a9fd73d92;hp=24aa78baa44a7152169744319ca75e7f8de4b7dd;hpb=27cb4fff4ed854d8be598a1157265c6de8aa035a;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/vfs/io.c b/KernelLand/Kernel/vfs/io.c index 24aa78ba..f5b16cc1 100644 --- a/KernelLand/Kernel/vfs/io.c +++ b/KernelLand/Kernel/vfs/io.c @@ -1,6 +1,11 @@ /* - * AcessMicro VFS - * - File IO Passthru's + * Acess2 Kernel + * - By John Hodge (thePowersGang) + * + * vfs/io.c + * - VFS IO Handling (Read/Write) + * + * TODO: VFS-level caching to support non-blocking IO? */ #define DEBUG 0 #include @@ -48,7 +53,9 @@ size_t VFS_Read(int FD, size_t Length, void *Buffer) } LOG("Position=%llx", h->Position); - ret = h->Node->Type->Read(h->Node, h->Position, Length, Buffer); + Uint flags = 0; + flags |= (h->Mode & VFS_OPENFLAG_NONBLOCK) ? VFS_IOFLAG_NOBLOCK : 0; + ret = h->Node->Type->Read(h->Node, h->Position, Length, Buffer, flags); if(ret == (size_t)-1) LEAVE_RET('i', -1); h->Position += ret; @@ -77,12 +84,15 @@ size_t VFS_ReadAt(int FD, Uint64 Offset, 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->Type->TypeName, h->Node->Type->Read); LEAVE_RET('i', -1); } - ret = h->Node->Type->Read(h->Node, Offset, Length, Buffer); + Uint flags = 0; + flags |= (h->Mode & VFS_OPENFLAG_NONBLOCK) ? VFS_IOFLAG_NOBLOCK : 0; + ret = h->Node->Type->Read(h->Node, Offset, Length, Buffer, flags); if(ret == (size_t)-1) return -1; return ret; } @@ -114,12 +124,15 @@ size_t VFS_Write(int FD, size_t Length, const void *Buffer) } 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, + Log_Error("VFS", "Node type %p(%s) write method is junk %p", + h->Node->Type, h->Node->Type->TypeName, h->Node->Type->Write); return -1; } - ret = h->Node->Type->Write(h->Node, h->Position, Length, Buffer); + Uint flags = 0; + flags |= (h->Mode & VFS_OPENFLAG_NONBLOCK) ? VFS_IOFLAG_NOBLOCK : 0; + ret = h->Node->Type->Write(h->Node, h->Position, Length, Buffer, flags); if(ret == (size_t)-1) return -1; h->Position += ret; @@ -144,11 +157,14 @@ size_t VFS_WriteAt(int FD, Uint64 Offset, size_t Length, const void *Buffer) if(!h->Node->Type || !h->Node->Type->Write) 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, + Log_Error("VFS", "Node type %p(%s) write method is junk %p", + h->Node->Type, h->Node->Type->TypeName, h->Node->Type->Write); return -1; } - ret = h->Node->Type->Write(h->Node, Offset, Length, Buffer); + Uint flags = 0; + flags |= (h->Mode & VFS_OPENFLAG_NONBLOCK) ? VFS_IOFLAG_NOBLOCK : 0; + ret = h->Node->Type->Write(h->Node, Offset, Length, Buffer, flags); if(ret == (size_t)-1) return -1; return ret; }