lkml.org 
[lkml]   [2002]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Reading page from given block device


On Thu, 9 May 2002, Pavel Machek wrote:

> Well, I'm doing it during boot, and this is swap partition; it should
> not have been accessed previously.
>
> > > bdev = bdget(kdev_t_to_nr(dev));
> > > if (!bdev) {
> > > printk("No block device for %s\n", __bdevname(dev));
> > > BUG();
> > > }
> > > printk("C");

blkdev_open(bdev, FMODE_READ, O_RDONLY, BDEV_RAW)

> > > bh = __bread(bdev, pos/PAGE_SIZE, PAGE_SIZE);
> > > printk("D");
> > > bdput(bdev);

nope - blkdev_put(bdev), and do it _after_ you are done with buffers.
Oh, and you need to do brelse().

> > > if (!bh || (!bh->b_data)) {
> > > return -1;

However, I would really suggest to open the bugger once, do all IO and
then close it. See how raw.c and friends deal with these problems.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:25    [W:0.089 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site