Acessnative - Sys_Spawn implimented
[tpg/acess2.git] / AcessNative / acesskernel_src / vfs_handle.c
index cfe0489..fc881ab 100644 (file)
@@ -88,6 +88,40 @@ void VFS_CloneHandleList(int PID)
        }
 }
 
+void VFS_CloneHandlesFromList(int PID, int nFD, int FDs[])
+{
+       tUserHandles    *ent;
+       tUserHandles    *cur;
+        int    i, maxhandles;
+       
+       cur = VFS_int_GetUserHandles(Threads_GetPID(), 0);
+       if(!cur)        return ;        // Don't need to do anything if the current list is empty
+       
+       ent = VFS_int_GetUserHandles(PID, 1);
+       
+       maxhandles = *Threads_GetMaxFD();
+       if( nFD > maxhandles )
+               nFD = maxhandles;
+       for( i = 0; i < nFD; i ++ )
+       {
+               if( FDs[i] >= maxhandles ) {
+                       ent->Handles[i].Node = NULL;
+                       continue ;
+               }
+               memcpy(&ent->Handles[i], &cur->Handles[ FDs[i] ], sizeof(tVFS_Handle));
+       }
+       for( ; i < maxhandles; i ++ )
+               cur->Handles[i].Node = NULL;
+       
+       for( i = 0; i < maxhandles; i ++ )
+       {
+               if(!cur->Handles[i].Node)       continue;
+               
+               if(ent->Handles[i].Node->Type->Reference)
+                       ent->Handles[i].Node->Type->Reference(ent->Handles[i].Node);
+       }
+}
+
 /**
  * \fn tVFS_Handle *VFS_GetHandle(int FD)
  * \brief Gets a pointer to the handle information structure

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