From cadbdf2beed2ddce34b48f42341a3c07b55a8e1a Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 27 Jan 2005 04:39:10 +0000 Subject: [PATCH] remove MemoryCardDriverThreaded::UnmountMountPoint; remount the fs instead (makes the timeout FS simpler) use timeout FS in windows memory card code for testing --- .../MemoryCard/MemoryCardDriverThreaded.cpp | 19 ++++--------------- .../MemoryCard/MemoryCardDriverThreaded.h | 3 --- .../MemoryCardDriverThreaded_Linux.cpp | 2 -- .../MemoryCardDriverThreaded_Windows.cpp | 17 +++++++++++------ 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp index 42747cc592..15194671f1 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp @@ -132,25 +132,14 @@ bool MemoryCardDriverThreaded::MountAndTestWrite( UsbStorageDevice* pDevice, CSt if( !iter->bWriteTestSucceeded ) return false; + /* Move the VFS mount to the destination. This is safe to do in the main thread. */ + FILEMAN->Remount( sMountPoint, pDevice->sOsMountDir ); + this->Mount( pDevice, sMountPoint ); + return pDevice->bWriteTestSucceeded; } - -void MemoryCardDriverThreaded::UnmountMountPoint( const CString &sMountPoint ) -{ - vector Mounts; - FILEMAN->GetLoadedDrivers( Mounts ); - for( unsigned i = 0; i < Mounts.size(); ++i ) - { - if( Mounts[i].Type.CompareNoCase( "dir" ) ) - continue; // wrong type - if( Mounts[i].MountPoint.CompareNoCase( sMountPoint ) ) - continue; // wrong mount point - FILEMAN->Unmount( Mounts[i].Type, Mounts[i].Root, Mounts[i].MountPoint ); - } -} - /* * (c) 2003-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h index 61848c1acf..156081618a 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h @@ -40,9 +40,6 @@ protected: vector m_vStorageDevices; bool m_bStorageDevicesChanged; RageMutex m_mutexStorageDevices; // protects the above two - - // placed here for use by derivitives to eliminate duplicate code - void UnmountMountPoint( const CString &sMountPoint ); }; #endif diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp index a8b6227e9f..7d2f073be4 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp @@ -522,8 +522,6 @@ void MemoryCardDriverThreaded_Linux::Mount( UsbStorageDevice* pDevice, CString s { ASSERT( !pDevice->sOsMountDir.empty() ); - UnmountMountPoint( sMountPoint ); - FILEMAN->Mount( "dir", pDevice->sOsMountDir, sMountPoint.c_str() ); LOG->Trace( "FILEMAN->Mount %s %s", pDevice->sOsMountDir.c_str(), sMountPoint.c_str() ); diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Windows.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Windows.cpp index 0991f88953..5519a4b415 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Windows.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Windows.cpp @@ -8,7 +8,8 @@ #include "Profile.h" #include "PrefsManager.h" -const CString TEMP_MOUNT_POINT = "@mctemp/"; +const CString TEMP_MOUNT_POINT_INTERNAL = "@mctemp/"; +const CString TEMP_MOUNT_POINT = "@mctemptimeout/"; MemoryCardDriverThreaded_Windows::MemoryCardDriverThreaded_Windows() @@ -104,15 +105,20 @@ void MemoryCardDriverThreaded_Windows::MountThreadDoOneUpdate() UsbStorageDevice usbd; usbd.SetOsMountDir( sDrive ); usbd.bWriteTestSucceeded = TestWrite( sDrive ); + // read name this->Mount( &usbd, TEMP_MOUNT_POINT ); - FILEMAN->FlushDirCache( TEMP_MOUNT_POINT ); + FILEMAN->Mount( "dir", usbd.sOsMountDir, TEMP_MOUNT_POINT_INTERNAL ); + FILEMAN->Mount( "timeout", TEMP_MOUNT_POINT_INTERNAL, TEMP_MOUNT_POINT ); + Profile profile; CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/'; profile.LoadEditableDataFromDir( sProfileDir ); usbd.bIsNameAvailable = true; usbd.sName = profile.GetDisplayName(); - UnmountMountPoint( TEMP_MOUNT_POINT ); + + FILEMAN->Unmount( "timeout", TEMP_MOUNT_POINT_INTERNAL, TEMP_MOUNT_POINT ); + FILEMAN->Unmount( "dir", usbd.sOsMountDir, TEMP_MOUNT_POINT_INTERNAL ); vNewStorageDevices.push_back( usbd ); } @@ -134,10 +140,9 @@ void MemoryCardDriverThreaded_Windows::Mount( UsbStorageDevice* pDevice, CString { ASSERT( !pDevice->sOsMountDir.empty() ); - UnmountMountPoint( sMountPoint ); - - FILEMAN->Mount( "dir", pDevice->sOsMountDir, sMountPoint.c_str() ); LOG->Trace( "FILEMAN->Mount %s %s", pDevice->sOsMountDir.c_str(), sMountPoint.c_str() ); + + // nothing to do here... } void MemoryCardDriverThreaded_Windows::Unmount( UsbStorageDevice* pDevice, CString sMountPoint )