[PATCH] Get blockdev size right in pktcdvd after switching discs

From: Peter Osterlund
Date: Sun Aug 15 2004 - 09:04:18 EST



If you do "pktsetup 0 /dev/hdd", insert a CD and write some data to
it, remove the CD and insert a DVD, the /dev/hdd block device will not
have the correct size. This leads to bogus "attempt to access beyond
end of device" errors.

This patch fixes it.

Signed-off-by: Peter Osterlund <petero2@xxxxxxxxx>
---

linux-petero/drivers/block/pktcdvd.c | 2 ++
1 files changed, 2 insertions(+)

diff -puN drivers/block/pktcdvd.c~packet-capacity drivers/block/pktcdvd.c
--- linux/drivers/block/pktcdvd.c~packet-capacity 2004-08-15 15:08:08.000000000 +0200
+++ linux-petero/drivers/block/pktcdvd.c 2004-08-15 15:44:18.102726968 +0200
@@ -1971,6 +1971,8 @@ static int pkt_open_dev(struct pktcdvd_d
}

set_capacity(pd->disk, lba << 2);
+ set_capacity(pd->bdev->bd_disk, lba << 2);
+ bd_set_size(pd->bdev, (loff_t)lba << 11);

/*
* The underlying block device needs to have its merge logic
_

--
Peter Osterlund - petero2@xxxxxxxxx
http://w1.894.telia.com/~u89404340
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/