[core] fix potential "loss" of disk after writing Ubuntu 20.10 in DD mode

* Due to the partition gymnastic that is required by the hack that is ISOHybrid,
  some ISOHybrid images that are written in DD mode, such as Ubuntu 20.10, may
  result in Windows somehow "losing" the target disk from some of its listings.
* This "removal" can be seen for instance if you have diskpart already open and
  issue 'list disk' after Rufus 3.13 completed its image writing.
* In the worst case scenario, Windows may flat out refuse to access the disk at
  the sector level be it in diskpart or disk manager, which forces ones to clear
  the partition tables on Linux or some other OS to be able to "recover" the disk.
* This appears to be mostly due to Windows VDS cache (which Microsoft assures
  should be able to do a proper job of refreshing itself on its own, in the same
  stride as they also feel the need to introduce IVdsService::Refresh whose sole
  purpose appears to work around a limitation that Microsoft knows exists) not
  being in sync with the actual disk layout.
* So we now add calls to VDS layout refresh where needed, to work around the issue.
* Also fix an ext2fs Coverity warning.
This commit is contained in:
Pete Batard 2021-01-15 17:50:57 +00:00
parent 3056d54cc1
commit 20b8a84595
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
5 changed files with 89 additions and 11 deletions

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Formatting function calls
* Copyright © 2011-2020 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2021 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -2181,6 +2181,7 @@ DWORD WINAPI FormatThread(void* param)
}
out:
VdsRescan(VDS_RESCAN_REFRESH, 0, TRUE);
safe_free(volume_name);
safe_free(buffer);
safe_closehandle(hSourceImage);