Is it possible to access sysfs from within the kernel?

From: Tomas Carnecky
Date: Sat Dec 18 2004 - 14:56:46 EST


Why? Lets see.
Sysfs describes the system with all its devices etc but is also an interface to access kernel internal data.
Sysfs data could easily be put into a hierarchical tree. (I think it even is, but it's not so obvious, because it's done using the fs code (inodes, dentries), maybe the kobjects do play a big role here, too).
To access sysfs from an application, you have to use extensively open() and close() for each file (attributes) and readdir for directories... or use libsysfs which does these things for you.
While the current design is good for users (cat /sys/.../.../attribute), it's not very efficient for applications (due to the many syscalls).
IMO it would be much better (for the applications) to have a device node in /dev which could be used to access the sysfs tree. No ioctl but using simple packets.
Besides the simple query/result things, you could register for recieving events (now hotplug), with the difference that the current hotplug (AFAIK) can inform (execute) only one application (/sbin/hotplug).
Or even make it possible to recieve events only from certain classes/devices/subsystems etc.

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