* dtable.cc (dtable::set_file_pointers_for_exec): Call SetFilePointer

correctly for 64 bit file access.  Comment out functionality.
	* fhandler.cc (fhandler_base::open): Don't set append_mode.
	(fhandler_base::write): Check for O_APPEND instead of append_mode.
	Call SetFilePointer correctly for 64 bit file access.  Handle
	errors from SetFilePointer.
	* fhandler.h (class fhandler_base): Drop append_mode status flag.
	* fhandler_disk_file.cc (fhandler_base::fstat_helper): Handle
	seeking correctly for 64 bit file access.
This commit is contained in:
Corinna Vinschen 2007-05-29 17:25:36 +00:00
parent 8a11b13ff0
commit ad4e943fca
5 changed files with 34 additions and 13 deletions

View File

@ -1,3 +1,15 @@
2007-05-29 Corinna Vinschen <corinna@vinschen.de>
* dtable.cc (dtable::set_file_pointers_for_exec): Call SetFilePointer
correctly for 64 bit file access. Comment out functionality.
* fhandler.cc (fhandler_base::open): Don't set append_mode.
(fhandler_base::write): Check for O_APPEND instead of append_mode.
Call SetFilePointer correctly for 64 bit file access. Handle
errors from SetFilePointer.
* fhandler.h (class fhandler_base): Drop append_mode status flag.
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Handle
seeking correctly for 64 bit file access.
2007-05-22 Corinna Vinschen <corinna@vinschen.de>
* path.cc (cwdstuff::set): Revert useless acquire check.

View File

@ -690,12 +690,16 @@ dtable::fixup_before_exec (DWORD target_proc_id)
void
dtable::set_file_pointers_for_exec ()
{
/* This is not POSIX-compliant. */
#if 0
LONG off_high = 0;
lock ();
fhandler_base *fh;
for (size_t i = 0; i < size; i++)
if ((fh = fds[i]) != NULL && fh->get_flags () & O_APPEND)
SetFilePointer (fh->get_handle (), 0, 0, FILE_END);
SetFilePointer (fh->get_handle (), 0, &off_high, FILE_END);
unlock ();
#endif
}
void

View File

@ -550,9 +550,6 @@ fhandler_base::open (int flags, mode_t mode)
if ((flags & O_EXCL) && (flags & O_CREAT))
create_disposition = FILE_CREATE;
if (flags & O_APPEND)
append_mode (true);
if (flags & O_CREAT && get_device () == FH_FS)
{
file_attributes = FILE_ATTRIBUTE_NORMAL;
@ -711,8 +708,17 @@ fhandler_base::write (const void *ptr, size_t len)
{
int res;
if (append_mode ())
SetFilePointer (get_output_handle (), 0, 0, FILE_END);
if (get_flags () & O_APPEND)
{
LONG off_high = 0;
DWORD ret = SetFilePointer (get_output_handle (), 0, &off_high, FILE_END);
if (ret == INVALID_SET_FILE_POINTER && GetLastError () != NO_ERROR)
{
debug_printf ("Seeking to EOF in append mode failed");
__seterrno ();
return -1;
}
}
else if (did_lseek ())
{
_off64_t actual_length, current_position;

View File

@ -101,7 +101,6 @@ class fhandler_base
unsigned wbinset : 1; /* binary write mode explicitly set */
unsigned nohandle : 1; /* No handle associated with fhandler. */
unsigned uninterruptible_io : 1; /* Set if I/O should be uninterruptible. */
unsigned append_mode : 1; /* always append */
unsigned did_lseek : 1; /* set when lseek is called as a flag that
_write should check if we've moved
beyond EOF, zero filling or making
@ -114,7 +113,7 @@ class fhandler_base
public:
status_flags () :
rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0),
uninterruptible_io (0), append_mode (0), did_lseek (0),
uninterruptible_io (0), did_lseek (0),
query_open (no_query), close_on_exec (0), need_fork_fixup (0)
{}
} status, open_status;
@ -191,7 +190,6 @@ class fhandler_base
IMPLEMENT_STATUS_FLAG (bool, rbinset)
IMPLEMENT_STATUS_FLAG (bool, nohandle)
IMPLEMENT_STATUS_FLAG (bool, uninterruptible_io)
IMPLEMENT_STATUS_FLAG (bool, append_mode)
IMPLEMENT_STATUS_FLAG (bool, did_lseek)
IMPLEMENT_STATUS_FLAG (query_state, query_open)
IMPLEMENT_STATUS_FLAG (bool, close_on_exec)

View File

@ -493,13 +493,14 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
if (pc.exec_state () == dont_know_if_executable)
{
DWORD cur, done;
LONG curhigh = 0;
char magic[3];
/* First retrieve current position, set to beginning
of file if not already there. */
cur = SetFilePointer (get_handle (), 0, NULL, FILE_CURRENT);
if (cur != INVALID_SET_FILE_POINTER
&& (!cur || SetFilePointer (get_handle (), 0, NULL, FILE_BEGIN)
cur = SetFilePointer (get_handle (), 0, &curhigh, FILE_CURRENT);
if ((cur != INVALID_SET_FILE_POINTER || GetLastError () == NO_ERROR)
&& ((!cur && !curhigh) || SetFilePointer (get_handle (), 0, NULL, FILE_BEGIN)
!= INVALID_SET_FILE_POINTER))
{
/* FIXME should we use /etc/magic ? */
@ -510,7 +511,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
pc.set_exec ();
buf->st_mode |= STD_XBITS;
}
SetFilePointer (get_handle (), cur, NULL, FILE_BEGIN);
SetFilePointer (get_handle (), cur, &curhigh, FILE_BEGIN);
}
}
}