From: John Hodge Date: Sat, 24 Apr 2010 13:26:56 +0000 (+0800) Subject: Fixed SYS_SEEK not working due to 64-bit offset X-Git-Tag: rel0.06~215 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=f9c3c4a68ba22b00df9441631a8513198c8859a5;p=tpg%2Facess2.git Fixed SYS_SEEK not working due to 64-bit offset --- diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index c677bc0f..8255f6c7 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -353,6 +353,7 @@ Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) { tVTerm *term = &gVT_Terminals[ Node->Inode ]; + int size; // Write switch( term->Mode ) @@ -361,6 +362,19 @@ Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) VT_int_PutString(term, Buffer, Length); break; case TERM_MODE_FB: + size = term->Width*term->Height*4; + if( Offset > size ) { + Log_Notice("VTerm", "VT_Write: Offset (0x%llx) > FBSize (0x%x)", + Offset, size); + return 0; + } + + if( Offset + Length > size ) { + Log_Notice("VTerm", "VT_Write: Offset+Length (0x%llx) > FBSize (0x%x)", + Offset+Length, size); + Length = size - Offset; + } + memcpy( (void*)((Uint)term->Buffer + (Uint)Offset), Buffer, Length ); if( Node->Inode == giVT_CurrentTerminal ) @@ -428,6 +442,7 @@ int VT_Terminal_IOCtl(tVFS_Node *Node, int Id, void *Data) case TERM_IOCTL_MODETYPE: if(Data != NULL) { + Log_Log("VTerm", "VTerm %i mode set to %i", (int)Node->Inode, *iData); // Update mode if needed if(term->Mode != *iData) VT_int_ChangeMode(term, *iData); @@ -454,6 +469,8 @@ int VT_Terminal_IOCtl(tVFS_Node *Node, int Id, void *Data) return term->Height; case TERM_IOCTL_FORCESHOW: + Log_Log("VTerm", "Thread %i forced VTerm %i to be shown", + Threads_GetTID(), (int)Node->Inode); VT_SetTerminal( Node->Inode ); LEAVE('i', 1); return 1; @@ -1006,9 +1023,11 @@ void VT_int_ChangeMode(tVTerm *Term, int NewMode) Term->Text = calloc( Term->Width*Term->Height*VT_SCROLLBACK, sizeof(tVT_Char) ); break; case TERM_MODE_FB: - Log_Log("VTerm", "Set VT %p to framebuffer mode", Term); + Log_Log("VTerm", "Set VT %p to framebuffer mode (%ix%i)", Term, + Term->Width, Term->Height); free(Term->Text); Term->Buffer = calloc( Term->Width*Term->Height, sizeof(Uint32) ); + Log_Debug("VTerm", "Term->Buffer = %p", Term->Buffer); break; //case TERM_MODE_2DACCEL: //case TERM_MODE_3DACCEL: diff --git a/Kernel/syscalls.c b/Kernel/syscalls.c index b49b4d6c..ab8c1c93 100644 --- a/Kernel/syscalls.c +++ b/Kernel/syscalls.c @@ -198,7 +198,11 @@ void SyscallHandler(tSyscallRegs *Regs) break; case SYS_SEEK: + #if BITS == 64 ret = VFS_Seek( Regs->Arg1, Regs->Arg2, Regs->Arg3 ); + #else + ret = VFS_Seek( Regs->Arg1, Regs->Arg2|((Uint64)Regs->Arg3<<64), Regs->Arg4 ); + #endif break; case SYS_TELL: diff --git a/Kernel/vfs/io.c b/Kernel/vfs/io.c index 8ff15f56..f2d47ce1 100644 --- a/Kernel/vfs/io.c +++ b/Kernel/vfs/io.c @@ -103,7 +103,7 @@ Uint64 VFS_Write(int FD, Uint64 Length, void *Buffer) /** * \fn Uint64 VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer) - * \brief Write data to a file at a given offset (atomic) + * \brief Write data to a file at a given offset */ Uint64 VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer) { @@ -150,6 +150,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) { h->Position += Offset;