Here's a patch for this. I constructed a table with two FAT partitions on a memory card, hid one partition by changing its type code, and then verified that fatresize would destroy the hidden partition but would leave it intact once I applied this patch to libparted.
I am not going to NMU because I'm unsure whether it's generally a good
idea to leave hidden partitions untouched. If it is, please apply this.
Ben.
#! /bin/sh /usr/share/dpatch/dpatch-run
## preserve-hidden-parts.dpatch by Ben Hutchings <[EMAIL PROTECTED]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: This is an attempt to fix bug #491797. It changes the partition
## DP: rewriting code to set only the type code in entries for empty or
## DP: hidden partitions, so that hidden partitions should be preserved
## DP: so long as we don't resize another partition over them.
@DPATCH@
diff -urNad parted-1.8.8.git.2008.03.24~/libparted/labels/dos.c
parted-1.8.8.git.2008.03.24/libparted/labels/dos.c
--- parted-1.8.8.git.2008.03.24~/libparted/labels/dos.c 2008-10-05
22:24:07.000000000 +0100
+++ parted-1.8.8.git.2008.03.24/libparted/labels/dos.c 2008-10-05
22:43:43.000000000 +0100
@@ -1148,13 +1148,17 @@
if (!table.mbr_signature)
table.mbr_signature = generate_random_id();
- memset (table.partitions, 0, sizeof (DosRawPartition) * 4);
- table.magic = PED_CPU_TO_LE16 (MSDOS_MAGIC);
+ if (table.magic != PED_CPU_TO_LE16 (MSDOS_MAGIC)) {
+ memset (table.partitions, 0, sizeof (DosRawPartition) * 4);
+ table.magic = PED_CPU_TO_LE16 (MSDOS_MAGIC);
+ }
for (i=1; i<=4; i++) {
part = ped_disk_get_partition (disk, i);
- if (!part)
+ if (!part) {
+ table.partitions [i - 1].type = PARTITION_EMPTY;
continue;
+ }
if (!fill_raw_part (&table.partitions [i - 1], part, 0))
return 0;
--- END ---
signature.asc
Description: This is a digitally signed message part

