diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:44:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:44:04 +0000 |
commit | eb358d77291eba677141bab113dc27d7aabb0f3e (patch) | |
tree | 2e96f3b5d0c79beaeb536bbf05c3b8564846e65f /sal | |
parent | Adding debian version 4:24.2.1-4. (diff) | |
download | libreoffice-eb358d77291eba677141bab113dc27d7aabb0f3e.tar.xz libreoffice-eb358d77291eba677141bab113dc27d7aabb0f3e.zip |
Merging upstream version 4:24.2.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/file.cxx | 54 | ||||
-rw-r--r-- | sal/osl/unx/system.cxx | 26 |
2 files changed, 61 insertions, 19 deletions
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index eeee7c803f..ee7412dd10 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -64,6 +64,14 @@ #include <vector> #endif +#ifdef LINUX +#include <sys/vfs.h> +// As documented by the kernel +#define SMB_SUPER_MAGIC static_cast<__fsword_t>(0x517B) +#define CIFS_SUPER_MAGIC static_cast<__fsword_t>(0xFF534D42) +#define SMB2_SUPER_MAGIC static_cast<__fsword_t>(0xFE534D42) +#endif + namespace { enum class State @@ -736,9 +744,11 @@ oslFileHandle osl::detail::createFileHandleFromFD(int fd) return static_cast<oslFileHandle>(pImpl); } -static int osl_file_adjustLockFlags(const OString& path, int flags) +static void osl_file_adjustLockFlags(const OString& path, int *flags, sal_uInt32 *uFlags) { #ifdef MACOSX + (void) uFlags; + /* * The AFP implementation of MacOS X 10.4 treats O_EXLOCK in a way * that makes it impossible for OOo to create a backup copy of the @@ -751,20 +761,50 @@ static int osl_file_adjustLockFlags(const OString& path, int flags) { if(strncmp("afpfs", s.f_fstypename, 5) == 0) { - flags &= ~O_EXLOCK; - flags |= O_SHLOCK; + *flags &= ~O_EXLOCK; + *flags |= O_SHLOCK; } else { /* Needed flags to allow opening a webdav file */ - flags &= ~(O_EXLOCK | O_SHLOCK | O_NONBLOCK); + *flags &= ~(O_EXLOCK | O_SHLOCK | O_NONBLOCK); + } + } +#elif defined(LINUX) + (void) flags; + + /* get filesystem info */ + struct statfs aFileStatFs; + if (statfs(path.getStr(), &aFileStatFs) < 0) + { + int e = errno; + SAL_INFO("sal.file", "statfs(" << path << "): " << UnixErrnoString(e)); + } + else + { + SAL_INFO("sal.file", "statfs(" << path << "): OK"); + + // We avoid locking if on a Linux CIFS mount otherwise this + // fill fail later on when opening the file for reading + // during backup creation at save time (even though this is a + // write lock and not a read lock). + // Fixes the following bug: + // https://bugs.documentfoundation.org/show_bug.cgi?id=55004 + switch (aFileStatFs.f_type) { + case SMB_SUPER_MAGIC: + case CIFS_SUPER_MAGIC: + case SMB2_SUPER_MAGIC: + *uFlags |= osl_File_OpenFlag_NoLock; + break; + default: + break; } } #else (void) path; + (void) flags; + (void) uFlags; #endif - - return flags; } static bool osl_file_queryLocking(sal_uInt32 uFlags) @@ -981,7 +1021,7 @@ oslFileError openFilePath(const OString& filePath, oslFileHandle* pHandle, } else { - flags = osl_file_adjustLockFlags (filePath, flags); + osl_file_adjustLockFlags (filePath, &flags, &uFlags); } // O_EXCL can be set only when O_CREAT is set diff --git a/sal/osl/unx/system.cxx b/sal/osl/unx/system.cxx index f19bd70531..eba4fe01c6 100644 --- a/sal/osl/unx/system.cxx +++ b/sal/osl/unx/system.cxx @@ -48,11 +48,6 @@ int macxp_resolveAlias(char *path, int buflen) (void) buflen; return 0; #else - CFStringRef cfpath; - CFURLRef cfurl; - CFErrorRef cferror; - CFDataRef cfbookmark; - // Don't even try anything for files inside the app bundle. Just a // waste of time. @@ -74,12 +69,19 @@ int macxp_resolveAlias(char *path, int buflen) if ( unprocessedPath ) *unprocessedPath = '\0'; - cfpath = CFStringCreateWithCString( nullptr, path, kCFStringEncodingUTF8 ); - cfurl = CFURLCreateWithFileSystemPath( nullptr, cfpath, kCFURLPOSIXPathStyle, false ); - CFRelease( cfpath ); - cferror = nullptr; - cfbookmark = CFURLCreateBookmarkDataFromFile( nullptr, cfurl, &cferror ); - CFRelease( cfurl ); + // tdf#155710 handle conversion failures due to non-UTF8 strings + // Windows and Linux paths can be passed as parameters to this function + // and those paths may not always be UTF8 encoded like macOS paths. + CFStringRef cfpath = CFStringCreateWithCString( nullptr, path, kCFStringEncodingUTF8 ); + CFErrorRef cferror = nullptr; + CFDataRef cfbookmark = nullptr; + if (cfpath) + { + CFURLRef cfurl = CFURLCreateWithFileSystemPath( nullptr, cfpath, kCFURLPOSIXPathStyle, false ); + CFRelease( cfpath ); + cfbookmark = CFURLCreateBookmarkDataFromFile( nullptr, cfurl, &cferror ); + CFRelease( cfurl ); + } if ( cfbookmark == nullptr ) { @@ -91,7 +93,7 @@ int macxp_resolveAlias(char *path, int buflen) else { Boolean isStale; - cfurl = CFURLCreateByResolvingBookmarkData( nullptr, cfbookmark, kCFBookmarkResolutionWithoutUIMask, + CFURLRef cfurl = CFURLCreateByResolvingBookmarkData( nullptr, cfbookmark, kCFBookmarkResolutionWithoutUIMask, nullptr, nullptr, &isStale, &cferror ); CFRelease( cfbookmark ); if ( cfurl == nullptr ) |