I am attempting to accomplish the following goal within the Linux kernel: Generate a list of all block devices so that I may be able to traverse the list and check all devices for specific drive labels.
Is there a clean routine, or proposed method of being able to (within my device driver), generate a list of all block devices? I do not want any user interaction outside of the insertion of the module. Note that I need to stay with the 2.6.26.x kernel base.
Also, I was reviewing include/linux/genhd.h and came upon a routine:
/* drivers/block/genhd.c */
extern int get_blkdev_list(char *, int);
There are a couple of problems with this:
1. genhd.c was moved from drivers/block/genhd.c to block/genhd.c, so the comment should be updated.
2. When you go into the genhd.c or even grep for a recursive search for the string get_blkdev_list, it only returns with the declaration in the header file and the entire kernel source does NOT contain its definition.
Thanks in advance.
Petros Koutoupis
blkid
you essentially want to rewrite blkid but make your life harder and do it in kernel?
you know you can get 'all block devices' easily from user space? /proc/devices and /sys/block/ come to my mind. you can read the code behind that, of course.
re: blkid
After posting, I had immediately thought of looking through procfs and sysfs. I just do not want to go into user space unless I absolutely have to. It is unfortunate that as of the 2.6.16 kernel that they removed the definition to the get_blkdev_list() routine. Yesterday and today, I had sent a couple of patches to clean up/correct some of the comments and remove the declaration in include/linux/genhd.h based off of the 2.6.28.7.