aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
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 /include/linux/device.h
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 'include/linux/device.h')
-rw-r--r--include/linux/device.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index f71a78d123ae..e49aa74f248c 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -193,6 +193,7 @@ struct class {
193 struct semaphore sem; /* locks children, devices, interfaces */ 193 struct semaphore sem; /* locks children, devices, interfaces */
194 struct class_attribute *class_attrs; 194 struct class_attribute *class_attrs;
195 struct device_attribute *dev_attrs; 195 struct device_attribute *dev_attrs;
196 struct kobject *dev_kobj;
196 197
197 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); 198 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
198 199
@@ -205,6 +206,8 @@ struct class {
205 struct pm_ops *pm; 206 struct pm_ops *pm;
206}; 207};
207 208
209extern struct kobject *sysfs_dev_block_kobj;
210extern struct kobject *sysfs_dev_char_kobj;
208extern int __must_check class_register(struct class *class); 211extern int __must_check class_register(struct class *class);
209extern void class_unregister(struct class *class); 212extern void class_unregister(struct class *class);
210extern int class_for_each_device(struct class *class, void *data, 213extern int class_for_each_device(struct class *class, void *data,