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
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2007-05-29 21:25:36 +0400
committerCorinna Vinschen <corinna@vinschen.de>2007-05-29 21:25:36 +0400
commitad4e943fca1d5f03a1d23c742365d39d374ff942 (patch)
treee592a3480766d8ef3569fa54bcf5c0eef7100c05
parent8a11b13ff0f6d3e673f23060dca76d6358f4ac3f (diff)
* 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.
-rw-r--r--winsup/cygwin/ChangeLog12
-rw-r--r--winsup/cygwin/dtable.cc6
-rw-r--r--winsup/cygwin/fhandler.cc16
-rw-r--r--winsup/cygwin/fhandler.h4
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc9
5 files changed, 34 insertions, 13 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 2b72ec8df..3907da467 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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.
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index 17efacb69..c40b5e6ae 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -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
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 5f46484f9..5490d3ab0 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -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;
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 839fc4b05..814054399 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -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)
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index d510ff0f0..353c45ba5 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -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);
}
}
}