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:
Diffstat (limited to 'winsup/cygwin/fhandler_floppy.cc')
-rw-r--r--winsup/cygwin/fhandler_floppy.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc
index de9e163e5..cca00bab8 100644
--- a/winsup/cygwin/fhandler_floppy.cc
+++ b/winsup/cygwin/fhandler_floppy.cc
@@ -566,11 +566,11 @@ fhandler_dev_floppy::raw_write (const void *ptr, size_t len)
/* Align pointers, lengths, etc. */
cplen = MIN (cplen, written);
devbufstart += cplen;
+ if (devbufstart >= devbufend)
+ devbufstart = devbufend = 0;
p += cplen;
len -= cplen;
bytes_written += cplen;
- if (len)
- devbufstart = devbufend = 0;
}
/* As long as there's still something left in the input buffer ... */
while (len)
@@ -607,6 +607,14 @@ fhandler_dev_floppy::raw_write (const void *ptr, size_t len)
p += cplen;
len -= cplen;
bytes_written += cplen;
+ /* If we overwrote, revalidate devbuf. It still contains the
+ content from the above read/modify/write. Revalidating makes
+ sure lseek reports the correct position. */
+ if (cplen < bytes_per_sector)
+ {
+ devbufstart = cplen;
+ devbufend = bytes_per_sector;
+ }
}
return bytes_written;
}