* 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:
parent
cc9440b6f4
commit
8be730bbb1
|
@ -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>
|
2005-02-11 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
* cygthread.cc (cygthread::release): Reset ev here if it exists.
|
* cygthread.cc (cygthread::release): Reset ev here if it exists.
|
||||||
|
|
|
@ -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 (!WriteFile (get_output_handle (), ptr, len, &bytes_written, 0))
|
||||||
{
|
{
|
||||||
if (GetLastError () == ERROR_DISK_FULL && bytes_written > 0)
|
if (GetLastError () == ERROR_DISK_FULL && bytes_written > 0)
|
||||||
return bytes_written;
|
goto written;
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
if (get_errno () == EPIPE)
|
if (get_errno () == EPIPE)
|
||||||
raise (SIGPIPE);
|
raise (SIGPIPE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
written:
|
||||||
|
has_changed (true);
|
||||||
return bytes_written;
|
return bytes_written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,12 +91,14 @@ class fhandler_base
|
||||||
read or write access */
|
read or write access */
|
||||||
unsigned close_on_exec : 1; /* close-on-exec */
|
unsigned close_on_exec : 1; /* close-on-exec */
|
||||||
unsigned need_fork_fixup : 1; /* Set if need to fixup after fork. */
|
unsigned need_fork_fixup : 1; /* Set if need to fixup after fork. */
|
||||||
|
unsigned has_changed : 1; /* Flag used to set ctime on close. */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
status_flags () :
|
status_flags () :
|
||||||
rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0),
|
rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0),
|
||||||
uninterruptible_io (0), append_mode (0), did_lseek (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;
|
} status, open_status;
|
||||||
|
|
||||||
|
@ -177,6 +179,7 @@ class fhandler_base
|
||||||
IMPLEMENT_STATUS_FLAG (query_state, query_open)
|
IMPLEMENT_STATUS_FLAG (query_state, query_open)
|
||||||
IMPLEMENT_STATUS_FLAG (bool, close_on_exec)
|
IMPLEMENT_STATUS_FLAG (bool, close_on_exec)
|
||||||
IMPLEMENT_STATUS_FLAG (bool, need_fork_fixup)
|
IMPLEMENT_STATUS_FLAG (bool, need_fork_fixup)
|
||||||
|
IMPLEMENT_STATUS_FLAG (bool, has_changed)
|
||||||
|
|
||||||
int get_default_fmode (int flags);
|
int get_default_fmode (int flags);
|
||||||
|
|
||||||
|
|
|
@ -405,10 +405,10 @@ fhandler_disk_file::fchmod (mode_t mode)
|
||||||
if (!get_io_handle () && pc.has_acls ())
|
if (!get_io_handle () && pc.has_acls ())
|
||||||
{
|
{
|
||||||
/* Open for writing required to be able to set ctime. */
|
/* 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);
|
query_open (query_write_control);
|
||||||
if (!(oret = open_fs (O_BINARY, 0)))
|
if (!(oret = open (O_BINARY, 0)))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -435,11 +435,12 @@ fhandler_disk_file::fchmod (mode_t mode)
|
||||||
/* Correct NTFS security attributes have higher priority */
|
/* Correct NTFS security attributes have higher priority */
|
||||||
res = 0;
|
res = 0;
|
||||||
|
|
||||||
|
/* Set ctime on success. */
|
||||||
if (!res && !query_open ())
|
if (!res && !query_open ())
|
||||||
touch_ctime ();
|
has_changed (true);
|
||||||
|
|
||||||
if (oret)
|
if (oret)
|
||||||
close_fs ();
|
close ();
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -460,10 +461,10 @@ fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid)
|
||||||
if (!get_io_handle ())
|
if (!get_io_handle ())
|
||||||
{
|
{
|
||||||
/* Open for writing required to be able to set ctime. */
|
/* 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);
|
query_open (query_write_control);
|
||||||
if (!(oret = open_fs (O_BINARY, 0)))
|
if (!(oret = open (O_BINARY, 0)))
|
||||||
return -1;
|
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,
|
res = set_file_attribute (pc.has_acls (), get_io_handle (), pc,
|
||||||
uid, gid, attrib);
|
uid, gid, attrib);
|
||||||
|
/* Set ctime on success. */
|
||||||
if (!res && !query_open ())
|
if (!res && !query_open ())
|
||||||
touch_ctime ();
|
has_changed (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oret)
|
if (oret)
|
||||||
close_fs ();
|
close ();
|
||||||
|
|
||||||
return res;
|
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
|
/* Open for writing required to be able to set ctime
|
||||||
(even though setting the ACL is just pretended). */
|
(even though setting the ACL is just pretended). */
|
||||||
if (!get_io_handle ())
|
if (!get_io_handle ())
|
||||||
oret = open_fs (O_WRONLY | O_BINARY, 0);
|
oret = open (O_WRONLY | O_BINARY, 0);
|
||||||
res = 0;
|
res = 0;
|
||||||
break;
|
break;
|
||||||
case GETACL:
|
case GETACL:
|
||||||
|
@ -515,7 +517,7 @@ fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp)
|
||||||
if (!get_io_handle ())
|
if (!get_io_handle ())
|
||||||
{
|
{
|
||||||
query_open (query_read_control);
|
query_open (query_read_control);
|
||||||
if (!(oret = open_fs (O_BINARY, 0)))
|
if (!(oret = open (O_BINARY, 0)))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!fstat_by_handle (&st))
|
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. */
|
/* Open for writing required to be able to set ctime. */
|
||||||
if (cmd == SETACL)
|
if (cmd == SETACL)
|
||||||
oret = open_fs (O_WRONLY | O_BINARY, 0);
|
oret = open (O_WRONLY | O_BINARY, 0);
|
||||||
if (!oret)
|
if (!oret)
|
||||||
{
|
{
|
||||||
query_open (cmd == SETACL ? query_write_control
|
query_open (cmd == SETACL ? query_write_control
|
||||||
: query_read_control);
|
: query_read_control);
|
||||||
if (!(oret = open_fs (O_BINARY, 0)))
|
if (!(oret = open (O_BINARY, 0)))
|
||||||
return -1;
|
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 ())
|
if (!res && cmd == SETACL && !query_open ())
|
||||||
touch_ctime ();
|
has_changed (true);
|
||||||
|
|
||||||
if (oret)
|
if (oret)
|
||||||
close_fs ();
|
close ();
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -630,8 +633,9 @@ fhandler_disk_file::ftruncate (_off64_t length)
|
||||||
res = res_bug;
|
res = res_bug;
|
||||||
/* restore original file pointer location */
|
/* restore original file pointer location */
|
||||||
lseek (prev_loc, SEEK_SET);
|
lseek (prev_loc, SEEK_SET);
|
||||||
|
/* Set ctime on success. */
|
||||||
if (!res)
|
if (!res)
|
||||||
touch_ctime ();
|
has_changed (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -692,6 +696,10 @@ fhandler_base::open_fs (int flags, mode_t mode)
|
||||||
&& !allow_ntsec && allow_ntea)
|
&& !allow_ntsec && allow_ntea)
|
||||||
set_file_attribute (false, NULL, get_win32_name (), mode);
|
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 ());
|
set_fs_flags (pc.fs_flags ());
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
@ -703,6 +711,9 @@ out:
|
||||||
int
|
int
|
||||||
fhandler_disk_file::close ()
|
fhandler_disk_file::close ()
|
||||||
{
|
{
|
||||||
|
/* Changing file data requires setting ctime. */
|
||||||
|
if (has_changed ())
|
||||||
|
touch_ctime ();
|
||||||
return close_fs ();
|
return close_fs ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue