]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homework: Remove zeroing of PMBR
authorscarlet-storm <12461256+scarlet-storm@users.noreply.github.com>
Fri, 27 Dec 2024 10:26:12 +0000 (15:56 +0530)
committerscarlet-storm <12461256+scarlet-storm@users.noreply.github.com>
Tue, 17 Feb 2026 12:53:35 +0000 (18:23 +0530)
Remove zeroing of PMBR before writing out the new partition table.
There is no reason, to do this explicitly ?

src/home/homework-luks.c

index 7ae0f80985a34d74fcd27121ba66343b8478068a..e559836cc4a4e560aa84b1d5cf9567d63cda8517 100644 (file)
@@ -2856,9 +2856,7 @@ static int apply_resize_partition(
                 size_t new_partition_size) {
 
         _cleanup_(fdisk_unref_contextp) struct fdisk_context *c = NULL;
-        _cleanup_free_ void *two_zero_lbas = NULL;
         uint32_t ssz;
-        ssize_t n;
         int r;
 
         assert(fd >= 0);
@@ -2873,17 +2871,6 @@ static int apply_resize_partition(
         if (r < 0)
                 return log_error_errno(r, "Failed to determine current sector size: %m");
 
-        two_zero_lbas = malloc0(ssz * 2);
-        if (!two_zero_lbas)
-                return log_oom();
-
-        /* libfdisk appears to get confused by the existing PMBR. Let's explicitly flush it out. */
-        n = pwrite(fd, two_zero_lbas, ssz * 2, 0);
-        if (n < 0)
-                return log_error_errno(errno, "Failed to wipe partition table: %m");
-        if ((size_t) n != ssz * 2)
-                return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short write while wiping partition table.");
-
         r = fdisk_new_context_at(fd, /* path= */ NULL, /* read_only= */ false, ssz, &c);
         if (r < 0)
                 return log_error_errno(r, "Failed to open device: %m");