X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Facesskernel_src%2Fvfs_handle.c;h=1a5ebd52a379b9af70bca8d1d9cad02454e1d059;hb=4ab2ee475505478c2e1fa6547e94b480ef1308ec;hp=cfe048980469b9e75f96b3dede2cc3dbf7e082df;hpb=51ab5f489bc356940c95cc936fd0508e8f07ea97;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/vfs_handle.c b/AcessNative/acesskernel_src/vfs_handle.c index cfe04898..1a5ebd52 100644 --- a/AcessNative/acesskernel_src/vfs_handle.c +++ b/AcessNative/acesskernel_src/vfs_handle.c @@ -38,8 +38,8 @@ tUserHandles *VFS_int_GetUserHandles(int PID, int bCreate) tUserHandles *ent, *prev = NULL; for( ent = gpUserHandles; ent; prev = ent, ent = ent->Next ) { if( ent->PID == PID ) { - if( bCreate ) - Log_Warning("VFS", "Process %i already has a handle list", PID); + //if( bCreate ) + // Log_Warning("VFS", "Process %i already has a handle list", PID); return ent; } if( ent->PID > PID ) break; @@ -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 @@ -139,6 +173,39 @@ tVFS_Handle *VFS_GetHandle(int FD) return h; } +int VFS_SetHandle(int FD, tVFS_Node *Node, int Mode) +{ + tVFS_Handle *h; + if(FD < 0) return -1; + + if( FD & VFS_KERNEL_FLAG ) { + FD &= (VFS_KERNEL_FLAG -1); + if( FD >= MAX_KERNEL_FILES ) return -1; + h = &gaKernelHandles[FD]; + } + else { + tUserHandles *ent; + int pid = Threads_GetPID(); + int maxhandles = *Threads_GetMaxFD(); + + ent = VFS_int_GetUserHandles(pid, 0); + if(!ent) { + Log_Error("VFS", "Client %i does not have a handle list (>)", pid); + return NULL; + } + + if(FD >= maxhandles) { + LOG("FD (%i) > Limit (%i), RETURN NULL", FD, maxhandles); + return NULL; + } + h = &ent->Handles[ FD ]; + } + h->Node = Node; + h->Mode = Mode; + return FD; +} + + int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode) { int i;