summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-10-12 03:06:27 +0300
committerTor Lillqvist <tml@collabora.com>2018-10-12 08:56:20 +0200
commitf8c77cf7ebaf63e3aac85269c637c92a37bc988b (patch)
treeb61fdb424f506b7aa7d98a43cf96ccdf0bc3d3aa /sal
parentfa394eef4017d62549599ded3a62d790bc508582 (diff)
More SAL_INFO("sal.file", ...) tweaks
Change-Id: I999d641b54a53c5a737e82d67a0a1ffa769afd24 Reviewed-on: https://gerrit.libreoffice.org/61700 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/file_misc.cxx21
-rw-r--r--sal/osl/unx/profile.cxx37
-rw-r--r--sal/osl/unx/uunxapi.cxx47
3 files changed, 92 insertions, 13 deletions
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 8bc4303dce42..507779c7fe6c 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -196,6 +196,8 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString* ustrDirectoryURL, oslDirect
if( pdir )
{
+ SAL_INFO("sal.file", "opendir(" << path << ") => " << pdir);
+
/* create and initialize impl structure */
oslDirectoryImpl* pDirImpl = static_cast<oslDirectoryImpl*>(malloc( sizeof(oslDirectoryImpl) ));
@@ -214,9 +216,8 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString* ustrDirectoryURL, oslDirect
}
else
{
-#ifdef DEBUG_OSL_FILE
- perror ("osl_openDirectory"); fprintf (stderr, path);
-#endif
+ int e = errno;
+ SAL_INFO("sal.file", "opendir(" << path << "): errno " << e << ": " << strerror(e));
}
}
}
@@ -244,8 +245,14 @@ oslFileError SAL_CALL osl_closeDirectory(oslDirectory pDirectory)
else
#endif
{
- if (closedir( pDirImpl->pDirStruct))
+ if (closedir( pDirImpl->pDirStruct) != 0)
+ {
+ int e = errno;
+ SAL_INFO("sal.file", "closedir(" << pDirImpl->pDirStruct << "): errno " << e << ": " << strerror(e));
err = oslTranslateFileError(errno);
+ }
+ else
+ SAL_INFO("sal.file", "closedir(" << pDirImpl->pDirStruct << "): OK");
}
/* cleanup members */
@@ -461,8 +468,11 @@ oslFileError osl_psz_createDirectory(char const * pszPath, sal_uInt32 flags)
if ( nRet < 0 )
{
nRet=errno;
+ SAL_INFO("sal.file", "mkdir(" << pszPath << ",0" << std::oct << mode << std::dec << "): errno " << nRet << ": " << strerror(nRet));
return oslTranslateFileError(nRet);
}
+ else
+ SAL_INFO("sal.file", "mkdir(" << pszPath << ",0" << std::oct << mode << std::dec << "): OK");
return osl_File_E_None;
}
@@ -476,8 +486,11 @@ static oslFileError osl_psz_removeDirectory( const sal_Char* pszPath )
if ( nRet < 0 )
{
nRet=errno;
+ SAL_INFO("sal.file", "rmdir(" << pszPath << "): errno " << nRet << ": " << strerror(nRet));
return oslTranslateFileError(nRet);
}
+ else
+ SAL_INFO("sal.file", "rmdir(" << pszPath << "): OK");
return osl_File_E_None;
}
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index 4bd77901b247..6af40898a58c 100644
--- a/sal/osl/unx/profile.cxx
+++ b/sal/osl/unx/profile.cxx
@@ -949,6 +949,15 @@ static osl_TFile* openFileImpl(const sal_Char* pszFilename, oslProfileOption Pro
if (! bWriteable)
{
pFile->m_Handle = open(pszFilename, O_RDONLY);
+
+ if (pFile->m_Handle == -1)
+ {
+ int e = errno;
+ SAL_INFO("sal.file", "open(" << pszFilename << ",O_RDONLY): errno " << e << ": " << strerror(e));
+ }
+ else
+ SAL_INFO("sal.file", "open(" << pszFilename << ",O_RDONLY) => " << pFile->m_Handle);
+
/* mfe: argghh!!! do not check if the file could be opened */
/* default mode expects it that way!!! */
}
@@ -957,9 +966,13 @@ static osl_TFile* openFileImpl(const sal_Char* pszFilename, oslProfileOption Pro
if (((pFile->m_Handle = open(pszFilename, O_RDWR | O_CREAT | O_EXCL, DEFAULT_PMODE)) < 0) &&
((pFile->m_Handle = open(pszFilename, O_RDWR)) < 0))
{
+ int e = errno;
+ SAL_INFO("sal.file", "open(" << pszFilename << ",...): errno " << e << ": " << strerror(e));
free(pFile);
return nullptr;
}
+ else
+ SAL_INFO("sal.file", "open(" << pszFilename << ",...) => " << pFile->m_Handle);
}
/* set close-on-exec flag */
@@ -1003,6 +1016,7 @@ static osl_TStamp closeFileImpl(osl_TFile* pFile, oslProfileOption Flags)
}
close(pFile->m_Handle);
+ SAL_INFO("sal.file", "close(" << pFile->m_Handle << ")");
pFile->m_Handle = -1;
}
@@ -1710,8 +1724,27 @@ static bool osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile)
unlink( pszBakFile );
// Rename ini -> bak, then tmp -> ini:
- return rename( pProfile->m_FileName, pszBakFile ) == 0
- && rename( pszTmpFile, pProfile->m_FileName ) == 0;
+ bool result = rename( pProfile->m_FileName, pszBakFile ) == 0;
+ if (!result)
+ {
+ int e = errno;
+ SAL_INFO("sal.file", "rename(" << pProfile->m_FileName << "," << pszBakFile << "): errno " << e << ": " << strerror(e));
+ }
+ else
+ {
+ SAL_INFO("sal.file", "rename(" << pProfile->m_FileName << "," << pszBakFile << "): OK");
+ result = rename( pszTmpFile, pProfile->m_FileName ) == 0;
+ if (!result)
+ {
+ int e = errno;
+ SAL_INFO("sal.file", "rename(" << pszTmpFile << "," << pProfile->m_FileName << "): errno " << e << ": " << strerror(e));
+ }
+ else
+ {
+ SAL_INFO("sal.file", "rename(" << pszTmpFile << "," << pProfile->m_FileName << "): OK");
+ }
+ }
+ return result;
}
static void osl_ProfileGenerateExtension(const sal_Char* pszFileName, const sal_Char* pszExtension, sal_Char* pszTmpName, int BufferMaxLen)
diff --git a/sal/osl/unx/uunxapi.cxx b/sal/osl/unx/uunxapi.cxx
index 3d8fb144a255..614c83c04e34 100644
--- a/sal/osl/unx/uunxapi.cxx
+++ b/sal/osl/unx/uunxapi.cxx
@@ -181,9 +181,16 @@ int access_u(const rtl_uString* pustrPath, int mode)
accessFilePathState *state = prepare_to_access_file_path(fn.getStr());
int result = access(fn.getStr(), mode);
+ int saved_errno = errno;
+ if (result == -1)
+ SAL_INFO("sal.file", "access(" << fn.getStr() << ",0" << std::oct << mode << std::dec << "): errno " << saved_errno << ": " << strerror(saved_errno));
+ else
+ SAL_INFO("sal.file", "access(" << fn.getStr() << ",0" << std::oct << mode << std::dec << "): OK");
done_accessing_file_path(fn.getStr(), state);
+ errno = saved_errno;
+
return result;
}
@@ -211,6 +218,11 @@ bool realpath_u(const rtl_uString* pustrFileName, rtl_uString** ppustrResolvedNa
char rp[PATH_MAX];
bool bRet = realpath(fn.getStr(), rp);
+ int saved_errno = errno;
+ if (!bRet)
+ SAL_INFO("sal.file", "realpath(" << fn.getStr() << "): errno " << saved_errno << ": " << strerror(saved_errno));
+ else
+ SAL_INFO("sal.file", "realpath(" << fn.getStr() << "): OK");
done_accessing_file_path(fn.getStr(), state);
@@ -221,6 +233,9 @@ bool realpath_u(const rtl_uString* pustrFileName, rtl_uString** ppustrResolvedNa
rtl_uString_assign(ppustrResolvedName, resolved.pData);
}
+
+ errno = saved_errno;
+
return bRet;
}
@@ -236,9 +251,16 @@ int stat_c(const char* cpPath, struct stat* buf)
accessFilePathState *state = prepare_to_access_file_path(cpPath);
int result = stat(cpPath, buf);
+ int saved_errno = errno;
+ if (result == -1)
+ SAL_INFO("sal.file", "stat(" << cpPath << "): errno " << saved_errno << ": " << strerror(saved_errno));
+ else
+ SAL_INFO("sal.file", "stat(" << cpPath << "): OK");
done_accessing_file_path(cpPath, state);
+ errno = saved_errno;
+
return result;
}
@@ -254,9 +276,16 @@ int lstat_c(const char* cpPath, struct stat* buf)
accessFilePathState *state = prepare_to_access_file_path(cpPath);
int result = lstat(cpPath, buf);
+ int saved_errno = errno;
+ if (result == -1)
+ SAL_INFO("sal.file", "lstat(" << cpPath << "): errno " << saved_errno << ": " << strerror(saved_errno));
+ else
+ SAL_INFO("sal.file", "lstat(" << cpPath << "): OK");
done_accessing_file_path(cpPath, state);
+ errno = saved_errno;
+
return result;
}
@@ -278,9 +307,16 @@ int mkdir_u(const rtl_uString* path, mode_t mode)
accessFilePathState *state = prepare_to_access_file_path(fn.getStr());
int result = mkdir(OUStringToOString(path).getStr(), mode);
+ int saved_errno = errno;
+ if (result == -1)
+ SAL_INFO("sal.file", "mkdir(" << OUStringToOString(path).getStr() << ",0" << std::oct << mode << std::dec << "): errno " << saved_errno << ": " << strerror(saved_errno));
+ else
+ SAL_INFO("sal.file", "mkdir(" << OUStringToOString(path).getStr() << ",0" << std::oct << mode << std::dec << "): OK");
done_accessing_file_path(fn.getStr(), state);
+ errno = saved_errno;
+
return result;
}
@@ -291,9 +327,7 @@ int open_c(const char *cpPath, int oflag, int mode)
int result = open(cpPath, oflag, mode);
int saved_errno = errno;
if (result == -1)
- {
SAL_INFO("sal.file", "open(" << cpPath << ",0" << std::oct << oflag << ",0" << mode << std::dec << "): errno " << saved_errno << ": " << strerror(saved_errno));
- }
else
SAL_INFO("sal.file", "open(" << cpPath << ",0" << std::oct << oflag << ",0" << mode << std::dec << ") => " << result);
@@ -362,17 +396,16 @@ int ftruncate_with_name(int fd, sal_uInt64 uSize, rtl_String* path)
accessFilePathState *state = prepare_to_access_file_path(fn.getStr());
int result = ftruncate(fd, uSize);
-
+ int saved_errno = errno;
if (result < 0)
- {
- int e = errno;
- SAL_INFO("sal.file", "ftruncate(" << fd << "," << uSize << "): errno " << e << ": " << strerror(e));
- }
+ SAL_INFO("sal.file", "ftruncate(" << fd << "," << uSize << "): errno " << saved_errno << ": " << strerror(saved_errno));
else
SAL_INFO("sal.file", "ftruncate(" << fd << "," << uSize << "): OK");
done_accessing_file_path(fn.getStr(), state);
+ errno = saved_errno;
+
return result;
}