lkml.org 
[lkml]   [2005]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
Subjectsysfs question: how to map major:minor to name under /sys

Hi,
I have a question about sysfs related usage.

Suppose I have a major:minor number for a block device - maybe from
fstat of a filedescriptor I was given, or stat of a name in /dev.
How do I find the directory in /sys/block that contains relevant
information?

It seems to me that there is no direct way, and maybe there should
be. (I can do a find of 'dev' file and compare, which is fine in a
one-off shell script, but sub-optimal in general).

The most obvious solution would be to have a directory somewhere full
of symlinks:
/sys/block_dev/8:0 -> ../block/sda
or whatever.
Is this reasonable? Should I try it?

The particular case that I am interested in involves md.
In this case I can find the right /sys/block/mdX entry easily enough
because I *know* how the names are generated. However when a block
device is added to an array, it gets an entry like
/sys/block/md4/md/dev-sda
I would like to be able to easily find that given just the
information that 8:0 was added.
If the above directory of symlinks existed, I could readlink the
relevant entry, take the basename, and add "md/dev-" to front of
that.

Comments?

NeilBrown
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-12-15 04:18    [W:0.038 / U:0.716 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site