KernelLand - Better node chaching code
[tpg/acess2.git] / KernelLand / Kernel / drv / pty.c
index ace6c53..8f4302d 100644 (file)
@@ -104,7 +104,8 @@ tDevFS_Driver       gPTY_Driver = {
        .Name = "pts",
        .RootNode = {
                .Flags = VFS_FFLAG_DIRECTORY,
-               .Type = &gPTY_NodeType_Root
+               .Type = &gPTY_NodeType_Root,
+               .Size = -1
        }
 };
  int   giPTY_NumCount;
@@ -230,8 +231,7 @@ int PTY_SetAttrib(tPTY *PTY, const struct ptydims *Dims, const struct ptymode *M
                        errno = EINVAL;
                        return -1;
                }
-               PTY->Mode = *Mode;
-               if( !WasClient )
+               if( WasClient )
                {
                        if( PTY->ModeSet && PTY->ModeSet(PTY->OutputHandle, Mode) )
                        {
@@ -245,10 +245,17 @@ int PTY_SetAttrib(tPTY *PTY, const struct ptydims *Dims, const struct ptymode *M
                                // ACK by server doing GETMODE
                        }
                }
+               else
+               {
+                       // Should the client be informed that the server just twiddled the modes?
+               }
+               LOG("PTY %p mode set to {0%o, 0%o}", PTY, Mode->InputMode, Mode->OutputMode);
+               PTY->Mode = *Mode;
        }
        if( Dims )
        {
-               if( WasClient ) {
+               if( WasClient )
+               {
                        // Poke the server?
                        if( PTY->ReqResize && PTY->ReqResize(PTY->OutputHandle, Dims) )
                        {
@@ -260,9 +267,11 @@ int PTY_SetAttrib(tPTY *PTY, const struct ptydims *Dims, const struct ptymode *M
                                // Inform server process... somehow
                        }
                }
-               else {
+               else
+               {
                        // SIGWINSZ to client
                }
+               LOG("PTY %p dims set to %ix%i", PTY, Dims->W, Dims->H);
                PTY->Dims = *Dims;
        }
        return 0;
@@ -426,37 +435,42 @@ size_t PTY_SendInput(tPTY *PTY, const char *Input, size_t Length)
 int PTY_ReadDir(tVFS_Node *Node, int Pos, char Name[FILENAME_MAX])
 {
        tPTY    *pty = NULL;
-       if( Pos < giPTY_NumCount * 2 )
+        int    idx = Pos;
+       if( idx < giPTY_NumCount * 2 )
        {
                RWLock_AcquireRead(&glPTY_NumPTYs);
                for( pty = gpPTY_FirstNumPTY; pty; pty = pty->Next )
                {
-                       if( Pos < 2 )
+                       if( idx < 2 )
                                break;
-                       Pos -= 2;
+                       idx -= 2;
                }
                RWLock_Release(&glPTY_NumPTYs);
        }
-       else if( Pos < (giPTY_NumCount + giPTY_NamedCount) * 2 )
+       else if( idx < (giPTY_NumCount + giPTY_NamedCount) * 2 )
        {
+               idx -= giPTY_NumCount*2;
                RWLock_AcquireRead(&glPTY_NamedPTYs);
                for( pty = gpPTY_FirstNamedPTY; pty; pty = pty->Next )
                {
-                       if( Pos < 2 )
+                       if( idx < 2 )
                                break;
-                       Pos -= 2;
+                       idx -= 2;
                }
                RWLock_Release(&glPTY_NamedPTYs);
        }
        
 
-       if( !pty )
+       if( !pty ) {
+               LOG("%i out of range", Pos);
                return -1;
+       }
        
        if( pty->Name[0] )
-               snprintf(Name, FILENAME_MAX, "%s%c", pty->Name, (Pos == 0 ? 'c' : 's'));
+               snprintf(Name, FILENAME_MAX, "%s%c", pty->Name, (idx == 0 ? 'c' : 's'));
        else
-               snprintf(Name, FILENAME_MAX, "%i%c", pty->NumericName, (Pos == 0 ? 'c' : 's'));
+               snprintf(Name, FILENAME_MAX, "%i%c", pty->NumericName, (idx == 0 ? 'c' : 's'));
+       LOG("Return '%s'", Name);
        return 0;
 }
 

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