summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_disk_file.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2005-02-11 15:37:26 +0000
committerCorinna Vinschen <corinna@vinschen.de>2005-02-11 15:37:26 +0000
commit8be730bbb14e0924efe5c560f0a4b07af5c653eb (patch)
treeec6e0a440fe9b8186f887474eb6f1ed6056ea92c /winsup/cygwin/fhandler_disk_file.cc
parentcc9440b6f42536f9f3b3fca6a6c53155792a51eb (diff)
downloadcygnal-8be730bbb14e0924efe5c560f0a4b07af5c653eb.tar.gz
cygnal-8be730bbb14e0924efe5c560f0a4b07af5c653eb.tar.bz2
cygnal-8be730bbb14e0924efe5c560f0a4b07af5c653eb.zip
* 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.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc41
1 files changed, 26 insertions, 15 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 454ab11ab..129e9ce6b 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -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 ();
}