Your shopping cart is empty!
Sysfs is a virtual file system provided by Linux. Sysfs exports information about devices and drivers from the kernel device model to user space, and is also used for configuration. It is similar to the sysctl mechanism found in BSD systems, but implemented as a file system instead of a separate mechanism.
During the 2.5 development cycle, the Linux driver model was introduced to fix several shortcomings of version 2.4:
Sysfs is designed to export the information present in the device tree which would then no longer clutter up procfs. It was written by Patrick Mochel. Maneesh Soni later wrote the sysfs backing store patch to reduce memory usage on large systems.
sysfs is an in-memory filesystem that was originally based on ramfs. ramfs was written around the time Linux 2.4.0 was being stabilized. It was an exercise in elegance, as it showed just how easy it was to write a simple filesystem using the then-new VFS layer. Because of its simplicity and use of the VFS, it provided a good base from which to derive other in-memory based filesystems.
sysfs was originally called ddfs (Device Driver Filesystem) and was initially created to debug the new driver model as it was being written. Previously, debugging was performed by using procfs to export a device tree, but under urging from Linus Torvalds, it was converted to use a new filesystem based on ramfs. By the time the new driver model was merged into the kernel around 2.5.1, it had changed names to driverfs to be a little more descriptive.
During the next year of 2.5 development, the infrastructural capabilities of the driver model and driverfs began to prove useful to other subsystems. kobjects were developed to provide a central object management mechanism and driverfs was renamed to sysfs to represent its subsystem agnosticism.
procfs (or the proc filesystem) is a special filesystem in UNIX-like operating systems that presents information about processes and other system information in a hierarchical file-like structure, providing a more convenient and standardized method for dynamically accessing process data held in the kernel than traditional tracing methods or direct access to kernel memory. Typically, it is mapped to a mount point named /procat boot time.
The proc filesystem provides a method of communication between kernel space and user space. For example, the GNU version of uses the procfs to obtain its data, without using any specialized system calls.
The Linux implementation of /procalso clones that of Plan 9. Under Linux, /procincludes a directory for each running process (including kernel processes) at /proc/PID, containing information about that process, notably including:
Obtaining the PID can be done with utilities like pgrep, pidof or ps:
$ ls -l /proc/$(pgrep -n python)/fd # List all file descriptors of the most recently started `python' process
lrwx------ 1 baldur baldur 64 2011-03-18 12:31 0 -> /dev/pts/3
lrwx------ 1 baldur baldur 64 2011-03-18 12:31 1 -> /dev/pts/3
lrwx------ 1 baldur baldur 64 2011-03-18 12:31 2 -> /dev/pts/3
$ readlink /proc/$(pgrep -n python)/exe # List executable used to launch the most recently started `python' process
It also includes non-process-related system information, although in the 2.6 kernel much of that information moved to a separate pseudo-file system, sysfs, mounted under /sys:
On multi-core CPUs, /proc/cpuinfo contains the two fields "siblings" and "cpu cores" whereas the following calculation is applied:
"siblings" = (HT per CPU package) * (# of cores per CPU package)
"cpu cores" = (# of cores per CPU package)
A CPU package means physical CPU which can have multiple cores (single core for one, dual core for two, quad core for four). This allows to better distinguish between HT and dual-core, i.e. the number of HT per CPU package can be calculated by siblings / CPU cores. If both values for a CPU package are the same, then hyper-threading is not supported. For instance, a CPU package with siblings=2 and "cpu cores"=2 is a dual-core CPU but doesn't support HT.
The basic utilities that use /proc under Linux come in the procps (/proc processes) package, and only function in conjunction with a mounted /proc.