summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Susi <psusi@ubuntu.com>2014-04-26 14:38:30 -0400
committerPhillip Susi <psusi@ubuntu.com>2014-05-22 19:56:36 -0400
commit82eda230f252ddf2d5909eff3ab092c4af33eb60 (patch)
tree31c6462ad22c92e6ebbb2d3ca34e7903065ca606
parent7eac0588b68a4d991a0f861bb9f4553f44557e14 (diff)
downloadparted-82eda230f252ddf2d5909eff3ab092c4af33eb60.tar.gz
libparted: don't detect fat and ntfs boot sectors as dos MBR
fat and ntfs boot sectors are very similar to an MBR so if you had one of these filesystems on an unpartitioned disk, parted detected them as a dos partition table. Have the dos label code call the fat and ntfs filesystem probes and if they recognize the sector ( their tests are more stringent ) then don't claim it as a dos label.
-rw-r--r--NEWS3
-rw-r--r--libparted/fs/ntfs/ntfs.c2
-rw-r--r--libparted/labels/dos.c29
3 files changed, 33 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 8e2a1b9..bc852e2 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,9 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ libparted: fat and ntfs boot sectors were misdetected as dos
+ partition tables instead of being treated as a loop label.
+
libparted: previously if you chose to ignore the warning about
the gpt thinking the disk was smaller than it appears to be on
on disk, subsequent warnings on other disks would be suppressed.
diff --git a/libparted/fs/ntfs/ntfs.c b/libparted/fs/ntfs/ntfs.c
index 3ba2683..4c154fd 100644
--- a/libparted/fs/ntfs/ntfs.c
+++ b/libparted/fs/ntfs/ntfs.c
@@ -32,7 +32,7 @@
#define NTFS_SIGNATURE "NTFS"
-static PedGeometry*
+PedGeometry*
ntfs_probe (PedGeometry* geom)
{
char *buf = alloca (geom->dev->sector_size);
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index eff1c03..295fcf3 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -235,12 +235,23 @@ maybe_FAT (unsigned char const *s)
return true;
}
+PedGeometry*
+fat_probe_fat16 (PedGeometry* geom);
+
+PedGeometry*
+fat_probe_fat32 (PedGeometry* geom);
+
+PedGeometry*
+ntfs_probe (PedGeometry* geom);
+
static int
msdos_probe (const PedDevice *dev)
{
PedDiskType* disk_type;
DosRawTable* part_table;
int i;
+ PedGeometry *geom = NULL;
+ PedGeometry *fsgeom = NULL;
PED_ASSERT (dev != NULL);
@@ -257,6 +268,20 @@ msdos_probe (const PedDevice *dev)
if (PED_LE16_TO_CPU (part_table->magic) != MSDOS_MAGIC)
goto probe_fail;
+ geom = ped_geometry_new (dev, 0, dev->length);
+ PED_ASSERT (geom);
+ fsgeom = fat_probe_fat16 (geom);
+ if (fsgeom)
+ goto probe_fail; /* fat fs looks like dos mbr */
+ fsgeom = fat_probe_fat32 (geom);
+ if (fsgeom)
+ goto probe_fail; /* fat fs looks like dos mbr */
+ fsgeom = ntfs_probe (geom);
+ if (fsgeom)
+ goto probe_fail; /* ntfs fs looks like dos mbr */
+ ped_geometry_destroy (geom);
+ geom = NULL;
+
/* If this is a FAT fs, fail here. Checking for the FAT signature
* has some false positives; instead, do what the Linux kernel does
* and ensure that each partition has a boot indicator that is
@@ -303,6 +328,10 @@ msdos_probe (const PedDevice *dev)
return 1;
probe_fail:
+ if (geom)
+ ped_geometry_destroy (geom);
+ if (fsgeom)
+ ped_geometry_destroy (fsgeom);
free (label);
return 0;
}