Skip to contentSkip to conversation

partitions

DISCUSSION David Chow 5 participants 7 messages Jul 24, 2002 – Jul 25, 2002 VFS

lore
Share & tools
lore

David Chow

author
#0 lore raw

Hi all,

Is there any global variables or list in the kernel space that I can find out which partitions are available in the system? Please give pointer of information.

regards,
David

#1 lore raw

Hello David , /proc/partitions ? Hth , JimL

Quoted 6 lines · David Chow

Hi all,
Is there any global variables or list in the kernel space that I can find out which partitions are available in the system? Please give pointer of information.
regards,
David

       +------------------------------------------------------------------+
       | James   W.   Laferriere | System    Techniques | Give me VMS     |
       | Network        Engineer |     P.O. Box 854     |  Give me Linux  |
       | [email protected] | Coudersport PA 16915 |   only  on  AXP |
       +------------------------------------------------------------------+
#2 lore raw

On Wed, 24 Jul 2002, Mr. James W. Laferriere wrote:

| 	Hello David ,  /proc/partitions ?  Hth ,  JimL
|
| On Thu, 25 Jul 2002, David Chow wrote:
| > Hi all,
| > Is there any global variables or list in the kernel space that I can
| > find out which partitions are available in the system? Please give
| > pointer of information.

um, I wouldn't call /proc/partitions "in the kernel space." However, someone could clone the code that produces /proc/partitions in kernel space.

in drivers/block/genhd.c::get_partition_list() [at least in 2.4.18/19]

Signature · 1 line
~Randy
#3 lore raw
In reply to David Chow
Quoted 2 lines · David Chow

Is there any global variables or list in the kernel space that I can find out which partitions are available in the system?

Look at the struct gendisk chain.

#4 lore raw
Quoted 6 lines · Andries Brouwer
Quoted 2 lines · David Chow

Is there any global variables or list in the kernel space that I can find out which partitions are available in the system?

Look at the struct gendisk chain.

... and you will get a random set of things. E.g. you might very well find a gendisk shared by hda (with its partitions) and hdb (either unpartitioned disk or a CDROM; no way to tell which one it is). OTOH, you will not find a SCSI CDROM. You will find IDE-floppy. You will not find paride one. You will find a very odd gendisk for RAID devices (even though they are not partitioned). You will not find one for loop or nbd.

IOW, contents of /proc/partitions or (soon to be late) gendisk chain is random - any code that relies on it to give you a meaningful set of devices is buggered.

BTW, going through /proc/partitions and blindly opening all devices you see is _NOT_ a good idea - it will show you absent devices if there is something with the same major and higher minor. Why? Beats me.

Basically, gendisks are crap. Why on the earth they were created as per-major objects instead of per-disk ones is a mistery, but whatever reason it had, it had acted as serious source of mess. For many years. Right now I'm cleaning that mess up in 2.5 and I have nothing nice to say about the bright guys responsible for its creation. Sorry.

#5 lore raw
Quoted 5 lines · Alexander Viro

Basically, gendisks are crap. Why on the earth they were created as per-major objects instead of per-disk ones is a mistery, but whatever reason it had, it had acted as serious source of mess. For many years. Right now I'm cleaning that mess up in 2.5 and I have nothing nice to say about the bright guys responsible for its creation. Sorry.

[amused] Good to see that you now understand that permanent disk data is not stored in a struct block_device and that the way to removal of the arrays is nearly independent of struct block_device and instead dependent on a replacement of struct gendisk.

[berating] However, your annoyed words are not fair to Drew Eckhardt. Ten years ago, when he created struct gendisk, most of the problems you mention did not exist yet.

author
#6 lore raw
Quoted 16 lines · Andries Brouwer
Quoted 5 lines · Alexander Viro

Basically, gendisks are crap. Why on the earth they were created as per-major objects instead of per-disk ones is a mistery, but whatever reason it had, it had acted as serious source of mess. For many years. Right now I'm cleaning that mess up in 2.5 and I have nothing nice to say about the bright guys responsible for its creation. Sorry.

[amused] Good to see that you now understand that permanent disk data is not stored in a struct block_device and that the way to removal of the arrays is nearly independent of struct block_device and instead dependent on a replacement of struct gendisk.

Quoted 3 lines

[berating] However, your annoyed words are not fair to Drew Eckhardt. Ten years ago, when he created struct gendisk, most of the problems you mention did not exist yet.

Thanks for advice, it seems there are no standard solutions right? It depends on what sort of device we are looking for... I think I rather concentrate on finding local partitioncs, ide or scsi. But the case of ide-floppy is in a gray area. I certainly don't want to make use of such slow disk.

regards,
David