* 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:
parent
8a11b13ff0
commit
ad4e943fca
|
@ -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>
|
2007-05-22 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* path.cc (cwdstuff::set): Revert useless acquire check.
|
* path.cc (cwdstuff::set): Revert useless acquire check.
|
||||||
|
|
|
@ -690,12 +690,16 @@ dtable::fixup_before_exec (DWORD target_proc_id)
|
||||||
void
|
void
|
||||||
dtable::set_file_pointers_for_exec ()
|
dtable::set_file_pointers_for_exec ()
|
||||||
{
|
{
|
||||||
|
/* This is not POSIX-compliant. */
|
||||||
|
#if 0
|
||||||
|
LONG off_high = 0;
|
||||||
lock ();
|
lock ();
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
for (size_t i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
if ((fh = fds[i]) != NULL && fh->get_flags () & O_APPEND)
|
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 ();
|
unlock ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -550,9 +550,6 @@ fhandler_base::open (int flags, mode_t mode)
|
||||||
if ((flags & O_EXCL) && (flags & O_CREAT))
|
if ((flags & O_EXCL) && (flags & O_CREAT))
|
||||||
create_disposition = FILE_CREATE;
|
create_disposition = FILE_CREATE;
|
||||||
|
|
||||||
if (flags & O_APPEND)
|
|
||||||
append_mode (true);
|
|
||||||
|
|
||||||
if (flags & O_CREAT && get_device () == FH_FS)
|
if (flags & O_CREAT && get_device () == FH_FS)
|
||||||
{
|
{
|
||||||
file_attributes = FILE_ATTRIBUTE_NORMAL;
|
file_attributes = FILE_ATTRIBUTE_NORMAL;
|
||||||
|
@ -711,8 +708,17 @@ fhandler_base::write (const void *ptr, size_t len)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (append_mode ())
|
if (get_flags () & O_APPEND)
|
||||||
SetFilePointer (get_output_handle (), 0, 0, FILE_END);
|
{
|
||||||
|
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 ())
|
else if (did_lseek ())
|
||||||
{
|
{
|
||||||
_off64_t actual_length, current_position;
|
_off64_t actual_length, current_position;
|
||||||
|
|
|
@ -101,7 +101,6 @@ class fhandler_base
|
||||||
unsigned wbinset : 1; /* binary write mode explicitly set */
|
unsigned wbinset : 1; /* binary write mode explicitly set */
|
||||||
unsigned nohandle : 1; /* No handle associated with fhandler. */
|
unsigned nohandle : 1; /* No handle associated with fhandler. */
|
||||||
unsigned uninterruptible_io : 1; /* Set if I/O should be uninterruptible. */
|
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
|
unsigned did_lseek : 1; /* set when lseek is called as a flag that
|
||||||
_write should check if we've moved
|
_write should check if we've moved
|
||||||
beyond EOF, zero filling or making
|
beyond EOF, zero filling or making
|
||||||
|
@ -114,7 +113,7 @@ class fhandler_base
|
||||||
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), 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)
|
||||||
{}
|
{}
|
||||||
} status, open_status;
|
} status, open_status;
|
||||||
|
@ -191,7 +190,6 @@ class fhandler_base
|
||||||
IMPLEMENT_STATUS_FLAG (bool, rbinset)
|
IMPLEMENT_STATUS_FLAG (bool, rbinset)
|
||||||
IMPLEMENT_STATUS_FLAG (bool, nohandle)
|
IMPLEMENT_STATUS_FLAG (bool, nohandle)
|
||||||
IMPLEMENT_STATUS_FLAG (bool, uninterruptible_io)
|
IMPLEMENT_STATUS_FLAG (bool, uninterruptible_io)
|
||||||
IMPLEMENT_STATUS_FLAG (bool, append_mode)
|
|
||||||
IMPLEMENT_STATUS_FLAG (bool, did_lseek)
|
IMPLEMENT_STATUS_FLAG (bool, did_lseek)
|
||||||
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)
|
||||||
|
|
|
@ -493,13 +493,14 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
|
||||||
if (pc.exec_state () == dont_know_if_executable)
|
if (pc.exec_state () == dont_know_if_executable)
|
||||||
{
|
{
|
||||||
DWORD cur, done;
|
DWORD cur, done;
|
||||||
|
LONG curhigh = 0;
|
||||||
char magic[3];
|
char magic[3];
|
||||||
|
|
||||||
/* First retrieve current position, set to beginning
|
/* First retrieve current position, set to beginning
|
||||||
of file if not already there. */
|
of file if not already there. */
|
||||||
cur = SetFilePointer (get_handle (), 0, NULL, FILE_CURRENT);
|
cur = SetFilePointer (get_handle (), 0, &curhigh, FILE_CURRENT);
|
||||||
if (cur != INVALID_SET_FILE_POINTER
|
if ((cur != INVALID_SET_FILE_POINTER || GetLastError () == NO_ERROR)
|
||||||
&& (!cur || SetFilePointer (get_handle (), 0, NULL, FILE_BEGIN)
|
&& ((!cur && !curhigh) || SetFilePointer (get_handle (), 0, NULL, FILE_BEGIN)
|
||||||
!= INVALID_SET_FILE_POINTER))
|
!= INVALID_SET_FILE_POINTER))
|
||||||
{
|
{
|
||||||
/* FIXME should we use /etc/magic ? */
|
/* FIXME should we use /etc/magic ? */
|
||||||
|
@ -510,7 +511,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
|
||||||
pc.set_exec ();
|
pc.set_exec ();
|
||||||
buf->st_mode |= STD_XBITS;
|
buf->st_mode |= STD_XBITS;
|
||||||
}
|
}
|
||||||
SetFilePointer (get_handle (), cur, NULL, FILE_BEGIN);
|
SetFilePointer (get_handle (), cur, &curhigh, FILE_BEGIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue