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>
This commit is contained in:
Corinna Vinschen 2016-06-24 13:39:42 +02:00
parent 9aab8eb5b6
commit 166d3ddf5a
1 changed files with 7 additions and 10 deletions

View File

@ -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