X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fdrv%2Fvterm.c;h=cf12ff96c832c68c613b15cc09af65475bc6afcd;hb=4d184c30a3385600c0d87a2f93b4259c8c973e73;hp=63db01e467385152389c4e3518f64488c3f2a214;hpb=e02f66c7125bf18f77c6c53587238cbd49da2c89;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/drv/vterm.c b/KernelLand/Kernel/drv/vterm.c index 63db01e4..cf12ff96 100644 --- a/KernelLand/Kernel/drv/vterm.c +++ b/KernelLand/Kernel/drv/vterm.c @@ -34,7 +34,7 @@ extern void Debug_SetKTerminal(const char *File); // === PROTOTYPES === int VT_Install(char **Arguments); -char *VT_ReadDir(tVFS_Node *Node, int Pos); + int VT_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]); tVFS_Node *VT_FindDir(tVFS_Node *Node, const char *Name); int VT_Root_IOCtl(tVFS_Node *Node, int Id, void *Data); size_t VT_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer); @@ -114,11 +114,11 @@ int VT_Install(char **Arguments) if( strcmp(opt, "Video") == 0 ) { if( !gsVT_OutputDevice ) - gsVT_OutputDevice = strdup(val); + gsVT_OutputDevice = val; } else if( strcmp(opt, "Input") == 0 ) { if( !gsVT_InputDevice ) - gsVT_InputDevice = strdup(val); + gsVT_InputDevice = val; } else if( strcmp(opt, "Width") == 0 ) { giVT_RealWidth = atoi( val ); @@ -129,6 +129,9 @@ int VT_Install(char **Arguments) else if( strcmp(opt, "Scrollback") == 0 ) { giVT_Scrollback = atoi( val ); } + else { + Log_Notice("VTerm", "Unknown option '%s'", opt); + } } } @@ -268,11 +271,12 @@ void VT_SetResolution(int Width, int Height) * \fn char *VT_ReadDir(tVFS_Node *Node, int Pos) * \brief Read from the VTerm Directory */ -char *VT_ReadDir(tVFS_Node *Node, int Pos) +int VT_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]) { - if(Pos < 0) return NULL; - if(Pos >= NUM_VTS) return NULL; - return strdup( gVT_Terminals[Pos].Name ); + if(Pos < 0) return -EINVAL; + if(Pos >= NUM_VTS) return -EINVAL; + strncpy(Dest, gVT_Terminals[Pos].Name, FILENAME_MAX); + return 0; } /** @@ -447,8 +451,8 @@ size_t VT_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer // - Sanity Checking size = term->Width*term->Height*4; if( Offset > size ) { - Log_Notice("VTerm", "VT_Write: Offset (0x%llx) > FBSize (0x%x)", - Offset, size); + Log_Notice("VTerm", "VT_Write: %i Offset (0x%llx) > FBSize (0x%x)", + (int)Node->Inode, Offset, size); return 0; } if( Offset + Length > size ) { @@ -512,7 +516,7 @@ size_t VT_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer break; } - return 0; + return Length; } /** @@ -733,11 +737,10 @@ void VT_SetTerminal(int ID) gpVT_CurTerm->Buffer = malloc( gpVT_CurTerm->Width*gpVT_CurTerm->Height*4 ); if( gpVT_CurTerm->Width < giVT_RealWidth ) { - int line; Uint ofs = 0; Uint32 *dest = gpVT_CurTerm->Buffer; // Slower scanline copy - for( line = 0; line < gpVT_CurTerm->Height; line ++ ) + for( int line = 0; line < gpVT_CurTerm->Height; line ++ ) { VFS_ReadAt(giVT_OutputDevHandle, ofs, gpVT_CurTerm->Width*4, dest); ofs += giVT_RealWidth * 4; @@ -751,6 +754,7 @@ void VT_SetTerminal(int ID) gpVT_CurTerm->Buffer ); } + LOG("Cached screen contents"); } // Update current terminal ID