Skip to contentSkip to conversation

Get blockdev size right in pktcdvd after switching discs

PATCH New Peter Osterlund 1 participant 1 message Aug 15, 2004 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Get blockdev size right in pktcdvd after switching discs

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.

---

 linux-petero/drivers/block/pktcdvd.c |    2 ++
 1 files changed, 2 insertions(+)
drivers/block/pktcdvd.c renamed from drivers/block/pktcdvd.c~packet-capacity +2 -0
diff -puN drivers/block/pktcdvd.c~packet-capacity drivers/block/pktcdvd.c
@@ -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

_

Signature · 2 lines
Peter Osterlund - [email protected]
http://w1.894.telia.com/~u89404340