Kernel - Changed PTY code to not expose userland server node as a file
[tpg/acess2.git] / KernelLand / Kernel / drv / pty.c
index 6dc8f94..8b63b11 100644 (file)
@@ -5,6 +5,7 @@
  * drv/pty.c
  * - Pseudo Terminals
  */
+#define DEBUG  0
 #include <acess.h>
 #include <vfs.h>
 #include <fs_devfs.h>
@@ -25,8 +26,11 @@ struct sPTY
        
        char    *Name;
         int    NumericName;
+       
        void    *OutputHandle;
        tPTY_OutputFcn  OutputFcn;
+       tPTY_ReqResize  ReqResize;
+       tPTY_ModeSet    ModeSet;
 
        struct ptymode  Mode;
        struct ptydims  Dims;
@@ -45,8 +49,8 @@ struct sPTY
         int    OutputReadPos;
        char    OutputData[OUTPUT_RINGBUFFER_LEN];
        
+       tVFS_Node       *ServerNode;
        tVFS_Node       ClientNode;
-       tVFS_Node       ServerNode;
        tVFS_ACL        OwnerRW;
        
        // TODO: Maintain list of client PIDs
@@ -64,26 +68,25 @@ size_t      PTY_int_SendInput(tPTY *PTY, const char *Input, size_t Length);
 // PTY_SendInput
 size_t PTY_ReadClient(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer, Uint Flags);
 size_t PTY_WriteClient(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer, Uint Flags);
- int   PTY_IOCtlClient(tVFS_Node *Node, int ID, void *Arg);
 void   PTY_ReferenceClient(tVFS_Node *Node);
 void   PTY_CloseClient(tVFS_Node *Node);
 size_t PTY_ReadServer(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer, Uint Flags);
 size_t PTY_WriteServer(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer, Uint Flags);
- int   PTY_IOCtlServer(tVFS_Node *Node, int ID, void *Arg);
 void   PTY_CloseServer(tVFS_Node *Node);
+ int   PTY_IOCtl(tVFS_Node *Node, int ID, void *Arg);
 
 // === GLOBALS ===
 MODULE_DEFINE(0, 0x100, PTY, PTY_Install, NULL, NULL);
 tVFS_NodeType  gPTY_NodeType_Root = {
        .TypeName = "PTY-Root",
        .ReadDir = PTY_ReadDir,
-       .FindDir = PTY_FindDir
+       .FindDir = PTY_FindDir,
 };
 tVFS_NodeType  gPTY_NodeType_Client = {
        .TypeName = "PTY-Client",
        .Read = PTY_ReadClient,
        .Write = PTY_WriteClient,
-       .IOCtl = PTY_IOCtlClient,
+       .IOCtl = PTY_IOCtl,
        .Reference = PTY_ReferenceClient,
        .Close = PTY_CloseClient
 };
@@ -91,8 +94,16 @@ tVFS_NodeType        gPTY_NodeType_Server = {
        .TypeName = "PTY-Server",
        .Read = PTY_ReadServer,
        .Write = PTY_WriteServer,
-       .IOCtl = PTY_IOCtlServer,
+       .IOCtl = PTY_IOCtl,
        .Close = PTY_CloseServer
+};
+tDevFS_Driver  gPTY_Driver = {
+       .Name = "pts",
+       .RootNode = {
+               .Flags = VFS_FFLAG_DIRECTORY,
+               .Type = &gPTY_NodeType_Root,
+               .Size = -1
+       }
 };
  int   giPTY_NumCount;
 tRWLock        glPTY_NumPTYs;
@@ -104,11 +115,12 @@ tPTY      *gpPTY_FirstNamedPTY;
 // === CODE ===
 int PTY_Install(char **Arguments)
 {
+       DevFS_AddDevice(&gPTY_Driver);
        return MODULE_ERR_OK;
 }
 
 // --- Management ---
