// Mark some flags
if( pipe->ReadPos == pipe->WritePos ) {
+ LOG("%i == %i, marking none to read", pipe->ReadPos, pipe->WritePos);
VFS_MarkAvaliable(Node, 0);
}
VFS_MarkFull(Node, 0); // Buffer can't still be full
while(remaining)
{
// Wait for buffer to empty
- if(pipe->Flags & PF_BLOCKING) {
- if( pipe->ReadPos == (pipe->WritePos+1)%pipe->BufSize )
+ if(pipe->Flags & PF_BLOCKING)
+ {
+ if( pipe->ReadPos == (pipe->WritePos+1)%pipe->BufSize ) {
+ LOG("Blocking write on FIFO");
VFS_SelectNode(Node, VFS_SELECT_WRITE, NULL, "FIFO_Write");
+ }
len = remaining;
if( pipe->ReadPos > pipe->WritePos )
if(len > pipe->BufSize - pipe->WritePos)
{
int ofs = pipe->BufSize - pipe->WritePos;
+ LOG("pipe->Buffer = %p, pipe->WritePos = %i, ofs=%i, len=%i",
+ pipe->Buffer, pipe->WritePos, ofs, len);
memcpy(&pipe->Buffer[pipe->WritePos], Buffer, ofs);
- memcpy(&pipe->Buffer, (Uint8*)Buffer + ofs, len-ofs);
+ memcpy(&pipe->Buffer[0], (Uint8*)Buffer + ofs, len-ofs);
}
else
{
+ LOG("pipe->Buffer = %p, pipe->WritePos = %i", pipe->Buffer, pipe->WritePos);
memcpy(&pipe->Buffer[pipe->WritePos], Buffer, len);
}
// Mark some flags
if( pipe->ReadPos == pipe->WritePos ) {
+ LOG("Buffer is full");
VFS_MarkFull(Node, 1); // Buffer full
}
VFS_MarkAvaliable(Node, 1);
ret = calloc(1, allocsize);
if(!ret) LEAVE_RET('n', NULL);
- // Clear Return
+ // Set default flags
ret->Flags = PF_BLOCKING;
// Allocate Buffer