diff options
author | Christopher Faylor <me@cgf.cx> | 2005-07-29 17:26:10 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2005-07-29 17:26:10 +0000 |
commit | 88c5a50f9f1982b1ae8cc16350fbc9b60502d88a (patch) | |
tree | a67eef3ba9f12719789e50caa300604dd2dab75f /winsup/cygwin | |
parent | ca4870999679e833bfaa85dacbea74b5cbb49ff4 (diff) | |
download | cygnal-88c5a50f9f1982b1ae8cc16350fbc9b60502d88a.tar.gz cygnal-88c5a50f9f1982b1ae8cc16350fbc9b60502d88a.tar.bz2 cygnal-88c5a50f9f1982b1ae8cc16350fbc9b60502d88a.zip |
* fhandler_disk_file.cc (fhandler_base::pread): Don't move file offset pointer
after I/O.
(fhandler_base::pwrite): Ditto.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 25 |
2 files changed, 25 insertions, 6 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 93eaaf721..0b477b571 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,11 @@ 2005-07-29 Christopher Faylor <cgf@timesys.com> + * fhandler_disk_file.cc (fhandler_base::pread): Don't move file offset + pointer after I/O. + (fhandler_base::pwrite): Ditto. + +2005-07-29 Christopher Faylor <cgf@timesys.com> + * fhandler.h (fhandler_base::pread): Declare new function. (fhandler_base::pwrite): Ditto. (fhandler_disk_file::pread): Ditto. diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 76fe9b393..3b3388c6f 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -987,12 +987,18 @@ fhandler_base::close_fs () ssize_t __stdcall fhandler_disk_file::pread (void *buf, size_t count, _off64_t offset) { - ssize_t res = lseek (offset, SEEK_SET); - if (res >= 0) + ssize_t res; + _off64_t curpos = lseek (0, SEEK_CUR); + if (curpos < 0 || lseek (offset, SEEK_SET) < 0) + res = -1; + else { size_t tmp_count = count; read (buf, tmp_count); - res = (ssize_t) tmp_count; + if (lseek (curpos, SEEK_SET) == 0) + res = (ssize_t) tmp_count; + else + res = -1; } debug_printf ("%d = pread (%p, %d, %d)\n", res, buf, count, offset); return res; @@ -1001,9 +1007,16 @@ fhandler_disk_file::pread (void *buf, size_t count, _off64_t offset) ssize_t __stdcall fhandler_disk_file::pwrite (void *buf, size_t count, _off64_t offset) { - ssize_t res = lseek (offset, SEEK_SET); - if (res >= 0) - res = write (buf, count); + int res; + _off64_t curpos = lseek (0, SEEK_CUR); + if (curpos < 0 || lseek (offset, SEEK_SET) < 0) + res = curpos; + else + { + res = (ssize_t) write (buf, count); + if (lseek (curpos, SEEK_SET) < 0) + res = -1; + } debug_printf ("%d = pwrite (%p, %d, %d)\n", res, buf, count, offset); return res; } |