-tPTY *PTY_Create(const char *Name, void *Handle, tPTY_OutputFcn Output)
+tPTY *PTY_Create(const char *Name, void *Handle, tPTY_OutputFcn Output, tPTY_ReqResize ReqResize, tPTY_ModeSet ModeSet)
 {
        tPTY    **prev_np = NULL;
        size_t  namelen;
@@ -152,10 +164,14 @@ tPTY *PTY_Create(const char *Name, void *Handle, tPTY_OutputFcn Output)
                                break;
                        idx ++;
                }
-               namelen = 0;
+               namelen = snprintf(NULL,0, "%u", idx);
        }
        
        tPTY *ret = calloc(sizeof(tPTY) + namelen + 1, 1);
+       if(!ret) {
+               errno = ENOMEM;
+               return NULL;
+       }
        
        // - List maintainance
        ret->Next = *prev_np;
@@ -165,19 +181,13 @@ tPTY *PTY_Create(const char *Name, void *Handle, tPTY_OutputFcn Output)
        if(Name)
                strcpy(ret->Name, Name);
        else
-               ret->Name[0] = 0;
+               sprintf(ret->Name, "%u", idx);
        ret->NumericName = idx;
        // - Output function and handle (same again)
        ret->OutputHandle = Handle;
        ret->OutputFcn = Output;
-       // - Server node
-       ret->ServerNode.ImplPtr = ret;
-       ret->ServerNode.Type = &gPTY_NodeType_Server;
-       ret->ServerNode.UID = Threads_GetUID();
-       ret->ServerNode.GID = Threads_GetGID();
-       ret->ServerNode.NumACLs = 1;
-       ret->ServerNode.ACLs = &ret->OwnerRW;
-       ret->ServerNode.ReferenceCount = (Output ? 1 : 0);      // Prevents a userland open/close killing a kernel pty
+       ret->ReqResize = ReqResize;
+       ret->ModeSet = ModeSet;
        // - Client node
        ret->ClientNode.ImplPtr = ret;
        ret->ClientNode.Type = &gPTY_NodeType_Client;
@@ -201,26 +211,59 @@ tPTY *PTY_Create(const char *Name, void *Handle, tPTY_OutputFcn Output)
        return ret;
 }
 
