forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. [[email protected]: fix duplicate registrations] [[email protected]: cleanup suggestions] Cc: Neil Brown <[email protected]> Cc: Tejun Heo <[email protected]> Acked-by: Kay Sievers <[email protected]> Reviewed-by: SL Baur <[email protected]> Acked-by: Kay Sievers <[email protected]> Acked-by: Mark Lord <[email protected]> Acked-by: H. Peter Anvin <[email protected]> Signed-off-by: Dan Williams <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
- Loading branch information
Showing
7 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
What: /sys/dev | ||
Date: April 2008 | ||
KernelVersion: 2.6.26 | ||
Contact: Dan Williams <[email protected]> | ||
Description: The /sys/dev tree provides a method to look up the sysfs | ||
path for a device using the information returned from | ||
stat(2). There are two directories, 'block' and 'char', | ||
beneath /sys/dev containing symbolic links with names of | ||
the form "<major>:<minor>". These links point to the | ||
corresponding sysfs path for the given device. | ||
|
||
Example: | ||
$ readlink /sys/dev/block/8:32 | ||
../../block/sdc | ||
|
||
Entries in /sys/dev/char and /sys/dev/block will be | ||
dynamically created and destroyed as devices enter and | ||
leave the system. | ||
|
||
Users: mdadm <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters