summaryrefslogtreecommitdiff
path: root/libparted/fs/hfs
diff options
context:
space:
mode:
authorPhillip Susi <psusi@ubuntu.com>2014-03-17 22:07:55 -0400
committerPhillip Susi <psusi@ubuntu.com>2014-04-18 12:55:21 -0400
commit80678bdd957cf49a9ccfc8b88ba3fb8b4c63fc12 (patch)
tree5e5396f7d88cbc096f5049f4687ce7a5b17507ef /libparted/fs/hfs
parentd0a4cc1b57750a92afb48b229e4791154afa322b (diff)
downloadparted-80678bdd957cf49a9ccfc8b88ba3fb8b4c63fc12.tar.gz
Fix filesystem detection on non 512 byte sectors
Enable probing for filesystems with non 512 byte sectors, and fix up each filesystem to correctly handle that. Remove unused field from the fs type structure listing acceptable sector sizes.
Diffstat (limited to 'libparted/fs/hfs')
-rw-r--r--libparted/fs/hfs/hfs.c7
-rw-r--r--libparted/fs/hfs/probe.c13
2 files changed, 8 insertions, 12 deletions
diff --git a/libparted/fs/hfs/hfs.c b/libparted/fs/hfs/hfs.c
index 40c8173..e5396b2 100644
--- a/libparted/fs/hfs/hfs.c
+++ b/libparted/fs/hfs/hfs.c
@@ -44,10 +44,6 @@ uint8_t* hfsp_block = NULL;
unsigned hfs_block_count;
unsigned hfsp_block_count;
-#define HFS_BLOCK_SIZES ((int[2]){512, 0})
-#define HFSP_BLOCK_SIZES ((int[2]){512, 0})
-#define HFSX_BLOCK_SIZES ((int[2]){512, 0})
-
static PedFileSystemOps hfs_ops = {
probe: hfs_probe,
};
@@ -65,21 +61,18 @@ static PedFileSystemType hfs_type = {
next: NULL,
ops: &hfs_ops,
name: "hfs",
- block_sizes: HFS_BLOCK_SIZES
};
static PedFileSystemType hfsplus_type = {
next: NULL,
ops: &hfsplus_ops,
name: "hfs+",
- block_sizes: HFSP_BLOCK_SIZES
};
static PedFileSystemType hfsx_type = {
next: NULL,
ops: &hfsx_ops,
name: "hfsx",
- block_sizes: HFSX_BLOCK_SIZES
};
void
diff --git a/libparted/fs/hfs/probe.c b/libparted/fs/hfs/probe.c
index ad79a64..c4dca5e 100644
--- a/libparted/fs/hfs/probe.c
+++ b/libparted/fs/hfs/probe.c
@@ -62,7 +62,6 @@ it is in fact a wrapper to an HFS+ volume */
PedGeometry*
hfs_and_wrapper_probe (PedGeometry* geom)
{
- uint8_t buf[PED_SECTOR_SIZE_DEFAULT];
HfsMasterDirectoryBlock *mdb;
PedGeometry* geom_ret;
PedSector search, max;
@@ -70,18 +69,22 @@ hfs_and_wrapper_probe (PedGeometry* geom)
PED_ASSERT (geom != NULL);
PED_ASSERT (hfsc_can_use_geom (geom));
- mdb = (HfsMasterDirectoryBlock *) buf;
+ const int sectors = ((3 * 512) + geom->dev->sector_size - 1) /
+ geom->dev->sector_size;
+ char * buf = alloca (sectors * geom->dev->sector_size);
+
+ mdb = (HfsMasterDirectoryBlock *)(buf+1024);
/* is 5 an intelligent value ? */
if ((geom->length < 5)
- || (!ped_geometry_read (geom, buf, 2, 1))
+ || (!ped_geometry_read (geom, buf, 0, sectors))
|| (mdb->signature != PED_CPU_TO_BE16 (HFS_SIGNATURE)) )
return NULL;
search = ((PedSector) PED_BE16_TO_CPU (mdb->start_block)
+ ((PedSector) PED_BE16_TO_CPU (mdb->total_blocks)
- * (PED_BE32_TO_CPU (mdb->block_size) / PED_SECTOR_SIZE_DEFAULT )));
- max = search + (PED_BE32_TO_CPU (mdb->block_size) / PED_SECTOR_SIZE_DEFAULT);
+ * (PED_BE32_TO_CPU (mdb->block_size) / geom->dev->sector_size)));
+ max = search + (PED_BE32_TO_CPU (mdb->block_size) / geom->dev->sector_size);
if ((search < 0)
|| !(geom_ret = ped_geometry_new (geom->dev, geom->start, search + 2)))
return NULL;