/*
* Acess Micro - VFS Server version 1
*/
+#define SANITY 1
#define DEBUG 0
#include <acess.h>
#include <vfs.h>
}
tVFS_Driver *bestfs = NULL;
- int bestrank, rank;
+ int bestrank = 0, rank;
for( fs = gVFS_Drivers; fs; fs = fs->Next )
{
if(!fs->Detect) continue ;
// Create mount information
mnt = malloc( sizeof(tVFS_Mount)+deviceLen+1+mountLen+1+argLen+1 );
if(!mnt) {
+ ASSERT(parent_mnt->OpenHandleCount > 0);
parent_mnt->OpenHandleCount --;
return -2;
}
mnt->RootNode = fs->InitDevice(Device, (const char **)args);
if(!mnt->RootNode) {
free(mnt);
+ ASSERT(parent_mnt->OpenHandleCount>0);
parent_mnt->OpenHandleCount --;
return -2;
}
break;
}
if(mpmnt) {
- mpmnt->OpenHandleCount -= 1;
+ ASSERT(mpmnt->OpenHandleCount>0);
+ mpmnt->OpenHandleCount --;
}
else {
Log_Notice("VFS", "Mountpoint '%s' has no parent", Mount->MountPoint);
if( mount->OpenHandleCount ) {
LOG("Mountpoint busy");
RWLock_Release(&glVFS_MountList);
+ Log_Log("VFS", "Unmount of '%s' deferred, still busy (%i open handles)",
+ Mountpoint, mount->OpenHandleCount);
return EBUSY;
}
if(prev)
// If we've unmounted the final filesystem, all good
if( gVFS_Mounts == NULL) {
RWLock_Release( &glVFS_MountList );
+
+ // Final unmount means VFS completely deinited
+ VFS_Deinit();
return -1;
}
for( mount = gVFS_Mounts; mount; prev = mount, mount = next )
{
next = mount->Next;
+
+ ASSERT(mount->OpenHandleCount >= 0);
+
// Can't unmount stuff with open handles
if( mount->OpenHandleCount > 0 ) {
LOG("%p (%s) has open handles (%i of them)",