Blame SOURCES/0043-v2v-windows-Do-not-fix-NTFS-heads-in-Windows-Vista-a.patch

62f9b7
From 72f50e52515369ef8decda9493422d6235f5b365 Mon Sep 17 00:00:00 2001
62f9b7
From: "Richard W.M. Jones" <rjones@redhat.com>
62f9b7
Date: Wed, 18 Aug 2021 11:00:12 +0100
62f9b7
Subject: [PATCH] v2v: windows: Do not fix NTFS heads in Windows Vista and
62f9b7
 later
62f9b7
62f9b7
Setting/adjusting the number of drive heads in the NTFS header is only
62f9b7
necessary for ancient versions of Windows.  Modern versions ignore
62f9b7
this.  In addition this operation broke when we added BitLocker
62f9b7
support.  Only do this for ancient Windows 2000/XP and skip it for
62f9b7
everything else.
62f9b7
62f9b7
Reported-by: Ming Xie
62f9b7
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1994984
62f9b7
(cherry picked from commit 0a394c5c2f802098c9e481b4bacee7821e5dd0ae)
62f9b7
---
62f9b7
 v2v/convert_windows.ml | 44 ++++++++++++++++++++++--------------------
62f9b7
 1 file changed, 23 insertions(+), 21 deletions(-)
62f9b7
62f9b7
diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
62f9b7
index 33fbd410..13de10cb 100644
62f9b7
--- a/v2v/convert_windows.ml
62f9b7
+++ b/v2v/convert_windows.ml
62f9b7
@@ -730,30 +730,32 @@ if errorlevel 3010 exit /b 0
62f9b7
        however, as this is specific to Windows 2003 it lists location
62f9b7
        0x1A as unused.
62f9b7
     *)
62f9b7
-    let rootpart = inspect.i_root in
62f9b7
+    if inspect.i_major_version < 6 (* is Windows 2000/XP *) then (
62f9b7
+      let rootpart = inspect.i_root in
62f9b7
 
62f9b7
-    (* Ignore if the rootpart is something like /dev/sda.  RHBZ#1276540. *)
62f9b7
-    if not (g#is_whole_device rootpart) then (
62f9b7
-      (* Check that the root device contains NTFS magic. *)
62f9b7
-      let magic = g#pread_device rootpart 8 3L in
62f9b7
-      if magic = "NTFS    " then (
62f9b7
-        (* Get the size of the whole disk containing the root partition. *)
62f9b7
-        let rootdev = g#part_to_dev rootpart in (* eg. /dev/sda *)
62f9b7
-        let size = g#blockdev_getsize64 rootdev in
62f9b7
+      (* Ignore if the rootpart is something like /dev/sda.  RHBZ#1276540. *)
62f9b7
+      if not (g#is_whole_device rootpart) then (
62f9b7
+        (* Check that the root device contains NTFS magic. *)
62f9b7
+        let magic = g#pread_device rootpart 8 3L in
62f9b7
+        if magic = "NTFS    " then (
62f9b7
+          (* Get the size of the whole disk containing the root partition. *)
62f9b7
+          let rootdev = g#part_to_dev rootpart in (* eg. /dev/sda *)
62f9b7
+          let size = g#blockdev_getsize64 rootdev in
62f9b7
 
62f9b7
-        let heads =             (* refer to the table above *)
62f9b7
-          if size < 2114445312L then 0x40
62f9b7
-          else if size < 4228374780L then 0x80
62f9b7
-          else 0xff in
62f9b7
+          let heads =             (* refer to the table above *)
62f9b7
+            if size < 2114445312L then 0x40
62f9b7
+            else if size < 4228374780L then 0x80
62f9b7
+            else 0xff in
62f9b7
 
62f9b7
-        (* Update NTFS's idea of the number of heads.  This is an
62f9b7
-         * unsigned 16 bit little-endian integer, offset 0x1a from the
62f9b7
-         * beginning of the partition.
62f9b7
-         *)
62f9b7
-        let b = Bytes.create 2 in
62f9b7
-        Bytes.unsafe_set b 0 (Char.chr heads);
62f9b7
-        Bytes.unsafe_set b 1 '\000';
62f9b7
-        ignore (g#pwrite_device rootpart (Bytes.to_string b) 0x1a_L)
62f9b7
+          (* Update NTFS's idea of the number of heads.  This is an
62f9b7
+           * unsigned 16 bit little-endian integer, offset 0x1a from the
62f9b7
+           * beginning of the partition.
62f9b7
+           *)
62f9b7
+          let b = Bytes.create 2 in
62f9b7
+          Bytes.unsafe_set b 0 (Char.chr heads);
62f9b7
+          Bytes.unsafe_set b 1 '\000';
62f9b7
+          ignore (g#pwrite_device rootpart (Bytes.to_string b) 0x1a_L)
62f9b7
+        )
62f9b7
       )
62f9b7
     )
62f9b7
 
62f9b7
-- 
0602f3
2.31.1
62f9b7