diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2016-06-24 13:39:42 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2016-06-24 13:40:02 +0200 |
commit | 166d3ddf5a04d6f915f9eb3c7befc50a2a40edfc (patch) | |
tree | 61c868b77afab8b6d2eb8286b3fa5d9643d3ceea /winsup/cygwin/fhandler_floppy.cc | |
parent | 9aab8eb5b6fe88deca2274ddd1695d41ca28346c (diff) | |
download | newlib-166d3ddf5a04d6f915f9eb3c7befc50a2a40edfc.zip newlib-166d3ddf5a04d6f915f9eb3c7befc50a2a40edfc.tar.gz newlib-166d3ddf5a04d6f915f9eb3c7befc50a2a40edfc.tar.bz2 |
Fix major device check when locking partitions
The change introduced in commit b2867a6 contains a faulty check for
the major device number in fhandler_dev_floppy::lock_partition.
Fix this. Also fix comments.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/fhandler_floppy.cc')
-rw-r--r-- | winsup/cygwin/fhandler_floppy.cc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc index 8c9ef9d..1bb3aca 100644 --- a/winsup/cygwin/fhandler_floppy.cc +++ b/winsup/cygwin/fhandler_floppy.cc @@ -159,9 +159,9 @@ fhandler_dev_floppy::lock_partition (DWORD to_write) /* The simple case. We have only a single partition open anyway. Try to lock the partition so that a subsequent write succeeds. If there's some file handle open on one of the affected partitions, - this fails, but that's how it works on Vista and later... - Only DEV_SD7_MAJOR and less can point to partition 0. */ - if (get_major () <= DEV_SD7_MAJOR && get_minor () % 16 != 0) + this fails, but that's how it works... + The high partition major numbers don't have a partition 0. */ + if (get_major () >= DEV_SD_HIGHPART_START || get_minor () % 16 != 0) { if (!DeviceIoControl (get_handle (), FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &bytes_read, NULL)) @@ -297,13 +297,10 @@ fhandler_dev_floppy::write_file (const void *buf, DWORD to_write, *err = 0; if (!(ret = WriteFile (get_handle (), buf, to_write, written, 0))) *err = GetLastError (); - /* When writing to a disk or partition on Vista, an "Access denied" error - is potentially a result of the raw disk write restriction. See - http://support.microsoft.com/kb/942448 for details. What we have to - do here is to lock the partition and retry. The previous solution - locked one or all partitions immediately in open. Which is overly - wasteful, given that the user might only want to change, say, the boot - sector. */ + /* When writing to a disk or partition an "Access denied" error may + occur due to the raw disk write restriction. + See http://support.microsoft.com/kb/942448 for details. + What we do here is to lock the affected partition(s) and retry. */ if (*err == ERROR_ACCESS_DENIED && wincap.has_restricted_raw_disk_access () && get_major () != DEV_FLOPPY_MAJOR |