Skip to contentSkip to conversation

exclusive access with bd_claim

DISCUSSION Alexander Sandler 1 participant 1 message Nov 11, 2004

lore
Share & tools
lore
#0 lore raw

I encountered this when tried to get exclusive access to device with bd_claim(). Following code, when compiled as loaded as module, does not prevent from modifying partition table on /dev/sda.

----------------------------------------------
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/blkdev.h>

struct block_device *bdev;

int excl_init( void )

{
        bdev = open_bdev_excl( "/dev/sda", 0, THIS_MODULE );
        if (!bdev)
                printk( "failed to open /dev/sda\n" );

        return 0;
}

void excl_exit( void )

{
        if (bdev)
                close_bdev_excl( bdev );
}

module_init( excl_init );
module_exit( excl_exit );
----------------------------------------------

Same when doing

bdev = open_by_devnum( MKDEV( 8, 0 ), FMODE_READ | FMODE_WRITE ); if (bdev)

        bd_claim( bdev, THIS_MODULE );

instead of open_bdev_excl(...).

Am I missing something? Any ideas?

system: SLES8 + 2.6.9 on MP machine.

Signature · 1 line
Sasha.