Skip to contentSkip to conversation

partitions and unusual block sizes

PATCH New Adam Lackorzynski 1 participant 1 message Jul 17, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 partitions and unusual block sizes

Hi,

I've been working on a block driver with a block size != 512 bytes, by using blk_queue_hardsect_size(q, 1024). The msdos partitioning code modifies the sectors according to the block size of the underlying device. As all blocks are 512 bytes internally, modifying the partitioning data looks wrong. The following patch fixes this for me.

fs/partitions/msdos.c +8 -10
diff -urN linux-2.6.8-rc1/fs/partitions/msdos.c linux-2.6.8-rc1.m/fs/partitions/msdos.c
@@ -78,7 +78,6 @@
 	Sector sect;
 	unsigned char *data;
 	u32 this_sector, this_size;
-	int sector_size = bdev_hardsect_size(bdev) / 512;
 	int loopct = 0;		/* number of links followed
 				   without finding a data partition */
 	int i;
@@ -119,8 +118,8 @@
 
 			/* Check the 3rd and 4th entries -
 			   these sometimes contain random garbage */
-			offs = START_SECT(p)*sector_size;
-			size = NR_SECTS(p)*sector_size;
+			offs = START_SECT(p);
+			size = NR_SECTS(p);
 			next = this_sector + offs;
 			if (i >= 2) {
 				if (offs + size > this_size)
@@ -152,8 +151,8 @@
 		if (i == 4)
 			goto done;	 /* nothing left to do */
 
-		this_sector = first_sector + START_SECT(p) * sector_size;
-		this_size = NR_SECTS(p) * sector_size;
+		this_sector = first_sector + START_SECT(p);
+		this_size = NR_SECTS(p);
 		put_dev_sector(sect);
 	}
 done:
@@ -376,7 +375,6 @@
  
 int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)
 {
-	int sector_size = bdev_hardsect_size(bdev) / 512;
 	Sector sect;
 	unsigned char *data;
 	struct partition *p;
@@ -424,8 +422,8 @@
 
 	state->next = 5;
 	for (slot = 1 ; slot <= 4 ; slot++, p++) {
-		u32 start = START_SECT(p)*sector_size;
-		u32 size = NR_SECTS(p)*sector_size;
+		u32 start = START_SECT(p);
+		u32 size = NR_SECTS(p);
 		if (!size)
 			continue;
 		if (is_extended_partition(p)) {
@@ -462,8 +460,8 @@
 
 		if (!subtypes[n].parse)
 			continue;
-		subtypes[n].parse(state, bdev, START_SECT(p)*sector_size,
-						NR_SECTS(p)*sector_size, slot);
+		subtypes[n].parse(state, bdev,
+		                  START_SECT(p), NR_SECTS(p), slot);
 	}
 	put_dev_sector(sect);
 	return 1;

Adam

Signature · 2 lines
Adam                 [email protected]
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/