X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Facesskernel_src%2Fvfs_handle.c;h=1a5ebd52a379b9af70bca8d1d9cad02454e1d059;hb=b7a55f71ed629d076996e2373da0b32e9c61925e;hp=724e76fc483db6249d6afdaa5e1533b654f4dd3e;hpb=b6198d9a828e247771a8913099070d51df76db4b;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/vfs_handle.c b/AcessNative/acesskernel_src/vfs_handle.c index 724e76fc..1a5ebd52 100644 --- a/AcessNative/acesskernel_src/vfs_handle.c +++ b/AcessNative/acesskernel_src/vfs_handle.c @@ -173,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;