Kaydet (Commit) f8c77cf7 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

More SAL_INFO("sal.file", ...) tweaks

Change-Id: I999d641b54a53c5a737e82d67a0a1ffa769afd24
Reviewed-on: https://gerrit.libreoffice.org/61700
Tested-by: Jenkins
Reviewed-by: 's avatarTor Lillqvist <tml@collabora.com>
üst fa394eef
......@@ -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;
}
......
......@@ -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)
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment