[Libreoffice-bugs] [Bug 142302] Calc FILESAVE: EXDEV renaming file
bugzilla-daemon at bugs.documentfoundation.org
bugzilla-daemon at bugs.documentfoundation.org
Mon May 31 15:55:15 UTC 2021
https://bugs.documentfoundation.org/show_bug.cgi?id=142302
jmullee at yahoo.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|1 |0
Status|NEEDINFO |UNCONFIRMED
--- Comment #3 from jmullee at yahoo.com ---
It'll be one of these four places, none of which handle EXDEV
(from fresh git clone)
./sal/osl/unx/file_misc.cxx:754: int nRet = rename(pszPath,pszDestPath);
./sal/osl/unx/file_misc.cxx:845: if (rename(pszDestFileName,
tmpDestFile.getStr()) != 0)
./sal/osl/unx/file_misc.cxx:893: if (rename(tmpDestFile.getStr(),
pszDestFileName) != 0)
./sal/osl/unx/profile.cxx:1720: bool result = rename( pProfile->m_FileName,
pszBakFile ) == 0;
./sal/osl/unx/profile.cxx:1729: result = rename( pszTmpFile,
pProfile->m_FileName ) == 0;
./codemaker/source/codemaker/global.cxx:198: if (
!rename(tmpFileName.getStr(), targetFileName.getStr()) )
./codemaker/source/codemaker/global.cxx:207: if (
rename(tmpFileName.getStr(), targetFileName.getStr()) ) {
sal/osl/unx/file_misc.cxx
e994b3fc3b2c9 (Noel Grandin 2019-12-19 13:29:13 +0200 752) static
oslFileError osl_psz_moveFile(const char* pszPath, const char* pszDestPath)
b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 753) {
acb0cdeedafc5 (Noel Grandin 2019-04-13 14:57:07 +0200 754) int
nRet = rename(pszPath,pszDestPath);
b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 755)
2de83d5ad256d (Chris Sherlock 2018-01-29 02:11:50 +1100 756) if
(nRet < 0)
b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 757) {
sal/osl/unx/file_misc.cxx
e994b3fc3b2c9 (Noel Grandin 2019-12-19 13:29:13 +0200 835) static
oslFileError oslDoCopy(const char* pszSourceFileName, const char*
pszDestFileName, mode
_t nMode, size_t nSourceSize, bool DestFileExists)
b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 836) {
b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 837) int
nRet=0;
b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 838)
6f50961e69406 (Noel Grandin 2018-10-23 12:06:00 +0200 839) OString
tmpDestFile;
b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 840) if (
DestFileExists )
b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 841) {
6edbcc1b231fe (Stephan Bergmann 2014-10-31 12:05:25 +0100 842)
//TODO: better pick a temp file name instead of adding .osl-tmp:
a2fb2cfd45452 (Michael Stahl 2016-03-07 18:53:55 +0100 843) //
use the destination file to avoid EXDEV /* Cross-device link */
7049328fb2d65 (Noel Grandin 2021-04-20 21:07:42 +0200 844)
tmpDestFile = pszDestFileName + OString::Concat(".osl-tmp");
30c9034c87b6c (Stephan Bergmann 2014-10-31 13:26:22 +0100 845) if
(rename(pszDestFileName, tmpDestFile.getStr()) != 0)
sal/osl/unx/profile.cxx
ebb4ac785f9d5 (Stephan Bergmann 2014-03-06 14:31:10 +0100 1705) static bool
osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile
^9399c662f36c (Jens-Heiner Rech 2000-09-18 14:18:43 +0000 1706) {
e994b3fc3b2c9 (Noel Grandin 2019-12-19 13:29:13 +0200 1707) char
pszBakFile[PATH_MAX];
e994b3fc3b2c9 (Noel Grandin 2019-12-19 13:29:13 +0200 1708) char
pszTmpFile[PATH_MAX];
ad0bdc51df262 (mfe 2001-02-26 15:17:50 +0000 1709)
ad0bdc51df262 (mfe 2001-02-26 15:17:50 +0000 1710)
pszBakFile[0] = '\0';
ad0bdc51df262 (mfe 2001-02-26 15:17:50 +0000 1711)
pszTmpFile[0] = '\0';
^9399c662f36c (Jens-Heiner Rech 2000-09-18 14:18:43 +0000 1712)
8f210c26c53cf (Stephan Bergmann 2014-03-04 13:47:20 +0100 1713)
osl_ProfileGenerateExtension(pProfile->m_FileName, "bak", pszB
8f210c26c53cf (Stephan Bergmann 2014-03-04 13:47:20 +0100 1714)
osl_ProfileGenerateExtension(pProfile->m_FileName, "tmp", pszT
^9399c662f36c (Jens-Heiner Rech 2000-09-18 14:18:43 +0000 1715)
52066e4726436 (Norbert Thiebaud 2013-06-20 14:26:49 -0500 1716) /*
unlink bak */
52066e4726436 (Norbert Thiebaud 2013-06-20 14:26:49 -0500 1717) unlink(
pszBakFile );
^9399c662f36c (Jens-Heiner Rech 2000-09-18 14:18:43 +0000 1718)
ebb4ac785f9d5 (Stephan Bergmann 2014-03-06 14:31:10 +0100 1719) //
Rename ini -> bak, then tmp -> ini:
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1720) bool
result = rename( pProfile->m_FileName, pszBakFile ) == 0;
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1721) if
(!result)
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1722) {
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1723) int
e = errno;
22a2ed832bae5 (Tor Lillqvist 2018-10-18 14:30:42 +0300 1724)
SAL_INFO("sal.file", "rename(" << pProfile->m_FileName <<
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1725) }
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1726) else
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1727) {
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1728)
SAL_INFO("sal.file", "rename(" << pProfile->m_FileName <<
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1729)
result = rename( pszTmpFile, pProfile->m_FileName ) == 0;
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1730) if
(!result)
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1731) {
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1732)
int e = errno;
22a2ed832bae5 (Tor Lillqvist 2018-10-18 14:30:42 +0300 1733)
SAL_INFO("sal.file", "rename(" << pszTmpFile << "," <<
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1734) }
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1735)
else
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1736) {
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1737)
SAL_INFO("sal.file", "rename(" << pszTmpFile << "," <<
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1738) }
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1739) }
f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1740) return
result;
^9399c662f36c (Jens-Heiner Rech 2000-09-18 14:18:43 +0000 1741) }
codemaker/source/codemaker/global.cxx
07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 192) bool
makeValidTypeFile(const OString& targetFileName, const OString& tmpFileName,
07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 193)
bool bFileCheck)
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 194) {
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 195) if
(bFileCheck) {
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 196) if
(checkFileContent(targetFileName, tmpFileName)) {
b525a3115f545 (Jens-Heiner Rech 2000-09-18 14:29:57 +0000 197)
if ( !unlink(targetFileName.getStr()) )
e57168966c81a (Juergen Schmidt 2001-11-15 12:00:46 +0000 198)
if ( !rename(tmpFileName.getStr(), targetFileName.getStr()) )
07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 199)
return true;
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 200) }
else
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 201)
return removeTypeFile(tmpFileName);
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 202) } else {
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 203) if
(fileExists(targetFileName))
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 204)
if (!removeTypeFile(targetFileName))
07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 205)
return false;
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 206)
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 207) if (
rename(tmpFileName.getStr(), targetFileName.getStr()) ) {
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 208)
if (errno == EEXIST)
07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 209)
return true;
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 210) }
else
07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 211)
return true;
b525a3115f545 (Jens-Heiner Rech 2000-09-18 14:29:57 +0000 212) }
07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 213) return
false;
d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 214) }
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210531/aa93c113/attachment-0001.htm>
More information about the Libreoffice-bugs
mailing list