Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Il 01/01/2013 14:36, Riccardo Magliocchetti ha scritto:
Hello,

does anyone know why linux and solaris are using pread / pwrite syscalls
while other unixes are using read + lseek? The code is at least
FileHandle_Impl::writeAt which AFAIU is the base for the osl_* file
functions.

[snip]
If the idea is sound i can cook a patch, but i'd like to have some
feedback from *BSD / MacOS X people that will compile the new code path.

Patch attached if anyone on these plaforms want to give it a try.

thanks,
riccardo
From b574788b119f62e0446eb66d78cf99c21f1ca58f Mon Sep 17 00:00:00 2001
From: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Date: Wed, 2 Jan 2013 11:54:08 +0100
Subject: [PATCH] sal: use pread / pwrite on every *nix

pread / pwrite don't look as a Linux and Solaris privilege.

Change-Id: Ifb2e88445d4064c13a406007bfd523ae0caa38e5
---
 sal/osl/unx/file.cxx |   36 ------------------------------------
 1 file changed, 36 deletions(-)

diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 2f1a99a..d1840a3 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -379,8 +379,6 @@ oslFileError FileHandle_Impl::readAt (
         return osl_File_E_None;
     }
 
-#if defined(LINUX) || defined(SOLARIS)
-
     ssize_t nBytes = ::pread (m_fd, pBuffer, nBytesRequested, nOffset);
     if ((-1 == nBytes) && (EOVERFLOW == errno))
     {
@@ -393,22 +391,6 @@ oslFileError FileHandle_Impl::readAt (
     if (-1 == nBytes)
         return oslTranslateFileError (OSL_FET_ERROR, errno);
 
-#else /* !(LINUX || SOLARIS) */
-
-    if (nOffset != m_offset)
-    {
-        if (-1 == ::lseek (m_fd, nOffset, SEEK_SET))
-            return oslTranslateFileError (OSL_FET_ERROR, errno);
-        m_offset = nOffset;
-    }
-
-    ssize_t nBytes = ::read (m_fd, pBuffer, nBytesRequested);
-    if (-1 == nBytes)
-        return oslTranslateFileError (OSL_FET_ERROR, errno);
-    m_offset += nBytes;
-
-#endif /* !(LINUX || SOLARIS) */
-
     OSL_FILE_TRACE("FileHandle_Impl::readAt(%d, %lld, %ld)", m_fd, nOffset, nBytes);
     *pBytesRead = nBytes;
     return osl_File_E_None;
@@ -428,28 +410,10 @@ oslFileError FileHandle_Impl::writeAt (
     if (!(m_state & STATE_WRITEABLE))
         return osl_File_E_BADF;
 
-#if defined(LINUX) || defined(SOLARIS)
-
     ssize_t nBytes = ::pwrite (m_fd, pBuffer, nBytesToWrite, nOffset);
     if (-1 == nBytes)
         return oslTranslateFileError (OSL_FET_ERROR, errno);
 
-#else /* !(LINUX || SOLARIS) */
-
-    if (nOffset != m_offset)
-    {
-        if (-1 == ::lseek (m_fd, nOffset, SEEK_SET))
-            return oslTranslateFileError (OSL_FET_ERROR, errno);
-        m_offset = nOffset;
-    }
-
-    ssize_t nBytes = ::write (m_fd, pBuffer, nBytesToWrite);
-    if (-1 == nBytes)
-        return oslTranslateFileError (OSL_FET_ERROR, errno);
-    m_offset += nBytes;
-
-#endif /* !(LINUX || SOLARIS) */
-
     OSL_FILE_TRACE("FileHandle_Impl::writeAt(%d, %lld, %ld)", m_fd, nOffset, nBytes);
     m_size = std::max (m_size, sal::static_int_cast< sal_uInt64 >(nOffset + nBytes));
 
-- 
1.7.10.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.