[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16231: [PATCH 8/9] libparted: don't trash filesystem when writing lo
From: |
Phillip Susi |
Subject: |
bug#16231: [PATCH 8/9] libparted: don't trash filesystem when writing loop label |
Date: |
Fri, 2 May 2014 21:50:50 -0400 |
If you deleted the fake partition on a loop label, loop_write() would write
the loop signature to the device, zeroing out all other bytes in the first
sector. When the disk contained an ext[234] filesystem and was using 2k
sectors, this would trash the super block residing in the 1-2kb part of the
sector causing the disk to become unrecognized. Instead, read the existing
sector and only modify the first few bytes that contain the loop label.
---
libparted/labels/loop.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libparted/labels/loop.c b/libparted/labels/loop.c
index 8ebb1f4..98f9f23 100644
--- a/libparted/labels/loop.c
+++ b/libparted/labels/loop.c
@@ -170,7 +170,8 @@ loop_write (const PedDisk* disk)
/* if there is already a filesystem on the disk, we don't need to write
the signature */
if (part && part->fs_type)
return 1;
- memset (buf, 0, buflen);
+ if (!ped_device_read (disk->dev, buf, 0, 1))
+ return 0;
strcpy (buf, LOOP_SIGNATURE);
return ped_device_write (disk->dev, buf, 0, 1);
--
1.9.1
- bug#16231: [PATCH 0/9] Refactored loop fixes, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 2/9] libparted: remove old partitions *first* before adding new ones, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 9/9] tests: test loop labels, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 3/9] libparted: remove all old partitions, even if new label allows less, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 1/9] libparted: don't detect fat and ntfs boot sectors as dos MBR, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 6/9] partprobe: do not skip loop labels, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 7/9] libparted: give correct partition device name on loop labels, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 5/9] libparted: don't create partition on loop label, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 8/9] libparted: don't trash filesystem when writing loop label,
Phillip Susi <=
- bug#16231: [PATCH 4/9] libparted: fix loop labels to not vanish, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 0/9] Refactored loop fixes, Brian C. Lane, 2014/05/07
- bug#16231: [PATCH 0/9] Refactored loop fixes, Phillip Susi, 2014/05/07
- bug#16231: [PATCH 0/9] Refactored loop fixes, Brian C. Lane, 2014/05/08
- bug#16231: [PATCH 0/9] Refactored loop fixes, Phillip Susi, 2014/05/19
- bug#16231: [PATCH 0/9] Refactored loop fixes, Brian C. Lane, 2014/05/21
- bug#16231: [PATCH 0/9] Refactored loop fixes, Phillip Susi, 2014/05/22
- bug#16231: [PATCH 0/9] Refactored loop fixes, Brian C. Lane, 2014/05/22
- bug#16231: [PATCH 0/9] Refactored loop fixes, Phillip Susi, 2014/05/22