summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/file.cxx25
-rw-r--r--sal/osl/unx/profile.c7
2 files changed, 29 insertions, 3 deletions
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 5a2dc5f52..58fbb4b72 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -291,6 +291,11 @@ static int adjustLockFlags(const char * path, int flags)
flags &= ~O_EXLOCK;
flags |= O_SHLOCK;
}
+ else
+ {
+ /* Needed flags to allow opening a webdav file */
+ flags &= ~( O_EXLOCK | O_SHLOCK );
+ }
}
return flags;
@@ -697,7 +702,18 @@ oslFileError osl_openFile( rtl_uString* ustrFileURL, oslFileHandle* pHandle, sal
aflock.l_type = 0;
/* lock the file if flock.l_type is set */
- bLocked = ( F_WRLCK != aflock.l_type || -1 != fcntl( fd, F_SETLK, &aflock ) );
+#ifdef MACOSX
+ bLocked = ( F_WRLCK != aflock.l_type );
+ if (!bLocked)
+ {
+ /* Mac OSX returns ENOTSUP for webdav drives. We should try read lock */
+ if ( 0 == flock( fd, LOCK_EX | LOCK_NB ) || errno == ENOTSUP )
+ bLocked = ( errno != ENOTSUP ) || ( 0 == flock( fd, LOCK_SH | LOCK_NB ) || errno == ENOTSUP );
+ }
+#else /* MACOSX */
+ bLocked = ( F_WRLCK != aflock.l_type || -1 != fcntl( fd, F_SETLK, &aflock ) );
+#endif /* MACOSX */
+
}
if ( !bNeedsLock || bLocked )
@@ -764,7 +780,12 @@ oslFileError osl_closeFile( oslFileHandle Handle )
/* FIXME: check if file is really locked ? */
/* release the file share lock on this file */
- if( -1 == fcntl( pHandleImpl->fd, F_SETLK, &aflock ) )
+#ifdef MACOSX
+ /* Mac OSX will return ENOTSUP for webdav drives. We should ignore the error */
+ if ( 0 != flock( pHandleImpl->fd, LOCK_UN | LOCK_NB ) && errno != ENOTSUP )
+#else /* MACOSX */
+ if( -1 == fcntl( pHandleImpl->fd, F_SETLK, &aflock ) )
+#endif /* MACOSX */
{
PERROR( "osl_closeFile", "unlock failed" );
}
diff --git a/sal/osl/unx/profile.c b/sal/osl/unx/profile.c
index 3f446ed9a..1b828f22b 100644
--- a/sal/osl/unx/profile.c
+++ b/sal/osl/unx/profile.c
@@ -1207,7 +1207,12 @@ static sal_Bool OslProfile_lockFile(const osl_TFile* pFile, osl_TLockMode eMode)
break;
}
- if ( fcntl(pFile->m_Handle, F_SETLKW, &lock) == -1 )
+#ifndef MACOSX // not MAC OSX
+ if ( fcntl(pFile->m_Handle, F_SETLKW, &lock) == -1 )
+#else
+ /* Mac OSX will return ENOTSUP for webdav drives so we should ignore it */
+ if ( fcntl(pFile->m_Handle, F_SETLKW, &lock) == -1 && errno != ENOTSUP )
+#endif /* MACOSX */
{
OSL_TRACE("fcntl returned -1 (%s)\n",strerror(errno));
#ifdef TRACE_OSL_PROFILE