Skip to content

Commit

Permalink
[PATCH] pktcdvd: Use bd_claim to get exclusive access
Browse files Browse the repository at this point in the history
Use bd_claim() when opening the cdrom device to prevent user space programs
such as cdrecord, hald and kded from interfering with the burning process.

Signed-off-by: Peter Osterlund <petero2@telia.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Peter Osterlund authored and Linus Torvalds committed Jan 9, 2006
1 parent 97a41e2 commit 8382bf2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1955,9 +1955,12 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write)
if ((ret = blkdev_get(pd->bdev, FMODE_READ, O_RDONLY)))
goto out;

if ((ret = bd_claim(pd->bdev, pd)))
goto out_putdev;

if ((ret = pkt_get_last_written(pd, &lba))) {
printk("pktcdvd: pkt_get_last_written failed\n");
goto out_putdev;
goto out_unclaim;
}

set_capacity(pd->disk, lba << 2);
Expand All @@ -1967,7 +1970,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write)
q = bdev_get_queue(pd->bdev);
if (write) {
if ((ret = pkt_open_write(pd)))
goto out_putdev;
goto out_unclaim;
/*
* Some CDRW drives can not handle writes larger than one packet,
* even if the size is a multiple of the packet size.
Expand All @@ -1982,13 +1985,15 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write)
}

if ((ret = pkt_set_segment_merging(pd, q)))
goto out_putdev;
goto out_unclaim;

if (write)
printk("pktcdvd: %lukB available on disc\n", lba << 1);

return 0;

out_unclaim:
bd_release(pd->bdev);
out_putdev:
blkdev_put(pd->bdev);
out:
Expand All @@ -2007,6 +2012,7 @@ static void pkt_release_dev(struct pktcdvd_device *pd, int flush)
pkt_lock_door(pd, 0);

pkt_set_speed(pd, MAX_SPEED, MAX_SPEED);
bd_release(pd->bdev);
blkdev_put(pd->bdev);
}

Expand Down

0 comments on commit 8382bf2

Please sign in to comment.