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
General cleanup and bugfixes
[tpg/acess2.git]
/
KernelLand
/
Kernel
/
vfs
/
open.c
diff --git
a/KernelLand/Kernel/vfs/open.c
b/KernelLand/Kernel/vfs/open.c
index
d55b754
..
344b2a1
100644
(file)
--- a/
KernelLand/Kernel/vfs/open.c
+++ b/
KernelLand/Kernel/vfs/open.c
@@
-201,6
+201,7
@@
restart_parse:
*TruePath = malloc( gVFS_RootMount->MountPointLen+1 );
strcpy(*TruePath, gVFS_RootMount->MountPoint);
}
*TruePath = malloc( gVFS_RootMount->MountPointLen+1 );
strcpy(*TruePath, gVFS_RootMount->MountPoint);
}
+ gVFS_RootMount->OpenHandleCount ++;
if(MountPoint) *MountPoint = gVFS_RootMount;
LEAVE('p', gVFS_RootMount->RootNode);
return gVFS_RootMount->RootNode;
if(MountPoint) *MountPoint = gVFS_RootMount;
LEAVE('p', gVFS_RootMount->RootNode);
return gVFS_RootMount->RootNode;
@@
-214,6
+215,7
@@
restart_parse:
// Find Mountpoint
longestMount = gVFS_RootMount;
// Find Mountpoint
longestMount = gVFS_RootMount;
+ RWLock_AcquireRead( &glVFS_MountList );
for(mnt = gVFS_Mounts; mnt; mnt = mnt->Next)
{
// Quick Check
for(mnt = gVFS_Mounts; mnt; mnt = mnt->Next)
{
// Quick Check
@@
-223,6
+225,8
@@
restart_parse:
if(mnt->MountPointLen < longestMount->MountPointLen) continue;
// String Compare
cmp = strncmp(Path, mnt->MountPoint, mnt->MountPointLen);
if(mnt->MountPointLen < longestMount->MountPointLen) continue;
// String Compare
cmp = strncmp(Path, mnt->MountPoint, mnt->MountPointLen);
+ // Not a match, continue
+ if(cmp != 0) continue;
#if OPEN_MOUNT_ROOT
// Fast Break - Request Mount Root
#if OPEN_MOUNT_ROOT
// Fast Break - Request Mount Root
@@
-233,14
+237,16
@@
restart_parse:
}
if(MountPoint)
*MountPoint = mnt;
}
if(MountPoint)
*MountPoint = mnt;
+ RWLock_Release( &glVFS_MountList );
+ LOG("Mount %p root", mnt);
LEAVE('p', mnt->RootNode);
return mnt->RootNode;
}
#endif
LEAVE('p', mnt->RootNode);
return mnt->RootNode;
}
#endif
- // Not a match, continue
- if(cmp != 0) continue;
longestMount = mnt;
}
longestMount = mnt;
}
+ longestMount->OpenHandleCount ++; // Increment assuimg it worked
+ RWLock_Release( &glVFS_MountList );
// Save to shorter variable
mnt = longestMount;
// Save to shorter variable
mnt = longestMount;
@@
-277,9
+283,16
@@
restart_parse:
}
// Check if the node has a FindDir method
}
// Check if the node has a FindDir method
+ if( !curNode->Type )
+ {
+ LOG("Finddir failure on '%s' - No type", Path);
+ Log_Error("VFS", "Node at '%s' has no type (mount %s:%s)",
+ Path, mnt->Filesystem->Name, mnt->MountPoint);
+ goto _error;
+ }
if( !curNode->Type->FindDir )
{
if( !curNode->Type->FindDir )
{
- LOG("Finddir failure on '%s'
", Path
);
+ LOG("Finddir failure on '%s'
- No FindDir method in %s", Path, curNode->Type->Name
);
goto _error;
}
LOG("FindDir{=%p}(%p, '%s')", curNode->Type->FindDir, curNode, pathEle);
goto _error;
}
LOG("FindDir{=%p}(%p, '%s')", curNode->Type->FindDir, curNode, pathEle);
@@
-333,6
+346,7
@@
restart_parse:
// EVIL: Goto :)
LOG("Symlink -> '%s', restart", Path);
// EVIL: Goto :)
LOG("Symlink -> '%s', restart", Path);
+ mnt->OpenHandleCount --; // Not in this mountpoint
goto restart_parse;
}
goto restart_parse;
}
@@
-402,6
+416,8
@@
restart_parse:
*MountPoint = mnt;
}
*MountPoint = mnt;
}
+ // Leave the mointpoint's count increased
+
LEAVE('p', tmpNode);
return tmpNode;
LEAVE('p', tmpNode);
return tmpNode;
@@
-412,6
+428,9
@@
_error:
free(*TruePath);
*TruePath = NULL;
}
free(*TruePath);
*TruePath = NULL;
}
+ // Open failed, so decrement the open handle count
+ mnt->OpenHandleCount --;
+
LEAVE('n');
return NULL;
}
LEAVE('n');
return NULL;
}
@@
-571,6
+590,9
@@
int VFS_OpenChild(int FD, const char *Name, Uint Mode)
LEAVE_RET('i', -1);
}
LEAVE_RET('i', -1);
}
+ // Increment open handle count, no problems with the mount going away as `h` is already open on it
+ h->Mount->OpenHandleCount ++;
+
LEAVE_RET('x', VFS_int_CreateHandle(node, h->Mount, Mode));
}
LEAVE_RET('x', VFS_int_CreateHandle(node, h->Mount, Mode));
}
@@
-631,7
+653,10
@@
void VFS_Close(int FD)
#endif
_CloseNode(h->Node);
#endif
_CloseNode(h->Node);
-
+
+ if( h->Mount )
+ h->Mount->OpenHandleCount --;
+
h->Node = NULL;
}
h->Node = NULL;
}
UCC
git Repository :: git.ucc.asn.au