X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Facesskernel_src%2Fvfs_handle.c;h=cfe048980469b9e75f96b3dede2cc3dbf7e082df;hb=6bcb63ea0505129d32b249772b554b0848bb5612;hp=4d1e00d2305dfecdd64830aa05af016d2fac20aa;hpb=30dd821bb12d4b815546fbd3561b3325fc80e5a7;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/vfs_handle.c b/AcessNative/acesskernel_src/vfs_handle.c index 4d1e00d2..cfe04898 100644 --- a/AcessNative/acesskernel_src/vfs_handle.c +++ b/AcessNative/acesskernel_src/vfs_handle.c @@ -7,6 +7,7 @@ #include #include #include +#include // === CONSTANTS === #define MAX_KERNEL_FILES 128 @@ -68,21 +69,22 @@ void VFS_CloneHandleList(int PID) { tUserHandles *ent; tUserHandles *cur; - int i; + 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); - memcpy(ent->Handles, cur->Handles, CFGINT(CFG_VFS_MAXFILES)*sizeof(tVFS_Handle)); + maxhandles = *Threads_GetMaxFD(); + memcpy(ent->Handles, cur->Handles, maxhandles*sizeof(tVFS_Handle)); - for( i = 0; i < CFGINT(CFG_VFS_MAXFILES); i ++ ) + for( i = 0; i < maxhandles; i ++ ) { if(!cur->Handles[i].Node) continue; - if(ent->Handles[i].Node->Reference) - ent->Handles[i].Node->Reference(ent->Handles[i].Node); + if(ent->Handles[i].Node->Type->Reference) + ent->Handles[i].Node->Type->Reference(ent->Handles[i].Node); } } @@ -113,6 +115,7 @@ tVFS_Handle *VFS_GetHandle(int FD) { tUserHandles *ent; int pid = Threads_GetPID(); + int maxhandles = *Threads_GetMaxFD(); ent = VFS_int_GetUserHandles(pid, 0); if(!ent) { @@ -120,8 +123,8 @@ tVFS_Handle *VFS_GetHandle(int FD) return NULL; } - if(FD >= CFGINT(CFG_VFS_MAXFILES)) { - LOG("FD (%i) > Limit (%i), RETURN NULL", FD, CFGINT(CFG_VFS_MAXFILES)); + if(FD >= maxhandles) { + LOG("FD (%i) > Limit (%i), RETURN NULL", FD, maxhandles); return NULL; } h = &ent->Handles[ FD ]; @@ -144,10 +147,11 @@ int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode) if(bIsUser) { tUserHandles *ent; + int maxhandles = *Threads_GetMaxFD(); // Find the PID's handle list ent = VFS_int_GetUserHandles(Threads_GetPID(), 1); // Get a handle - for(i=0;iHandles[i].Node) continue; ent->Handles[i].Node = Node;