[PATCH] libblkid: fix mac partition detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This fixes the buffer length passed to blkid_probe_get_buffer() calls,
and the block size byte order (on little-endian systems).

Signed-off-by: Francesco Cosoleto <cosoleto@xxxxxxxxx>
---
 libblkid/src/partitions/mac.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/libblkid/src/partitions/mac.c b/libblkid/src/partitions/mac.c
index 4715ab6..e18896c 100644
--- a/libblkid/src/partitions/mac.c
+++ b/libblkid/src/partitions/mac.c
@@ -58,11 +58,11 @@ struct mac_driver_desc {
 
 static inline unsigned char *get_mac_block(
 					blkid_probe pr,
-					struct mac_driver_desc *md,
+					uint16_t block_size,
 					uint32_t num)
 {
 	return blkid_probe_get_buffer(pr,
-			(blkid_loff_t) num * md->block_size, num);
+			(blkid_loff_t) num * block_size, block_size);
 }
 
 static inline int has_part_signature(struct mac_partition *p)
@@ -78,6 +78,7 @@ static int probe_mac_pt(blkid_probe pr,
 	struct mac_partition *p;
 	blkid_parttable tab = NULL;
 	blkid_partlist ls;
+	uint16_t block_size;
 	uint16_t ssf;	/* sector size fragment */
 	uint32_t nblks, i;
 
@@ -89,11 +90,12 @@ static int probe_mac_pt(blkid_probe pr,
 	if (!md)
 		goto nothing;
 
+	block_size = be16_to_cpu(md->block_size);
 
 	/* The partition map always begins at physical block 1,
 	 * the second block on the disk.
 	 */
-	p = (struct mac_partition *) get_mac_block(pr, md, 1);
+	p = (struct mac_partition *) get_mac_block(pr, block_size, 1);
 	if (!p)
 		goto nothing;
 
@@ -113,7 +115,7 @@ static int probe_mac_pt(blkid_probe pr,
 	if (!tab)
 		goto err;
 
-	ssf = md->block_size / 512;
+	ssf = block_size / 512;
 	nblks = be32_to_cpu(p->map_count);
 
 	for (i = 1; i <= nblks; ++i) {
@@ -121,7 +123,7 @@ static int probe_mac_pt(blkid_probe pr,
 		uint32_t start;
 		uint32_t size;
 
-		p = (struct mac_partition *) get_mac_block(pr, md, i);
+		p = (struct mac_partition *) get_mac_block(pr, block_size, i);
 		if (!p)
 			goto nothing;
 		if (!has_part_signature(p))
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux