Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2005-02-11 18:37:26 +0300
committerCorinna Vinschen <corinna@vinschen.de>2005-02-11 18:37:26 +0300
commit8be730bbb14e0924efe5c560f0a4b07af5c653eb (patch)
treeec6e0a440fe9b8186f887474eb6f1ed6056ea92c /winsup
parentcc9440b6f42536f9f3b3fca6a6c53155792a51eb (diff)
* 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')
-rw-r--r--winsup/cygwin/ChangeLog15
-rw-r--r--winsup/cygwin/fhandler.cc4
-rw-r--r--winsup/cygwin/fhandler.h5
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc41
4 files changed, 48 insertions, 17 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index c0d120815..9ca6626c5 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,18 @@
+2005-02-11 Corinna Vinschen <corinna@vinschen.de>
+
+ * 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.
+
2005-02-11 Christopher Faylor <cgf@timesys.com>
* cygthread.cc (cygthread::release): Reset ev here if it exists.
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index ab588b500..3fd0bc74b 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -288,12 +288,14 @@ fhandler_base::raw_write (const void *ptr, size_t len)
if (!WriteFile (get_output_handle (), ptr, len, &bytes_written, 0))
{
if (GetLastError () == ERROR_DISK_FULL && bytes_written > 0)
- return bytes_written;
+ goto written;
__seterrno ();
if (get_errno () == EPIPE)
raise (SIGPIPE);
return -1;
}
+written:
+ has_changed (true);
return bytes_written;
}
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 2f2f01706..8a871cb8b 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -91,12 +91,14 @@ class fhandler_base
read or write access */
unsigned close_on_exec : 1; /* close-on-exec */
unsigned need_fork_fixup : 1; /* Set if need to fixup after fork. */
+ unsigned has_changed : 1; /* Flag used to set ctime on close. */
public:
status_flags () :
rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0),
uninterruptible_io (0), append_mode (0), did_lseek (0),
- query_open (no_query), close_on_exec (0), need_fork_fixup (0)
+ query_open (no_query), close_on_exec (0), need_fork_fixup (0),
+ has_changed (0)
{}
} status, open_status;
@@ -177,6 +179,7 @@ class fhandler_base
IMPLEMENT_STATUS_FLAG (query_state, query_open)
IMPLEMENT_STATUS_FLAG (bool, close_on_exec)
IMPLEMENT_STATUS_FLAG (bool, need_fork_fixup)
+ IMPLEMENT_STATUS_FLAG (bool, has_changed)
int get_default_fmode (int flags);
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 ();
}