-void PTY_SetAttrib(tPTY *PTY, const struct ptydims *Dims, const struct ptymode *Mode, int WasClient)
+int PTY_SetAttrib(tPTY *PTY, const struct ptydims *Dims, const struct ptymode *Mode, int WasClient)
 {
-       if( Mode ) {
-               PTY->Mode = *Mode;
-               if( !WasClient && !PTY->OutputFcn )
+       if( Mode )
+       {
+               // (for now) userland terminals can't be put into framebuffer mode
+               if( !PTY->OutputFcn && (Mode->OutputMode & PTYOMODE_BUFFMT) == PTYBUFFMT_FB ) {
+                       errno = EINVAL;
+                       return -1;
+               }
+               if( WasClient )
                {
-                       Log_Warning("PTY", "TODO: Need to stop client output until modeset has been ACKed");
-                       // Block write until acked
-                       // ACK by server doing GETMODE
+                       if( PTY->ModeSet && PTY->ModeSet(PTY->OutputHandle, Mode) )
+                       {
+                               errno = EINVAL;
+                               return -1;
+                       }
+                       else if( !PTY->OutputFcn )
+                       {
+                               Log_Warning("PTY", "TODO: Need to stop client output until modeset has been ACKed");
+                               // Block write until acked
+                               // 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 ) {
-               PTY->Dims = *Dims;
-               if( WasClient ) {
+       if( Dims )
+       {
+               if( WasClient )
+               {
                        // Poke the server?
+                       if( PTY->ReqResize && PTY->ReqResize(PTY->OutputHandle, Dims) )
+                       {
+                               errno = EINVAL;
+                               return -1;
+                       }
+                       else if( !PTY->OutputFcn )
+                       {
+                               // 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;
 }
 
 void PTY_Close(tPTY *PTY)
@@ -230,8 +273,10 @@ void PTY_Close(tPTY *PTY)
 
 size_t _rb_write(void *buf, size_t buflen, int *rd, int *wr, const void *data, size_t len)
 {
-       size_t space = (*rd - *wr + buflen) % buflen - 1;
+       size_t space = (*rd - *wr + buflen - 1) % buflen;
+       ENTER("pbuf ibuflen prd pwr pdata ilen", buf, buflen, rd, wr, data, len);
        len = MIN(space, len);
+       LOG("space = %i, *rd = %i, *wr = %i", space, *rd, *wr);
        if(*wr + len >= buflen) {
                size_t prelen = buflen - *wr;
                memcpy((char*)buf + *wr, data, prelen);
@@ -242,6 +287,7 @@ size_t _rb_write(void *buf, size_t buflen, int *rd, int *wr, const void *data, s
                memcpy((char*)buf + *wr, data, len);
                *wr += len;
        }
+       LEAVE('i', len);
        return len;
 }
 size_t _rb_read(void *buf, size_t buflen, int *rd, int *wr, void *data, size_t len)
@@ -274,7 +320,7 @@ size_t PTY_int_WriteInput(tPTY *PTY, const char *Input, size_t Length)
 
        VFS_MarkAvaliable(&PTY->ClientNode, 1);
        if(ret < Length)
-               VFS_MarkFull(&PTY->ServerNode, 1);      
+               VFS_MarkFull(PTY->ServerNode, 1);       
 
        return ret;
 }
@@ -283,8 +329,9 @@ size_t PTY_int_SendInput(tPTY *PTY, const char *Input, size_t Length)
 {
        size_t  ret = 1, print = 1;
        
-       // Only counts for text input modes
-       if( (PTY->Mode.OutputMode & PTYOMODE_BUFFMT) == PTYBUFFMT_TEXT )
+       // Input mode stuff only counts for text output mode
+       // - Any other is Uint32 keypresses
+       if( (PTY->Mode.OutputMode & PTYOMODE_BUFFMT) != PTYBUFFMT_TEXT )
                return PTY_int_WriteInput(PTY, Input, Length);
        // If in raw mode, flush directlr
        if( (PTY->Mode.InputMode & PTYIMODE_RAW) )
@@ -297,6 +344,7 @@ size_t PTY_int_SendInput(tPTY *PTY, const char *Input, size_t Length)
                {
                case 3: // INTR - ^C
                        // TODO: Send SIGINT
+                       // Threads_PostSignalExt(PTY->ClientThreads, SIGINT);
                        print = 0;
                        break;
                case 4: // EOF - ^D
@@ -376,37 +424,30 @@ 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 )
        {
                RWLock_AcquireRead(&glPTY_NumPTYs);
-               for( pty = gpPTY_FirstNumPTY; pty; pty = pty->Next )
-               {
-                       if( Pos < 2 )
-                               break;
-                       Pos -= 2;
-               }
+               for( pty = gpPTY_FirstNumPTY; pty && idx; pty = pty->Next )
+                       idx --;
                RWLock_Release(&glPTY_NumPTYs);
        }
-       else if( Pos < (giPTY_NumCount + giPTY_NamedCount) * 2 )
+       else if( idx < (giPTY_NumCount + giPTY_NamedCount) )
        {
+               idx -= giPTY_NumCount;
                RWLock_AcquireRead(&glPTY_NamedPTYs);
-               for( pty = gpPTY_FirstNamedPTY; pty; pty = pty->Next )
-               {
-                       if( Pos < 2 )
-                               break;
-                       Pos -= 2;
-               }
+               for( pty = gpPTY_FirstNamedPTY; pty && idx; pty = pty->Next )
+                       idx --;
                RWLock_Release(&glPTY_NamedPTYs);
        }
-       
 
-       if( !pty )
+       if( !pty ) {
+               LOG("%i out of range", Pos);
                return -1;
-       
-       if( pty->Name[0] )
-               snprintf(Name, 255, "%s%c", pty->Name, (Pos == 0 ? 'c' : 's'));
-       else
-               snprintf(Name, 255, "%i%c", pty->NumericName, (Pos == 0 ? 'c' : 's'));
+       }
+
+       strncpy(Name, pty->Name, FILENAME_MAX)  
+       LOG("Return '%s'", Name);
        return 0;
 }
 
@@ -414,17 +455,19 @@ tVFS_Node *PTY_FindDir(tVFS_Node *Node, const char *Name, Uint Flags)
 {
        char    *end;
         int    num = strtol(Name, &end, 10);
+
+       if( strcmp(Name, "ptmx") == 0 ) {
+               tVFS_Node       *ret = calloc(sizeof(tVFS_Node), 1);
+               ret->Size = -1;
+               ret->Type = &gPTY_NodeType_Server;
+               return ret;
+       } 
        
-       if( Name[0] == '\0' || Name[1] == '\0' )
-               return NULL;
-       
-       size_t  len = strlen(Name);
-       if( Name[len-1] != 'c' && Name[len-1] != 's' )
+       if( Name[0] == '\0' )
                return NULL;
-        int    isServer = (Name[len-1] != 'c');
        
        tPTY    *ret = NULL;
-       if( num && (end[0] == 'c' || end[0] == 's') && end[1] == '\0' )
+       if( num && end[0] == '\0' )
        {
                // Numeric name
                RWLock_AcquireRead(&glPTY_NumPTYs);
@@ -445,18 +488,21 @@ tVFS_Node *PTY_FindDir(tVFS_Node *Node, const char *Name, Uint Flags)
                RWLock_AcquireRead(&glPTY_NamedPTYs);
                for( tPTY *pty = gpPTY_FirstNamedPTY; pty; pty = pty->Next )
                {
-                       int cmp = strncmp(pty->Name, Name, len-1);
+                       int cmp = strcmp(pty->Name, Name);
                        if(cmp > 0)
                                break;
-                       if(cmp == 0 && pty->Name[len-1] == '\0' ) {
+                       if(cmp == 0 ) {
                                ret = pty;
                                break;
                        }
                }
                RWLock_Release(&glPTY_NamedPTYs);
        }
-       if( ret )
-               return (isServer ? &ret->ServerNode : &ret->ClientNode);
+       if( ret ) {
+               tVFS_Node       *retnode = &ret->ClientNode;
+               retnode->ReferenceCount ++;
+               return retnode;
+       }
        else
                return NULL;
 }
@@ -470,6 +516,13 @@ size_t PTY_ReadClient(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer
        tTime   timeout_z = 0, *timeout = (Flags & VFS_IOFLAG_NOBLOCK) ? &timeout_z : NULL;
         int    rv;
 _select:
+       // If server has disconnected, return EIO
+       if( pty->ServerNode && pty->ServerNode->ReferenceCount == 0 ) {
+               //Threads_PostSignal(SIGPIPE);
+               errno = EIO;
+               return -1;
+       }
+       // Wait for data to be ready
        rv = VFS_SelectNode(Node, VFS_SELECT_READ, timeout, "PTY_ReadClient");
        if(!rv) {
                errno = (timeout ? EWOULDBLOCK : EINTR);
@@ -481,6 +534,9 @@ _select:
                Buffer, Length);
        Mutex_Release(&pty->InputMutex);
 
+       if(pty->InputReadPos == pty->InputWritePos)
+               VFS_MarkAvaliable(Node, 0);
+
        if(Length == 0 && !pty->HasHitEOF) {
                goto _select;
        }
@@ -493,11 +549,19 @@ _select:
 size_t PTY_WriteClient(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer, Uint Flags)
 {
        tPTY *pty = Node->ImplPtr;
-       
+
+       // If the server has terminated, send SIGPIPE
+       if( pty->ServerNode && pty->ServerNode->ReferenceCount == 0 )
+       {
+               //Threads_PostSignal(SIGPIPE);
+               errno = EIO;
+               return -1;
+       }       
+
        // Write to either FIFO or directly to output function
        if( pty->OutputFcn )
        {
-               pty->OutputFcn(pty->OutputHandle, Buffer, Length, &pty->Dims);
+               pty->OutputFcn(pty->OutputHandle, Length, Buffer);
        }
        else
        {
@@ -505,51 +569,17 @@ size_t PTY_WriteClient(tVFS_Node *Node, off_t Offset, size_t Length, const void
                Length = _rb_write(pty->OutputData, OUTPUT_RINGBUFFER_LEN,
                        &pty->OutputReadPos, &pty->OutputWritePos,
                        Buffer, Length);
-               VFS_MarkAvaliable(&pty->ServerNode, 1);
+               VFS_MarkAvaliable(pty->ServerNode, 1);
        }
        
        return Length;
 }
 
-int PTY_IOCtlClient(tVFS_Node *Node, int ID, void *Data)
-{
-       tPTY    *pty = Node->ImplPtr;
-       struct ptymode  *mode = Data;
-       struct ptydims  *dims = Data;
-       switch(ID)
-       {
-       case DRV_IOCTL_TYPE:    return DRV_TYPE_TERMINAL;
-       case DRV_IOCTL_IDENT:   memcpy(Data, "PTY\0", 4);       return 0;
-       case DRV_IOCTL_VER:     return 0x100;
-       case DRV_IOCTL_LOOKUP:  return 0;
-       
-       case PTY_IOCTL_GETMODE:
-               if( !CheckMem(Data, sizeof(*mode)) ) { errno = EINVAL; return -1; }
-               *mode = pty->Mode;
-               return 0;
-       case PTY_IOCTL_SETMODE:
-               if( !CheckMem(Data, sizeof(*mode)) ) { errno = EINVAL; return -1; }
-               PTY_SetAttrib(pty, NULL, mode, 1);
-               return 0;
-       case PTY_IOCTL_GETDIMS:
-               if( !CheckMem(Data, sizeof(*dims)) ) { errno = EINVAL; return -1; }
-               *dims = pty->Dims;
-               return 0;
-       case PTY_IOCTL_SETDIMS:
-               if( !CheckMem(Data, sizeof(*dims)) ) { errno = EINVAL; return -1; }
-               PTY_SetAttrib(pty, dims, NULL, 1);
-               // Inform the server?
-               return 0;
-       }
-       errno = ENOSYS;
-       return -1;
-}
-
 void PTY_ReferenceClient(tVFS_Node *Node)
 {
        Node->ReferenceCount ++;
        // TODO: Add PID to list of client PIDs
-       Log_Notice("PTY", "TODO: List of client PIDs");
+//     Log_Notice("PTY", "ReferenceClient: TODO - List of client PIDs");
 }
 
 void PTY_CloseClient(tVFS_Node *Node)
@@ -558,11 +588,15 @@ void PTY_CloseClient(tVFS_Node *Node)
        Node->ReferenceCount --;
 
        // Remove PID from list
+       // TODO: Maintain list of client processes
 
        // Free structure if this was the last open handle
-       if( Node->ReferenceCount == 0 && pty->ServerNode.ReferenceCount == 0 )
+       if( Node->ReferenceCount > 0 )
+               return ;
+       if( pty->ServerNode && pty->ServerNode->ReferenceCount == 0 )
        {
                // Free the structure! (Should be off the PTY list now)
+               free(pty->ServerNode);
                free(pty);
        }
 }
@@ -600,51 +634,117 @@ size_t PTY_ReadServer(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer
 //\! Write to the client's input
 size_t PTY_WriteServer(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer, Uint Flags)
 {
-       // Write to current line buffer, flushing on unknown character or newline
-       // - or line wrap?
-       // Echo back if instructed
-       PTY_SendInput(Node->ImplPtr, Buffer, Length);
-       return -1;
+       return PTY_SendInput(Node->ImplPtr, Buffer, Length);
 }
 
-int PTY_IOCtlServer(tVFS_Node *Node, int ID, void *Data)
+void PTY_CloseServer(tVFS_Node *Node)
+{
+       tPTY    *pty = Node->ImplPtr;
+       // Dereference node
+       Node->ReferenceCount --;
+       // If reference count == 0, remove from main list
+       if( Node->ReferenceCount > 0 )
+               return ;
+       
+       // Locate on list and remove
+       tPTY    **prev_np;
+       if( pty->NumericName == 0 ) {
+               RWLock_AcquireWrite(&glPTY_NamedPTYs);
+               prev_np = &gpPTY_FirstNamedPTY;
+       }
+       else {
+               RWLock_AcquireWrite(&glPTY_NumPTYs);
+               prev_np = &gpPTY_FirstNumPTY;
+       }
+
+       // Search list until *prev_np is equal to pty   
+       for( tPTY *tmp = *prev_np; *prev_np != pty && tmp; prev_np = &tmp->Next, tmp = tmp->Next )
+               ;
+       
+       // Remove
+       if( *prev_np != pty ) {
+               Log_Error("PTY", "PTY %p(%i/%s) not on list at deletion time", pty, pty->NumericName, pty->Name);
+       }
+       else {
+               *prev_np = pty->Next;
+       }
+       
+       // Clean up lock
+       if( pty->NumericName == 0 ) {
+               RWLock_Release(&glPTY_NamedPTYs);
+               giPTY_NamedCount --;
+       }
+       else {
+               RWLock_Release(&glPTY_NumPTYs);
+               giPTY_NumCount --;
+       }
+
+       // If there are no open children, we can safely free this PTY
+       if( pty->ClientNode.ReferenceCount == 0 ) {
+               free(Node);
+               free(pty);
+       }
+}
+
+int PTY_IOCtl(tVFS_Node *Node, int ID, void *Data)
 {
        tPTY    *pty = Node->ImplPtr;
        struct ptymode  *mode = Data;
        struct ptydims  *dims = Data;
+       
+       int     is_server = !pty || Node == pty->ServerNode;
+
        switch(ID)
        {
        case DRV_IOCTL_TYPE:    return DRV_TYPE_TERMINAL;
        case DRV_IOCTL_IDENT:   memcpy(Data, "PTY\0", 4);       return 0;
-       case DRV_IOCTL_VER:     return 0x100;
+       case DRV_IOCTL_VERSION: return 0x100;
        case DRV_IOCTL_LOOKUP:  return 0;
        
        case PTY_IOCTL_GETMODE:
+               if( !pty )      return 0;
                if( !CheckMem(Data, sizeof(*mode)) ) { errno = EINVAL; return -1; }
                *mode = pty->Mode;
-               // ACK client's SETMODE
+               // TODO: ACK client's SETMODE
                return 0;
        case PTY_IOCTL_SETMODE:
+               if( !pty )      return 0;
                if( !CheckMem(Data, sizeof(*mode)) ) { errno = EINVAL; return -1; }
-               PTY_SetAttrib(pty, NULL, mode, 0);
+               PTY_SetAttrib(pty, NULL, mode, !is_server);
                return 0;
        case PTY_IOCTL_GETDIMS:
+               if( !pty )      return 0;
                if( !CheckMem(Data, sizeof(*dims)) ) { errno = EINVAL; return -1; }
                *dims = pty->Dims;
                return 0;
        case PTY_IOCTL_SETDIMS:
+               if( !pty )      return 0;
                if( !CheckMem(Data, sizeof(*dims)) ) { errno = EINVAL; return -1; }
-               PTY_SetAttrib(pty, dims, NULL, 0);
-               break;
+               PTY_SetAttrib(pty, dims, NULL, !is_server);
+               return 0;
+       case PTY_IOCTL_GETID:
+               if( pty )
+               {
+                       size_t  len = strlen(pty->Name)+1;
+                       if( Data )
+                       {
+                               if( !CheckMem(Data, len) ) { errno = EINVAL; return -1; }
+                               strcpy(Data, pty->Name);
+                       }
+                       return len;
+               }
+               return 0;
+       case PTY_IOCTL_SETID:
+               if( Data && !CheckString(Data) ) { errno = EINVAL; return -1; }
+               if( pty )       return EALREADY;
+               pty = PTY_Create(Data, NULL, NULL,NULL, NULL);
+               if(pty == NULL)
+                       return 1;
+               Node->ImplPtr = pty;
+               pty->ServerNode = Node;
+               return 0;
        }
        errno = ENOSYS;
        return -1;
 }
 
-void PTY_CloseServer(tVFS_Node *Node)
-{
-       // Dereference node
-       Node->ReferenceCount --;
-       // If reference count == 0, remove from main list and SIGPIPE all clients when they write
-}
-

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