mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] partitions and unusual block sizes
@ 2004-07-17 23:02 Adam Lackorzynski
  0 siblings, 0 replies; only message in thread
From: Adam Lackorzynski @ 2004-07-17 23:02 UTC (permalink / raw)
  To: linux-kernel

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.


Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>

diff -urN linux-2.6.8-rc1/fs/partitions/msdos.c linux-2.6.8-rc1.m/fs/partitions/msdos.c
--- linux-2.6.8-rc1/fs/partitions/msdos.c	2004-07-18 00:24:17.000000000 +0200
+++ linux-2.6.8-rc1.m/fs/partitions/msdos.c	2004-07-18 00:29:37.000000000 +0200
@@ -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
-- 
Adam                 adam@os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-07-17 23:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-17 23:02 [PATCH] partitions and unusual block sizes Adam Lackorzynski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome