aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2008-04-21 13:51:07 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-22 00:54:40 -0400
commite105b8bfc769b0545b6f0f395179d1e43cbee822 (patch)
tree23a1f0839547829c4ca6e89cd40adf285eb9feb6 /Documentation
parent93ded9b8fd42abe2c3607097963d8de6ad9117eb (diff)
sysfs: add /sys/dev/{char,block} to lookup sysfs path by major:minor
Why?: There are occasions where userspace would like to access sysfs attributes for a device but it may not know how sysfs has named the device or the path. For example what is the sysfs path for /dev/disk/by-id/ata-ST3160827AS_5MT004CK? With this change a call to stat(2) returns the major:minor then userspace can see that /sys/dev/block/8:32 links to /sys/block/sdc. What are the alternatives?: 1/ Add an ioctl to return the path: Doable, but sysfs is meant to reduce the need to proliferate ioctl interfaces into the kernel, so this seems counter productive. 2/ Use udev to create these symlinks: Also doable, but it adds a udev dependency to utilities that might be running in a limited environment like an initramfs. 3/ Do a full-tree search of sysfs. [kay.sievers@vrfy.org: fix duplicate registrations] [kay.sievers@vrfy.org: cleanup suggestions] Cc: Neil Brown <neilb@suse.de> Cc: Tejun Heo <htejun@gmail.com> Acked-by: Kay Sievers <kay.sievers@vrfy.org> Reviewed-by: SL Baur <steve@xemacs.org> Acked-by: Kay Sievers <kay.sievers@vrfy.org> Acked-by: Mark Lord <lkml@rtr.ca> Acked-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/ABI/testing/sysfs-dev20
-rw-r--r--Documentation/filesystems/sysfs.txt6
2 files changed, 26 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-dev b/Documentation/ABI/testing/sysfs-dev
new file mode 100644
index 000000000000..a9f2b8b0530f
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-dev
@@ -0,0 +1,20 @@
1What: /sys/dev
2Date: April 2008
3KernelVersion: 2.6.26
4Contact: Dan Williams <dan.j.williams@intel.com>
5Description: The /sys/dev tree provides a method to look up the sysfs
6 path for a device using the information returned from
7 stat(2). There are two directories, 'block' and 'char',
8 beneath /sys/dev containing symbolic links with names of
9 the form "<major>:<minor>". These links point to the
10 corresponding sysfs path for the given device.
11
12 Example:
13 $ readlink /sys/dev/block/8:32
14 ../../block/sdc
15
16 Entries in /sys/dev/char and /sys/dev/block will be
17 dynamically created and destroyed as devices enter and
18 leave the system.
19
20Users: mdadm <linux-raid@vger.kernel.org>
diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt
index 7f27b8f840d0..9e9c348275a9 100644
--- a/Documentation/filesystems/sysfs.txt
+++ b/Documentation/filesystems/sysfs.txt
@@ -248,6 +248,7 @@ The top level sysfs directory looks like:
248block/ 248block/
249bus/ 249bus/
250class/ 250class/
251dev/
251devices/ 252devices/
252firmware/ 253firmware/
253net/ 254net/
@@ -274,6 +275,11 @@ fs/ contains a directory for some filesystems. Currently each
274filesystem wanting to export attributes must create its own hierarchy 275filesystem wanting to export attributes must create its own hierarchy
275below fs/ (see ./fuse.txt for an example). 276below fs/ (see ./fuse.txt for an example).
276 277
278dev/ contains two directories char/ and block/. Inside these two
279directories there are symlinks named <major>:<minor>. These symlinks
280point to the sysfs directory for the given device. /sys/dev provides a
281quick way to lookup the sysfs interface for a device from the result of
282a stat(2) operation.
277 283
278More information can driver-model specific features can be found in 284More information can driver-model specific features can be found in
279Documentation/driver-model/. 285Documentation/driver-model/.