From 86bbf5f33d5f136a137a2da4d0fe3839cd7ce6f3 Mon Sep 17 00:00:00 2001 From: ahodgkinson Date: Fri, 5 May 2006 16:48:29 +0000 Subject: [PATCH] Moved Linux-specific routines out of ftkmisc and into ftkunix. git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@373 0109f412-320b-0410-ab79-c3e0c5ffbbe6 --- ftk/src/ftkmfh.cpp | 37 +++++++++---------------------- ftk/src/ftkmisc.cpp | 41 ++++------------------------------- ftk/src/ftksys.h | 3 +++ ftk/src/ftkunix.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 69 insertions(+), 65 deletions(-) diff --git a/ftk/src/ftkmfh.cpp b/ftk/src/ftkmfh.cpp index 223d6de..8355299 100644 --- a/ftk/src/ftkmfh.cpp +++ b/ftk/src/ftkmfh.cpp @@ -113,8 +113,6 @@ private: F_UNREFERENCED_PARM( pszBasePath); #endif - IF_FileSystem * pFileSystem = f_getFileSysPtr(); - if( m_pLockFileHdl) { @@ -127,7 +125,8 @@ private: #ifdef FLM_UNIX if( bDelete) { - char szTmpPath[ F_PATH_MAX_SIZE]; + IF_FileSystem * pFileSystem = f_getFileSysPtr(); + char szTmpPath[ F_PATH_MAX_SIZE]; // Delete the lock file @@ -403,9 +402,7 @@ RCODE F_MultiFileHdl::create( Exit: - /* - Release the lock file - */ + // Release the lock file if( RC_BAD( rc)) { @@ -483,27 +480,21 @@ RCODE F_MultiFileHdl::createUnique( f_strcpy( m_szPath, szTmpPath); bCreatedDir = TRUE; - /* - Create the lock file - */ + // Create the lock file if( RC_BAD( rc = createLockFile( m_szPath))) { goto Exit; } - /* - Initialize the EOF to 0 and set the state to open - */ + // Initialize the EOF to 0 and set the state to open m_ui64EOF = 0; m_bOpen = TRUE; Exit: - /* - Release the lock file - */ + // Release the lock file if( RC_BAD( rc)) { @@ -546,27 +537,21 @@ RCODE F_MultiFileHdl::open( f_strcpy( m_szPath, pszPath); - /* - Create the lock file - */ + // Create the lock file if( RC_BAD( rc = createLockFile( m_szPath))) { goto Exit; } - /* - Need to determine the current EOF - */ + // Need to determine the current EOF if( RC_BAD( rc = pFileSystem->openDir( m_szPath, (char *)"*.64", &pDir))) { goto Exit; } - /* - Find all data files to determine the EOF - */ + // Find all data files to determine the EOF for( rc = pDir->next(); !RC_BAD( rc) ; rc = pDir->next()) { @@ -591,9 +576,7 @@ Exit: pDir->Release(); } - /* - Release the lock file - */ + // Release the lock file if( RC_BAD( rc)) { diff --git a/ftk/src/ftkmisc.cpp b/ftk/src/ftkmisc.cpp index 1cc2728..8ecf987 100644 --- a/ftk/src/ftkmisc.cpp +++ b/ftk/src/ftkmisc.cpp @@ -32,13 +32,7 @@ static IF_RandomGenerator * gv_pSerialRandom = NULL; static FLMUINT32 * gv_pui32CRCTbl = NULL; static IF_ThreadMgr * gv_pThreadMgr = NULL; static IF_FileSystem * gv_pFileSystem = NULL; -static FLMUINT gv_uiMaxFileSize = 0xFFFC0000; - -#ifdef FLM_LINUX -static FLMUINT gv_uiLinuxMajorVer = 0; -static FLMUINT gv_uiLinuxMinorVer = 0; -static FLMUINT gv_uiLinuxRevision = 0; -#endif +static FLMUINT gv_uiMaxFileSize = FLM_MAXIMUM_FILE_SIZE; FSTATIC RCODE f_initSerialNumberGenerator( void); @@ -96,14 +90,13 @@ RCODE FLMAPI ftkStartup( void) } #if defined( FLM_LINUX) - f_getLinuxKernelVersion( &gv_uiLinuxMajorVer, &gv_uiLinuxMinorVer, - &gv_uiLinuxRevision); + f_setupLinuxKernelVersion(); gv_uiMaxFileSize = f_getLinuxMaxFileSize(); #elif defined( FLM_AIX) - // Call set setrlimit to increase the max allowed file size. + // Call setrlimit to increase the max allowed file size. // We don't have a good way to deal with any errors returned by - // setrlimit(), so we just hope that there aren't any... + // setrlimit(), so we just hope that there aren't any ... struct rlimit rlim; @@ -1004,32 +997,6 @@ FLMINT FLMAPI F_Object::Release( void) return( iRefCnt); } -/*************************************************************************** -Desc: Determines if the linux system we are running on is 2.4 or greater. -***************************************************************************/ -#ifdef FLM_LINUX -FLMUINT f_getLinuxMaxFileSize( void) -{ -#ifdef FLM_32BIT - return( FLM_MAXIMUM_FILE_SIZE); -#else - FLMUINT uiMaxFileSize = 0x7FF00000; - - f_assert( gv_uiLinuxMajorVer); - - // Is version 2.4 or greater? - - if( gv_uiLinuxMajorVer > 2 || - (gv_uiLinuxMajorVer == 2 && gv_uiLinuxMinorVer >= 4)) - { - uiMaxFileSize = FLM_MAXIMUM_FILE_SIZE; - } - - return( uiMaxFileSize); -#endif -} -#endif - /********************************************************************** Desc: **********************************************************************/ diff --git a/ftk/src/ftksys.h b/ftk/src/ftksys.h index 8bcc383..b080796 100644 --- a/ftk/src/ftksys.h +++ b/ftk/src/ftksys.h @@ -1916,6 +1916,9 @@ FLMBYTE * pszFileName); #if defined( FLM_LINUX) + + void f_setupLinuxKernelVersion( void); + void f_getLinuxKernelVersion( FLMUINT * puiMajor, FLMUINT * puiMinor, diff --git a/ftk/src/ftkunix.cpp b/ftk/src/ftkunix.cpp index 3fe518a..80b6f04 100644 --- a/ftk/src/ftkunix.cpp +++ b/ftk/src/ftkunix.cpp @@ -59,6 +59,12 @@ #include #endif +#ifdef FLM_LINUX + static FLMUINT gv_uiLinuxMajorVer = 0; + static FLMUINT gv_uiLinuxMinorVer = 0; + static FLMUINT gv_uiLinuxRevision = 0; +#endif + /****************************************************************************** Desc: *******************************************************************************/ @@ -1312,7 +1318,15 @@ void f_getLinuxKernelVersion( FLMUINT uiMajorVer = 0; FLMUINT uiMinorVer = 0; FLMUINT uiRevision = 0; - + + if( gv_uiLinuxMajorVer) + { + uiMajorVer = gv_uiLinuxMajorVer; + uiMinorVer = gv_uiLinuxMinorVer; + uiRevision = gv_uiLinuxRevision; + goto Exit; + } + if( (fd = open( "/proc/version", O_RDONLY, 0600)) == -1) { goto Exit; @@ -1381,6 +1395,43 @@ Exit: } #endif +/*************************************************************************** +Desc: +***************************************************************************/ +#ifdef FLM_LINUX +void f_setupLinuxKernelVersion( void) +{ + f_getLinuxKernelVersion( &gv_uiLinuxMajorVer, + &gv_uiLinuxMinorVer, &gv_uiLinuxRevision); +} +#endif + +/*************************************************************************** +Desc: Determines if the linux system we are running on is 2.4 or greater. +***************************************************************************/ +#ifdef FLM_LINUX +FLMUINT f_getLinuxMaxFileSize( void) +{ +#ifdef FLM_32BIT + return( FLM_MAXIMUM_FILE_SIZE); +#else + FLMUINT uiMaxFileSize = 0x7FF00000; + + f_assert( gv_uiLinuxMajorVer); + + // Is version 2.4 or greater? + + if( gv_uiLinuxMajorVer > 2 || + (gv_uiLinuxMajorVer == 2 && gv_uiLinuxMinorVer >= 4)) + { + uiMaxFileSize = FLM_MAXIMUM_FILE_SIZE; + } + + return( uiMaxFileSize); +#endif +} +#endif + /*************************************************************************** Desc: ***************************************************************************/