Kernel - Debugging AxWin3 error
authorJohn Hodge <[email protected]>
Sun, 15 Jul 2012 04:49:09 +0000 (12:49 +0800)
committerJohn Hodge <[email protected]>
Sun, 15 Jul 2012 04:49:09 +0000 (12:49 +0800)
KernelLand/Kernel/drv/vterm.c
KernelLand/Kernel/vfs/io.c

index 7d30511..a6a1c66 100644 (file)
@@ -353,8 +353,7 @@ 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)
 {
-        int    pos = 0;
-        int    avail;
+        int    pos, avail;
        tVTerm  *term = &gVT_Terminals[ Node->Inode ];
        Uint32  *codepoint_buf = Buffer;
        Uint32  *codepoint_in;
@@ -373,9 +372,10 @@ size_t VT_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
                avail = term->InputWrite - term->InputRead;
                if(avail < 0)
                        avail += MAX_INPUT_CHARS8;
-               if(avail > Length - pos)
-                       avail = Length - pos;
+               if(avail > Length)
+                       avail = Length;
                
+               pos = 0;
                while( avail -- )
                {
                        ((char*)Buffer)[pos] = term->InputBuffer[term->InputRead];
@@ -395,12 +395,13 @@ size_t VT_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
                if(avail < 0)
                        avail += MAX_INPUT_CHARS32;
                Length /= 4;
-               if(avail > Length - pos)
-                       avail = Length - pos;
+               if(avail > Length)
+                       avail = Length;
                
                codepoint_in = (void*)term->InputBuffer;
                codepoint_buf = Buffer;
                
+               pos = 0;
                while( avail -- )
                {
                        codepoint_buf[pos] = codepoint_in[term->InputRead];
index e7a2a06..dacf720 100644 (file)
@@ -20,12 +20,24 @@ Uint64 VFS_Read(int FD, Uint64 Length, void *Buffer)
        ENTER("iFD XLength pBuffer", FD, Length, Buffer);
        
        h = VFS_GetHandle(FD);
-       if(!h)  LEAVE_RET('i', -1);
+       if(!h) {
+               LOG("Bad Handle");
+               LEAVE_RET('i', -1);
+       }
        
-       if( !(h->Mode & VFS_OPENFLAG_READ) || h->Node->Flags & VFS_FFLAG_DIRECTORY )
+       if( !(h->Mode & VFS_OPENFLAG_READ) ) {
+               LOG("Bad mode");
+               LEAVE_RET('i', -1);
+       }
+       if( (h->Node->Flags & VFS_FFLAG_DIRECTORY) ) {
+               LOG("Reading directory");
                LEAVE_RET('i', -1);
+       }
 
-       if(!h->Node->Type || !h->Node->Type->Read)      LEAVE_RET('i', 0);
+       if(!h->Node->Type || !h->Node->Type->Read) {
+               LOG("No read method");
+               LEAVE_RET('i', -1);
+       }
        
        ret = h->Node->Type->Read(h->Node, h->Position, Length, Buffer);
        if(ret == -1)   LEAVE_RET('i', -1);

UCC git Repository :: git.ucc.asn.au