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>
#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");
}
Problem is , whatever i send argument to lookup_bdev function , it never returns NULL,
How am i going to check , path which sent as argument to lookup_bdev, exists or not ?