Fixed OS X issues.

git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@371 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
ahodgkinson
2006-05-05 16:15:45 +00:00
parent adb84b06ac
commit f283f1f9da
6 changed files with 87 additions and 83 deletions

View File

@@ -2360,17 +2360,6 @@
Desc: File path functions and macros
****************************************************************************/
// This defines the maximum file size we can support for ANY
// platform, ANY file type. It is not 4Gb because of a bug in direct IO
// on Netware. The limitation is that in direct IO mode (on the legacy file
// system) we are not allowed room for the last block. If the block
// size were 64K for example, direct IO only lets us expand to a size of
// 0xFFFF0000. Since we can't anticipate what the block size will be,
// we have to set a maximum that accounts for the maximum block size we
// may ever see. At this point, we are assuming it won't ever be more
// than 256K on legacy file systems. Thus, our limit of 0xFFFC0000.
// (See define of F_MAXIMUM_FILE_SIZE in xflaim.h)
#if defined( FLM_WIN) || defined( FLM_NLM)
#define FWSLASH '/'
#define SLASH '\\'
@@ -2408,6 +2397,8 @@
#define CURRENT_DIR "."
#endif
#endif
FLMUINT64 FLMAPI f_getMaxFileSize( void);
/****************************************************************************
Desc: CPU release and sleep functions

View File

@@ -1223,14 +1223,15 @@ Desc: Log memory leaks.
*********************************************************************/
#ifdef FLM_DEBUG
void logMemLeak(
F_MEM_HDR * pHdr)
F_MEM_HDR * pHdr)
{
char szTmpBuffer [1024];
FLMUINT uiMsgBufSize;
char * pszMessageBuffer;
char * pszTmp;
IF_FileHdl * pFileHdl = NULL;
FLMBOOL bSaveTrackLeaks = gv_bTrackLeaks;
char szTmpBuffer [1024];
FLMUINT uiMsgBufSize;
char * pszMessageBuffer;
char * pszTmp;
IF_FileHdl * pFileHdl = NULL;
FLMBOOL bSaveTrackLeaks = gv_bTrackLeaks;
IF_FileSystem * pFileSystem = f_getFileSysPtr();
gv_bTrackLeaks = FALSE;
@@ -1394,7 +1395,6 @@ void logMemLeak(
#ifdef FLM_WIN
FLMINT iRet;
IF_FileSystem * pFileSystem = f_getFileSysPtr();
iRet = MessageBox( NULL, (LPCTSTR)pszMessageBuffer, "WIN32 Memory Testing",
MB_ABORTRETRYIGNORE | MB_ICONINFORMATION | MB_TASKMODAL
@@ -4390,8 +4390,8 @@ RCODE f_getMemoryInfo(
}
#elif defined( FLM_UNIX)
{
FLMUINT uiProcMemLimit = HIGH_FLMUINT;
FLMUINT uiProcVMemLimit = HIGH_FLMUINT;
FLMUINT uiProcMemLimit = FLM_MAX_UINT;
FLMUINT uiProcVMemLimit = FLM_MAX_UINT;
#if defined( RLIMIT_VMEM)
{
@@ -4476,14 +4476,18 @@ RCODE f_getMemoryInfo(
flmGetLinuxMemInfo( &ui64TotalPhysMem, &ui64AvailPhysMem);
#else
#elif defined( _SC_PAGESIZE) && defined( _SC_AVPHYS_PAGES)
long iPageSize = sysconf( _SC_PAGESIZE);
// Get the amount of memory available to the system
ui64TotalPhysMem = sysconf(_SC_PHYS_PAGES) * iPageSize;
ui64AvailPhysMem = sysconf(_SC_AVPHYS_PAGES) * iPageSize;
ui64TotalPhysMem = sysconf( _SC_PHYS_PAGES) * iPageSize;
ui64AvailPhysMem = sysconf( _SC_AVPHYS_PAGES) * iPageSize;
#else
return( RC_SET( NE_FLM_NOT_IMPLEMENTED));
#endif
@@ -4517,7 +4521,7 @@ RCODE f_getMemoryInfo(
ui64AvailPhysMem = sysconf(_SC_AVPHYS_PAGES) * iPageSize;
}
#else
rc = RC_SET( NE_FLM_NOT_IMPLEMENTED);
return( RC_SET( NE_FLM_NOT_IMPLEMENTED));
#endif
if( ui64AvailPhysMem > ui64TotalPhysMem)

View File

@@ -113,6 +113,8 @@ private:
F_UNREFERENCED_PARM( pszBasePath);
#endif
IF_FileSystem * pFileSystem = f_getFileSysPtr();
if( m_pLockFileHdl)
{

View File

@@ -32,6 +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;
@@ -97,7 +98,7 @@ RCODE FLMAPI ftkStartup( void)
#if defined( FLM_LINUX)
flmGetLinuxKernelVersion( &gv_uiLinuxMajorVer, &gv_uiLinuxMinorVer,
&gv_uiLinuxRevision);
gv_uiMaxFileSize = flmGetLinuxMaxFileSize();
gv_ui64MaxFileSize = flmGetLinuxMaxFileSize();
#elif defined( FLM_AIX)
// Call set setrlimit to increase the max allowed file size.
@@ -321,10 +322,10 @@ RCODE FLMAPI f_createSerialNumber(
f_mutexLock( gv_hSerialMutex);
UD2FBA( (FLMUINT32)gv_pSerialRandom->getInt32(), &pszSerialNum[ 0]);
UD2FBA( (FLMUINT32)gv_pSerialRandom->getInt32(), &pszSerialNum[ 4]);
UD2FBA( (FLMUINT32)gv_pSerialRandom->getInt32(), &pszSerialNum[ 8]);
UD2FBA( (FLMUINT32)gv_pSerialRandom->getInt32(), &pszSerialNum[ 12]);
UD2FBA( (FLMUINT32)gv_pSerialRandom->getINT32(), &pszSerialNum[ 0]);
UD2FBA( (FLMUINT32)gv_pSerialRandom->getINT32(), &pszSerialNum[ 4]);
UD2FBA( (FLMUINT32)gv_pSerialRandom->getINT32(), &pszSerialNum[ 8]);
UD2FBA( (FLMUINT32)gv_pSerialRandom->getINT32(), &pszSerialNum[ 12]);
f_mutexUnlock( gv_hSerialMutex);
@@ -1018,3 +1019,11 @@ IF_ThreadMgr * f_getThreadMgrPtr( void)
{
return( gv_pThreadMgr);
}
/**********************************************************************
Desc:
**********************************************************************/
FLMUINT64 FLMAPI f_getMaxFileSize( void)
{
return( gv_uiMaxFileSize);
}

View File

@@ -1123,6 +1123,11 @@
m_uiBlockSize = uiBlockSize;
}
FINLINE FLMUINT FLMAPI getBlockSize( void)
{
return( m_uiBlockSize);
}
FINLINE FLMUINT FLMAPI getSectorSize( void)
{
return( m_uiBytesPerSector);

View File

@@ -41,9 +41,6 @@
#include <fcntl.h>
extern FLMUINT gv_uiMaxFileSize;
extern FLMBOOL gv_bOkToDoAsyncWrites;
#if defined( FLM_SOLARIS)
#include <sys/statvfs.h>
#elif defined( FLM_LINUX)
@@ -79,7 +76,7 @@ F_FileHdl::F_FileHdl()
m_fd = -1;
m_bDoDirectIO = FALSE;
m_uiExtendSize = 0;
m_uiMaxAutoExtendSize = gv_uiMaxFileSize;
m_uiMaxAutoExtendSize = f_getMaxFileSize();
m_uiBytesPerSector = 0;
m_ui64NotOnSectorBoundMask = 0;
m_ui64GetSectorBoundMask = 0;
@@ -120,18 +117,20 @@ RCODE F_FileHdl::openOrCreate(
FLMUINT uiAccess,
FLMBOOL bCreateFlag)
{
RCODE rc = NE_FLM_OK;
FLMBOOL bDoDirectIO = FALSE;
char szSaveFileName[ F_PATH_MAX_SIZE];
int openFlags = O_RDONLY;
RCODE rc = NE_FLM_OK;
FLMBOOL bDoDirectIO = FALSE;
char szSaveFileName[ F_PATH_MAX_SIZE];
int openFlags = O_RDONLY;
IF_FileSystem * pFileSystem = f_getFileSysPtr();
#if !defined( FLM_UNIX) || defined( FLM_LINUX) || defined( FLM_SOLARIS)
#if defined( FLM_LINUX) || defined( FLM_SOLARIS)
bDoDirectIO = (uiAccess & FLM_IO_DIRECT) ? TRUE : FALSE;
#endif
// HPUX needs this defined to access files larger than 2 GB. The Linux
// man pages *say* it's needed although as of Suse 9.1 it actually
// isn't. Including this flag on Linux anyway just it case...
// HPUX needs this defined to access files larger than 2 GB. The Linux
// man pages *say* it's needed although as of Suse 9.1 it actually
// isn't. Including this flag on Linux anyway just it case...
#if defined( FLM_HPUX) || defined( FLM_LINUX)
openFlags |= O_LARGEFILE;
#endif
@@ -176,7 +175,7 @@ RCODE F_FileHdl::openOrCreate(
}
else
{
if( RC_BAD( rc = gv_pFileSystem->getSectorSize(
if( RC_BAD( rc = pFileSystem->getSectorSize(
pszFileName, &m_uiBytesPerSector)))
{
goto Exit;
@@ -204,21 +203,14 @@ RCODE F_FileHdl::openOrCreate(
(uiMajor == 2 && uiMinor == 6 && uiRevision >= 5))
{
openFlags |= O_DIRECT;
if( gv_bOkToDoAsyncWrites)
{
m_bCanDoAsync = TRUE;
}
m_bCanDoAsync = TRUE;
}
else
{
bDoDirectIO = FALSE;
}
#elif defined( FLM_SOLARIS)
if( gv_bOkToDoAsyncWrites)
{
m_bCanDoAsync = TRUE;
}
m_bCanDoAsync = TRUE;
#endif
}
}
@@ -239,10 +231,10 @@ Retry_Create:
// Remove the file name for which we are creating the directory
if( RC_OK( gv_pFileSystem->pathReduce( szSaveFileName,
if( RC_OK( pFileSystem->pathReduce( szSaveFileName,
szIoDirPath, szTemp)))
{
if( RC_OK( rc = gv_pFileSystem->createDir( szIoDirPath)))
if( RC_OK( rc = pFileSystem->createDir( szIoDirPath)))
{
goto Retry_Create;
}
@@ -262,7 +254,7 @@ Retry_Create:
}
#endif
rc = MapPlatformError( errno, NE_FLM_OPENING_FILE);
rc = f_mapPlatformError( errno, NE_FLM_OPENING_FILE);
goto Exit;
}
@@ -338,21 +330,22 @@ Exit:
Desc:
******************************************************************************/
RCODE FLMAPI F_FileHdl::createUnique(
char * pszDirName,
const char * pszFileExtension,
FLMUINT uiIoFlags)
char * pszDirName,
const char * pszFileExtension,
FLMUINT uiIoFlags)
{
RCODE rc = NE_FLM_OK;
char * pszTmp;
FLMBOOL bModext = TRUE;
FLMUINT uiBaseTime = 0;
FLMBYTE ucHighByte = 0;
char szFileName[ F_FILENAME_SIZE];
char * pszDirPath;
char szDirPath[ F_PATH_MAX_SIZE];
char szTmpPath[ F_PATH_MAX_SIZE];
FLMUINT uiCount;
RCODE rc = NE_FLM_OK;
char * pszTmp;
FLMBOOL bModext = TRUE;
FLMUINT uiBaseTime = 0;
FLMBYTE ucHighByte = 0;
char szFileName[ F_FILENAME_SIZE];
char * pszDirPath;
char szDirPath[ F_PATH_MAX_SIZE];
char szTmpPath[ F_PATH_MAX_SIZE];
FLMUINT uiCount;
IF_FileSystem * pFileSystem = f_getFileSysPtr();
f_assert( !m_bFileOpened);
f_memset( szFileName, 0, sizeof( szFileName));
@@ -405,12 +398,12 @@ RCODE FLMAPI F_FileHdl::createUnique(
uiCount = 0;
do
{
gv_pFileSystem->pathCreateUniqueName( &uiBaseTime, szFileName,
pFileSystem->pathCreateUniqueName( &uiBaseTime, szFileName,
pszFileExtension,
&ucHighByte, bModext);
f_strcpy( szTmpPath, pszDirPath);
gv_pFileSystem->pathAppend( szTmpPath, szFileName);
pFileSystem->pathAppend( szTmpPath, szFileName);
if( m_pszFileName)
{
f_free( &m_pszFileName);
@@ -420,7 +413,7 @@ RCODE FLMAPI F_FileHdl::createUnique(
if (rc == NE_FLM_IO_DISK_FULL)
{
gv_pFileSystem->deleteFile( pszDirPath);
pFileSystem->deleteFile( pszDirPath);
goto Exit;
}
@@ -542,7 +535,7 @@ RCODE FLMAPI F_FileHdl::close( void)
if( bDeleteAllowed)
{
gv_pFileSystem->deleteFile( m_pszFileName);
f_getFileSysPtr()->deleteFile( m_pszFileName);
}
m_bDeleteOnRelease = FALSE;
@@ -584,7 +577,7 @@ RCODE FLMAPI F_FileHdl::flush( void)
if( fdatasync( m_fd) != 0)
{
return( MapPlatformError( errno, NE_FLM_FLUSHING_FILE));
return( f_mapPlatformError( errno, NE_FLM_FLUSHING_FILE));
}
#else
if( !m_bDoDirectIO)
@@ -595,7 +588,7 @@ RCODE FLMAPI F_FileHdl::flush( void)
if( fdatasync( m_fd) != 0)
#endif
{
return( MapPlatformError( errno, NE_FLM_FLUSHING_FILE));
return( f_mapPlatformError( errno, NE_FLM_FLUSHING_FILE));
}
}
#endif
@@ -686,7 +679,7 @@ RCODE F_FileHdl::directRead(
if( (iTmp = pread( m_fd, pucReadBuffer,
uiMaxBytesToRead, getSectorStartOffset( ui64ReadOffset))) == -1)
{
rc = MapPlatformError( errno, NE_FLM_READING_FILE);
rc = f_mapPlatformError( errno, NE_FLM_READING_FILE);
goto Exit;
}
uiBytesRead = (FLMUINT)iTmp;
@@ -785,7 +778,7 @@ RCODE FLMAPI F_FileHdl::read(
if( (iBytesRead = pread( m_fd, pvBuffer,
uiBytesToRead, ui64ReadOffset)) == -1)
{
rc = MapPlatformError(errno, NE_FLM_READING_FILE);
rc = f_mapPlatformError(errno, NE_FLM_READING_FILE);
goto Exit;
}
@@ -890,7 +883,7 @@ RCODE FLMAPI F_FileHdl::size(
if( fstat( m_fd, &statBuf) == -1)
{
rc = MapPlatformError( errno, NE_FLM_GETTING_FILE_SIZE);
rc = f_mapPlatformError( errno, NE_FLM_GETTING_FILE_SIZE);
goto Exit;
}
@@ -923,7 +916,7 @@ RCODE FLMAPI F_FileHdl::truncate(
if( ftruncate( m_fd, ui64Size) == -1)
{
rc = MapPlatformError( errno, NE_FLM_TRUNCATING_FILE);
rc = f_mapPlatformError( errno, NE_FLM_TRUNCATING_FILE);
goto Exit;
}
@@ -961,7 +954,7 @@ RCODE FLMAPI F_FileHdl::write(
if( (iBytesWritten = pwrite( m_fd, pvBuffer,
uiBytesToWrite, ui64WriteOffset)) == -1)
{
rc = MapPlatformError(errno, NE_FLM_WRITING_FILE);
rc = f_mapPlatformError(errno, NE_FLM_WRITING_FILE);
goto Exit;
}
@@ -1013,7 +1006,7 @@ RCODE F_FileHdl::allocAlignedBuffer( void)
#endif
{
m_uiAlignedBuffSize = 0;
rc = MapPlatformError( errno, NE_FLM_MEM);
rc = f_mapPlatformError( errno, NE_FLM_MEM);
goto Exit;
}
@@ -1180,7 +1173,7 @@ RCODE F_FileHdl::directWrite(
if( (iBytesWritten = pwrite( m_fd,
pucWriteBuffer, uiMaxBytesToWrite, uiLastWriteOffset)) == -1)
{
rc = MapPlatformError( errno, NE_FLM_WRITING_FILE);
rc = f_mapPlatformError( errno, NE_FLM_WRITING_FILE);
goto Exit;
}
@@ -1204,7 +1197,7 @@ RCODE F_FileHdl::directWrite(
if( aio_write( pAio) == -1)
{
rc = MapPlatformError( errno, NE_FLM_WRITING_FILE);
rc = f_mapPlatformError( errno, NE_FLM_WRITING_FILE);
goto Exit;
}