diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-01-19 11:05:51 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-01-19 11:07:20 +0000 |
commit | 0c17acbb321ced2afe2f0ff6769291549838ebaa (patch) | |
tree | 3abb6f3ba42f3b25d4a2a91179d6978f03fc2f7f | |
parent | 877663b9c262be9b5d8620f756a4cfdf97195279 (diff) |
fix SvStream to not disagree with sal on sizeof struct stat
A temporary tweak to restore build-ability; the oslDirectory
change needs a little more thought & public exposure, but rsc
no longer crashes during compile ...
-rw-r--r-- | sal/inc/osl/detail/file.h | 14 | ||||
-rw-r--r-- | sal/inc/osl/file.hxx | 2 | ||||
-rw-r--r-- | sal/osl/unx/file_stat.cxx | 20 | ||||
-rw-r--r-- | sal/util/sal.map | 2 | ||||
-rw-r--r-- | tools/source/stream/strmunx.cxx | 37 |
5 files changed, 47 insertions, 28 deletions
diff --git a/sal/inc/osl/detail/file.h b/sal/inc/osl/detail/file.h index 19415a2623fa..108d2306b36d 100644 --- a/sal/inc/osl/detail/file.h +++ b/sal/inc/osl/detail/file.h @@ -58,17 +58,13 @@ SAL_DLLPUBLIC oslFileError SAL_CALL osl_openFilePath( oslFileHandle *pHandle, sal_uInt32 uFlags ); -/* Wrappers for stat() and lstat() with Android-specific hook - for files inside the .apk. -*/ +/* Compare directory items for being the same underlying file + * this unwinds unix hard-links and symlinks etc. + */ -SAL_DLLPUBLIC oslFileError SAL_CALL osl_statFilePath( - const char *cpFilePath, - struct stat *statb ); +SAL_DLLPUBLIC sal_Bool SAL_CALL osl_identicalDirectoryItem(oslDirectory a, oslDirectory b); -SAL_DLLPUBLIC oslFileError SAL_CALL osl_lstatFilePath( - const char *cpFilePath, - struct stat *statb ); +SAL_DLLPUBLIC oslFileError SAL_CALL osl_lstatFilePath( const char *cpFilePath, struct stat *statb ); /* Get the OS specific "handle" of an open file. */ diff --git a/sal/inc/osl/file.hxx b/sal/inc/osl/file.hxx index e64e2f0aac71..d9a1d89fe84c 100644 --- a/sal/inc/osl/file.hxx +++ b/sal/inc/osl/file.hxx @@ -1389,9 +1389,9 @@ public: class DirectoryItem: public FileBase { - oslDirectoryItem _pData; public: + oslDirectoryItem _pData; /** Constructor. */ diff --git a/sal/osl/unx/file_stat.cxx b/sal/osl/unx/file_stat.cxx index 9cbb39af0edc..0477a52e555a 100644 --- a/sal/osl/unx/file_stat.cxx +++ b/sal/osl/unx/file_stat.cxx @@ -448,15 +448,31 @@ oslFileError SAL_CALL osl_setFileTime ( return osl_psz_setFileTime( path, pCreationTime, pLastAccessTime, pLastWriteTime ); } -oslFileError -SAL_CALL osl_statFilePath( const char *cpFilePath, struct stat *statb ) +sal_Bool +SAL_CALL osl_identicalDirectoryItem( oslDirectoryItem a, oslDirectoryItem b) { + DirectoryItem_Impl *pA = (DirectoryItem_Impl *) a; + DirectoryItem_Impl *pB = (DirectoryItem_Impl *) b; + if (a == b) + return sal_True; + /* same name => same item, unless renaming / moving madness has occurred */ + if (rtl_ustr_compare_WithLength( + pA->m_ustrFilePath->buffer, pA->m_ustrFilePath->length, + pB->m_ustrFilePath->buffer, pB->m_ustrFilePath->length ) == 0) + return sal_True; + + fprintf (stderr, "We have to do an inode compare !\n"); + + /* int rc = stat_c( cpFilePath, statb ); + Stat.st_ino == ... if (rc == -1) return oslTranslateFileError(OSL_FET_ERROR, errno); else return osl_File_E_None; + */ + return sal_False; } oslFileError diff --git a/sal/util/sal.map b/sal/util/sal.map index 879d252a9ee8..26c30fc03191 100644 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -648,7 +648,7 @@ PRIVATE_textenc.1 { # LibreOffice 3.6 PRIVATE_file.1 { # LibreOffice 3.6 global: osl_openFilePath; - osl_statFilePath; + osl_identicalDirectoryItem; osl_lstatFilePath; osl_getFileOSHandle; }; diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx index c9d4f071c617..8b47282d07b2 100644 --- a/tools/source/stream/strmunx.cxx +++ b/tools/source/stream/strmunx.cxx @@ -64,10 +64,10 @@ namespace { struct LockMutex : public rtl::Static< osl::Mutex, LockMutex > {}; } class InternalStreamLock { - sal_Size m_nStartPos; - sal_Size m_nEndPos; - SvFileStream* m_pStream; - struct stat m_aStat; + sal_Size m_nStartPos; + sal_Size m_nEndPos; + SvFileStream* m_pStream; + osl::DirectoryItem m_aItem; InternalStreamLock( sal_Size, sal_Size, SvFileStream* ); ~InternalStreamLock(); @@ -87,11 +87,11 @@ InternalStreamLock::InternalStreamLock( m_nEndPos( nEnd ), m_pStream( pStream ) { - rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(), - osl_getThreadTextEncoding())); - osl_statFilePath( aFileName.getStr(), &m_aStat ); + osl::DirectoryItem::get( m_pStream->GetFileName(), m_aItem ); LockList::get().push_back( this ); #if OSL_DEBUG_LEVEL > 1 + rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(), + osl_getThreadTextEncoding())); fprintf( stderr, "locked %s", aFileName.getStr() ); if( m_nStartPos || m_nEndPos ) fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos ); @@ -112,7 +112,7 @@ InternalStreamLock::~InternalStreamLock() } #if OSL_DEBUG_LEVEL > 1 rtl::OString aFileName(rtl::OUStringToOString(m_pStream->GetFileName(), - osl_getThreadTextEncoding())); + osl_getThreadTextEncoding())); fprintf( stderr, "unlocked %s", aFileName.getStr() ); if( m_nStartPos || m_nEndPos ) fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos ); @@ -125,13 +125,20 @@ sal_Bool InternalStreamLock::LockFile( sal_Size nStart, sal_Size nEnd, SvFileStr #ifndef BOOTSTRAP osl::MutexGuard aGuard( LockMutex::get() ); #endif - rtl::OString aFileName(rtl::OUStringToOString(pStream->GetFileName(), - osl_getThreadTextEncoding())); - struct stat aStat; - if( osl_statFilePath( aFileName.getStr(), &aStat ) != osl_File_E_None ) - return sal_False; + osl::DirectoryItem aItem; + if (osl::DirectoryItem::get( pStream->GetFileName(), aItem) != osl::FileBase::RC::E_None ) + { + SAL_INFO("tools", "Failed to lookup stream for locking"); + return sal_True; + } - if( S_ISDIR( aStat.st_mode ) ) + osl::FileStatus aStatus( osl_FileStatus_Mask_Type ); + if ( aItem.getFileStatus( aStatus ) != osl::FileBase::RC::E_None ) + { + SAL_INFO("tools", "Failed to stat stream for locking"); + return sal_True; + } + if( aStatus.getFileType() == osl::FileStatus::Type::Directory ) return sal_True; InternalStreamLock* pLock = NULL; @@ -139,7 +146,7 @@ sal_Bool InternalStreamLock::LockFile( sal_Size nStart, sal_Size nEnd, SvFileStr for( size_t i = 0; i < rLockList.size(); ++i ) { pLock = rLockList[ i ]; - if( aStat.st_ino == pLock->m_aStat.st_ino ) + if( osl_identicalDirectoryItem( aItem._pData, pLock->m_aItem._pData) ) { sal_Bool bDenyByOptions = sal_False; StreamMode nLockMode = pLock->m_pStream->GetStreamMode(); |