/*
- * 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 <acess.h>
}
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;
}
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;
}
}
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;
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;
}