* dcrt0.cc (dll_crt0_1): Don't call set_cygwin_privileges on 9x.

* fhandler.h (enum change_state): Add.
	(fhandler_base::status): Add a bit to has_changed flag.
	(fhandler_base::has_changed): Implement with type change_state.
	* fhandler.cc (fhandler_base::raw_write): Accomodate type change
	of has_changed.
	* fhandler_disk_file.cc )fhandler_disk_file::touch_ctime): Also
	touch modification time if has_changed == data_changed.
	(fhandler_disk_file::fchmod): Also open on 9x, otherwise we can't
	touch ctime.  Accomodate type change of has_changed.
	(fhandler_disk_file::fchown): Accomodate type change of has_changed.
	(fhandler_disk_file::facl): Ditto.
	(fhandler_disk_file::ftruncate): Ditto.
	(fhandler_disk_file::link): Ditto.
	(fhandler_base::open_fs): Ditto.
This commit is contained in:
Corinna Vinschen 2005-04-04 10:26:35 +00:00
parent 24e2f8b482
commit e6d598eee0
5 changed files with 52 additions and 22 deletions

View File

@ -1,3 +1,22 @@
2005-04-04 Corinna Vinschen <corinna@vinschen.de>
* dcrt0.cc (dll_crt0_1): Don't call set_cygwin_privileges on 9x.
* fhandler.h (enum change_state): Add.
(fhandler_base::status): Add a bit to has_changed flag.
(fhandler_base::has_changed): Implement with type change_state.
* fhandler.cc (fhandler_base::raw_write): Accomodate type change
of has_changed.
* fhandler_disk_file.cc )fhandler_disk_file::touch_ctime): Also
touch modification time if has_changed == data_changed.
(fhandler_disk_file::fchmod): Also open on 9x, otherwise we can't
touch ctime. Accomodate type change of has_changed.
(fhandler_disk_file::fchown): Accomodate type change of has_changed.
(fhandler_disk_file::facl): Ditto.
(fhandler_disk_file::ftruncate): Ditto.
(fhandler_disk_file::link): Ditto.
(fhandler_base::open_fs): Ditto.
2005-04-03 Corinna Vinschen <corinna@vinschen.de>
* cygheap.cc (cygheap_init): Accomodate set_process_privilege change.

View File

@ -770,7 +770,8 @@ dll_crt0_1 (char *)
pinfo_init (envp, envc);
/* Can be set only after environment has been initialized. */
set_cygwin_privileges (hProcImpToken);
if (wincap.has_security ())
set_cygwin_privileges (hProcImpToken);
if (!old_title && GetConsoleTitle (title_buf, TITLESIZE))
old_title = title_buf;

View File

@ -295,7 +295,7 @@ fhandler_base::raw_write (const void *ptr, size_t len)
return -1;
}
written:
has_changed (true);
has_changed (data_changed);
return bytes_written;
}

View File

@ -78,6 +78,12 @@ enum query_state {
query_write_attributes = 4
};
enum change_state {
no_change = 0,
inode_changed = 1,
data_changed = 2
};
class fhandler_base
{
friend class dtable;
@ -100,14 +106,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. */
unsigned has_changed : 2; /* 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),
has_changed (0)
has_changed (no_change)
{}
} status, open_status;
@ -188,7 +194,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)
IMPLEMENT_STATUS_FLAG (change_state, has_changed)
int get_default_fmode (int flags);

View File

@ -391,10 +391,13 @@ fhandler_disk_file::touch_ctime (void)
FILETIME ft;
GetSystemTimeAsFileTime (&ft);
if (!SetFileTime (get_io_handle (), &ft, NULL, NULL))
/* Modification time is touched if the file data has changed as well.
This happens for instance on write() or ftruncate(). */
if (!SetFileTime (get_io_handle (), &ft, NULL,
has_changed () == data_changed ? &ft : NULL))
debug_printf ("SetFileTime (%s) failed, %E", get_win32_name ());
else
has_changed (false);
has_changed (no_change);
}
int __stdcall
@ -407,15 +410,16 @@ fhandler_disk_file::fchmod (mode_t mode)
if (pc.is_fs_special ())
return chmod_device (pc, mode);
/* Also open on 9x, otherwise we can't touch ctime. */
if (!get_io_handle ())
{
query_open (query_write_control);
if (!(oret = open (O_BINARY, 0)))
return -1;
}
if (wincap.has_security ())
{
if (!get_io_handle () && pc.has_acls ())
{
query_open (query_write_control);
if (!(oret = open (O_BINARY, 0)))
return -1;
}
if (!allow_ntsec && allow_ntea) /* Not necessary when manipulating SD. */
SetFileAttributes (pc, (DWORD) pc & ~FILE_ATTRIBUTE_READONLY);
if (pc.isdir ())
@ -440,7 +444,7 @@ fhandler_disk_file::fchmod (mode_t mode)
/* Set ctime on success. */
if (!res)
has_changed (true);
has_changed (inode_changed);
if (oret)
close ();
@ -477,7 +481,7 @@ fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid)
uid, gid, attrib);
/* Set ctime on success. */
if (!res)
has_changed (true);
has_changed (inode_changed);
}
if (oret)
@ -574,7 +578,7 @@ fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp)
/* Set ctime on success. */
if (!res && cmd == SETACL)
has_changed (true);
has_changed (inode_changed);
if (oret)
close ();
@ -624,7 +628,7 @@ fhandler_disk_file::ftruncate (_off64_t length)
lseek (prev_loc, SEEK_SET);
/* Set ctime on success. */
if (!res)
has_changed (true);
has_changed (data_changed);
}
}
return res;
@ -757,7 +761,7 @@ fhandler_disk_file::link (const char *newpath)
success:
/* Set ctime on success. */
has_changed (true);
has_changed (inode_changed);
close ();
if (!allow_winsymlinks && pc.is_lnk_symlink ())
SetFileAttributes (newpc, (DWORD) pc
@ -773,13 +777,13 @@ docopy:
return -1;
}
/* Set ctime on success, also on the copy. */
has_changed (true);
has_changed (inode_changed);
close ();
fhandler_disk_file fh (newpc);
fh.query_open (query_write_attributes);
if (fh.open (O_BINARY, 0))
{
fh.has_changed (true);
fh.has_changed (inode_changed);
fh.close ();
}
return 0;
@ -895,7 +899,7 @@ fhandler_base::open_fs (int flags, mode_t mode)
/* O_TRUNC on existing file requires setting ctime. */
if ((flags & (O_CREAT | O_TRUNC)) == O_TRUNC)
has_changed (true);
has_changed (data_changed);
set_fs_flags (pc.fs_flags ());