git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Usermode - More hackery to get glib compiling
[tpg/acess2.git]
/
KernelLand
/
Kernel
/
vfs
/
handle.c
diff --git
a/KernelLand/Kernel/vfs/handle.c
b/KernelLand/Kernel/vfs/handle.c
index
661ced8
..
d500aa9
100644
(file)
--- a/
KernelLand/Kernel/vfs/handle.c
+++ b/
KernelLand/Kernel/vfs/handle.c
@@
-39,7
+39,7
@@
tVFS_Handle *VFS_GetHandle(int FD)
if(FD >= MAX_KERNEL_FILES) return NULL;
h = &gaKernelHandles[ FD ];
} else {
if(FD >= MAX_KERNEL_FILES) return NULL;
h = &gaKernelHandles[ FD ];
} else {
- if(FD >= *Threads_GetMaxFD(
))
return NULL;
+ if(FD >= *Threads_GetMaxFD(
NULL))
return NULL;
h = &gaUserHandles[ FD ];
}
h = &gaUserHandles[ FD ];
}
@@
-59,7
+59,7
@@
int VFS_SetHandle(int FD, tVFS_Node *Node, int Mode)
h = &gaKernelHandles[FD];
}
else {
h = &gaKernelHandles[FD];
}
else {
- if( FD >= *Threads_GetMaxFD(
))
return -1;
+ if( FD >= *Threads_GetMaxFD(
NULL))
return -1;
h = &gaUserHandles[FD];
}
h->Node = Node;
h = &gaUserHandles[FD];
}
h->Node = Node;
@@
-72,7
+72,7
@@
int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode)
// Check for a user open
if(bIsUser)
{
// Check for a user open
if(bIsUser)
{
- int max_handles = *Threads_GetMaxFD();
+ int max_handles = *Threads_GetMaxFD(
NULL
);
// Allocate Buffer
if( MM_GetPhysAddr( gaUserHandles ) == 0 )
{
// Allocate Buffer
if( MM_GetPhysAddr( gaUserHandles ) == 0 )
{
@@
-132,14
+132,13
@@
int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode)
void VFS_ReferenceUserHandles(void)
{
void VFS_ReferenceUserHandles(void)
{
- int i;
- int max_handles = *Threads_GetMaxFD();
+ const int max_handles = *Threads_GetMaxFD(NULL);
// Check if this process has any handles
if( MM_GetPhysAddr( gaUserHandles ) == 0 )
return ;
// Check if this process has any handles
if( MM_GetPhysAddr( gaUserHandles ) == 0 )
return ;
- for( i = 0; i < max_handles; i ++ )
+ for( i
nt i
= 0; i < max_handles; i ++ )
{
tVFS_Handle *h;
h = &gaUserHandles[i];
{
tVFS_Handle *h;
h = &gaUserHandles[i];
@@
-150,22
+149,34
@@
void VFS_ReferenceUserHandles(void)
}
}
}
}
-void VFS_CloseAllUserHandles(
void
)
+void VFS_CloseAllUserHandles(
struct sProcess *Process
)
{
{
- int max_handles = *Threads_GetMaxFD();
+ const int max_handles = *Threads_GetMaxFD(Process);
+ ENTER("pProcess", Process);
+ if( max_handles >= PAGE_SIZE / sizeof(tVFS_Handle) )
+ TODO("More than a page of handles");
+
+ tVFS_Handle *handles = MM_MapTempFromProc(Process, gaUserHandles);
+ LOG("handles=%p", handles);
// Check if this process has any handles
// Check if this process has any handles
- if( MM_GetPhysAddr( gaUserHandles ) == 0 )
+ if( !handles ) {
+ LEAVE('-');
return ;
return ;
+ }
for( int i = 0; i < max_handles; i ++ )
{
for( int i = 0; i < max_handles; i ++ )
{
- tVFS_Handle *h;
-
h = &gaUserHandles[i]
;
+ tVFS_Handle *h
= &handles[i]
;
+
LOG("handles[%i].Node = %p", i, h->Node)
;
if( !h->Node )
continue ;
_CloseNode(h->Node);
if( !h->Node )
continue ;
_CloseNode(h->Node);
+ h->Node = NULL;
}
}
+
+ MM_FreeTemp(handles);
+ LEAVE('-');
}
/**
}
/**
@@
-174,7
+185,7
@@
void VFS_CloseAllUserHandles(void)
void *VFS_SaveHandles(int NumFDs, int *FDs)
{
tVFS_Handle *ret;
void *VFS_SaveHandles(int NumFDs, int *FDs)
{
tVFS_Handle *ret;
-
int max_handles = *Threads_GetMaxFD(
);
+
const int max_handles = *Threads_GetMaxFD(NULL
);
// Check if this process has any handles
if( MM_GetPhysAddr( gaUserHandles ) == 0 )
// Check if this process has any handles
if( MM_GetPhysAddr( gaUserHandles ) == 0 )
@@
-235,11
+246,16
@@
void *VFS_SaveHandles(int NumFDs, int *FDs)
void VFS_RestoreHandles(int NumFDs, void *Handles)
{
tVFS_Handle *handles = Handles;
void VFS_RestoreHandles(int NumFDs, void *Handles)
{
tVFS_Handle *handles = Handles;
-
int max_handles = *Threads_GetMaxFD(
);
+
const int max_handles = *Threads_GetMaxFD(NULL
);
// NULL = nothing to do
if( !Handles )
// NULL = nothing to do
if( !Handles )
- return ;
+ return ;
+
+ if( NumFDs > max_handles ) {
+ Log_Notice("VFS", "RestoreHandles: Capping from %i FDs to %i", NumFDs, max_handles);
+ NumFDs = max_handles;
+ }
// Allocate user handle area (and dereference existing handles)
for( int i = 0; i < NumFDs; i ++ )
// Allocate user handle area (and dereference existing handles)
for( int i = 0; i < NumFDs; i ++ )
UCC
git Repository :: git.ucc.asn.au