Results 1 to 1 of 1
Hi,
i'm trying to write a code, which checks if a block device exists or not.
I wrote the following code
Code:
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
...
- 05-26-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 6
lookup_bdev function ,
Hi,
i'm trying to write a code, which checks if a block device exists or not.
I wrote the following code
Problem is , whatever i send argument to lookup_bdev function , it never returns NULL,Code:#include <linux/kernel.h> #include <linux/init.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/blkdev.h> int init_module (void) { struct block_device *bd = NULL; bd = lookup_bdev("dev/sda1"); if( bd == NULL ) { printk(KERN_ALERT "Error!Block device not found!\n"); return -1 ; } printk(KERN_DEBUG "Module Loaded\n"); printk(KERN_INFO " Block device is found!\n"); return 0; } void cleanup_module(void) { printk( KERN_INFO "Module is cleaned-up!\n"); }
How am i going to check , path which sent as argument to lookup_bdev, exists or not ?


Reply With Quote
