* fhandler.cc (fhandler_base::raw_write): Mark as changed on
successful write. * fhandler.h (fhandler_base::status_flags): Add 'has_changed' flag. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Call fhandler_disk_file's own open and close instead of open_fs and close_fs. Mark as changed on success. (fhandler_disk_file::fchown): Ditto. (fhandler_disk_file::facl): Ditto. (fhandler_disk_file::ftruncate): Ditto. (fhandler_base::open_fs): Mark as changed when O_TRUNC flag on existing file is set. (fhandler_disk_file::close): Set st_ctime if has_changed flag is set.
This commit is contained in:
@@ -405,10 +405,10 @@ fhandler_disk_file::fchmod (mode_t mode)
|
||||
if (!get_io_handle () && pc.has_acls ())
|
||||
{
|
||||
/* Open for writing required to be able to set ctime. */
|
||||
if (!(oret = open_fs (O_WRONLY | O_BINARY, 0)))
|
||||
if (!(oret = open (O_WRONLY | O_BINARY, 0)))
|
||||
{
|
||||
query_open (query_write_control);
|
||||
if (!(oret = open_fs (O_BINARY, 0)))
|
||||
if (!(oret = open (O_BINARY, 0)))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -435,11 +435,12 @@ fhandler_disk_file::fchmod (mode_t mode)
|
||||
/* Correct NTFS security attributes have higher priority */
|
||||
res = 0;
|
||||
|
||||
/* Set ctime on success. */
|
||||
if (!res && !query_open ())
|
||||
touch_ctime ();
|
||||
has_changed (true);
|
||||
|
||||
if (oret)
|
||||
close_fs ();
|
||||
close ();
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -460,10 +461,10 @@ fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid)
|
||||
if (!get_io_handle ())
|
||||
{
|
||||
/* Open for writing required to be able to set ctime. */
|
||||
if (!(oret = open_fs (O_WRONLY | O_BINARY, 0)))
|
||||
if (!(oret = open (O_WRONLY | O_BINARY, 0)))
|
||||
{
|
||||
query_open (query_write_control);
|
||||
if (!(oret = open_fs (O_BINARY, 0)))
|
||||
if (!(oret = open (O_BINARY, 0)))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -476,12 +477,13 @@ fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid)
|
||||
{
|
||||
res = set_file_attribute (pc.has_acls (), get_io_handle (), pc,
|
||||
uid, gid, attrib);
|
||||
/* Set ctime on success. */
|
||||
if (!res && !query_open ())
|
||||
touch_ctime ();
|
||||
has_changed (true);
|
||||
}
|
||||
|
||||
if (oret)
|
||||
close_fs ();
|
||||
close ();
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -502,7 +504,7 @@ fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp)
|
||||
/* Open for writing required to be able to set ctime
|
||||
(even though setting the ACL is just pretended). */
|
||||
if (!get_io_handle ())
|
||||
oret = open_fs (O_WRONLY | O_BINARY, 0);
|
||||
oret = open (O_WRONLY | O_BINARY, 0);
|
||||
res = 0;
|
||||
break;
|
||||
case GETACL:
|
||||
@@ -515,7 +517,7 @@ fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp)
|
||||
if (!get_io_handle ())
|
||||
{
|
||||
query_open (query_read_control);
|
||||
if (!(oret = open_fs (O_BINARY, 0)))
|
||||
if (!(oret = open (O_BINARY, 0)))
|
||||
return -1;
|
||||
}
|
||||
if (!fstat_by_handle (&st))
|
||||
@@ -552,12 +554,12 @@ fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp)
|
||||
{
|
||||
/* Open for writing required to be able to set ctime. */
|
||||
if (cmd == SETACL)
|
||||
oret = open_fs (O_WRONLY | O_BINARY, 0);
|
||||
oret = open (O_WRONLY | O_BINARY, 0);
|
||||
if (!oret)
|
||||
{
|
||||
query_open (cmd == SETACL ? query_write_control
|
||||
: query_read_control);
|
||||
if (!(oret = open_fs (O_BINARY, 0)))
|
||||
if (!(oret = open (O_BINARY, 0)))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -581,11 +583,12 @@ fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp)
|
||||
}
|
||||
}
|
||||
|
||||
/* Set ctime on success. */
|
||||
if (!res && cmd == SETACL && !query_open ())
|
||||
touch_ctime ();
|
||||
has_changed (true);
|
||||
|
||||
if (oret)
|
||||
close_fs ();
|
||||
close ();
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -630,8 +633,9 @@ fhandler_disk_file::ftruncate (_off64_t length)
|
||||
res = res_bug;
|
||||
/* restore original file pointer location */
|
||||
lseek (prev_loc, SEEK_SET);
|
||||
/* Set ctime on success. */
|
||||
if (!res)
|
||||
touch_ctime ();
|
||||
has_changed (true);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
@@ -692,6 +696,10 @@ fhandler_base::open_fs (int flags, mode_t mode)
|
||||
&& !allow_ntsec && allow_ntea)
|
||||
set_file_attribute (false, NULL, get_win32_name (), mode);
|
||||
|
||||
/* O_TRUNC on existing file requires setting ctime. */
|
||||
if ((flags & (O_CREAT | O_TRUNC)) == O_TRUNC)
|
||||
has_changed (true);
|
||||
|
||||
set_fs_flags (pc.fs_flags ());
|
||||
|
||||
out:
|
||||
@@ -703,6 +711,9 @@ out:
|
||||
int
|
||||
fhandler_disk_file::close ()
|
||||
{
|
||||
/* Changing file data requires setting ctime. */
|
||||
if (has_changed ())
|
||||
touch_ctime ();
|
||||
return close_fs ();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user