Sysfs
Encyclopedia
Sysfs is a virtual file system
Virtual file system
A virtual file system or virtual filesystem switch is an abstraction layer on top of a more concrete file system. The purpose of a VFS is to allow client applications to access different types of concrete file systems in a uniform way...

 provided by Linux
Linux kernel
The Linux kernel is an operating system kernel used by the Linux family of Unix-like operating systems. It is one of the most prominent examples of free and open source software....

 2.6. Sysfs exports information about devices and drivers from the kernel device model to user space
User space
A conventional computer operating system usually segregates virtual memory into kernel space and user space. Kernel space is strictly reserved for running the kernel, kernel extensions, and most device drivers...

, and is also used for configuration. It is similar to the sysctl
Sysctl
Sysctl is an interface for examining and dynamically changing parameters in the BSD and Linux operating systems. The implementation mechanism in these two systems is very different....

 mechanism found in BSD systems, but implemented as a file system instead of a separate mechanism.

History

During the 2.5 development cycle, the Linux driver model was introduced to fix several shortcomings of version 2.4:
  • No unified method of representing driver-device relationships existed.
  • There was no generic hotplug
    Hot swapping
    Hot swapping and hot plugging are terms used to describe the functions of replacing computer system components without shutting down the system...

     mechanism.
  • procfs
    Procfs
    procfs 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...

     was cluttered with lots of non-process information.


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
Procfs
procfs 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...

 to export a device tree, but under urging from Linus Torvalds
Linus Torvalds
Linus Benedict Torvalds is a Finnish software engineer and hacker, best known for having initiated the development of the open source Linux kernel. He later became the chief architect of the Linux kernel, and now acts as the project's coordinator...

, 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.

S/390 buses

As the S/390 architecture contains devices not found elsewhere, special buses have been created:
  • css: Contains subchannels (currently the only driver provided is for I/O subchannels).
  • ccw: Contains channel attached devices (driven by CCWs).
  • ccwgroup: Artificial devices, created by the user and consisting of ccw devices. Replaces some of the 2.4 chandev functionality.
  • iucv: Artificial devices like netiucv devices which use VM's IUCV
    IUCV
    IUCV is a data transfer mechanism in IBM VM line of operating systems.IUCV allows establishing point to point communication channels, either between 2 virtual machines or between a virtual machine and hypervisor services...

     interface.

Sysfs and userspace

Sysfs is used by several utilities to access information about hardware and its driver (kernel modules) such as udev
Udev
udev is the device manager for the Linux kernel. Primarily, it manages device nodes in /dev. It is the successor of devfs and hotplug, which means that it handles the /dev directory and all user space actions when adding/removing devices, including firmware load.-History:udev was new in Linux...

 or HAL
HAL (software)
HAL was a software project providing a hardware abstraction layer for Unix-like computer systems.HAL is now deprecated on GNU/Linux systems, with functionality being merged into udev as of 2008–2010...

. Scripts have been written to access information previously obtained via procfs
Procfs
procfs 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...

, and some scripts configure device drivers and devices via their attributes.

See also

  • configfs
    Configfs
    Configfs is a RAM-based virtual file system provided by the 2.6 Linux kernel. Configfs appears similar to sysfs but they are in fact different and complementary. Configfs is for creating, managing and destroying kernel objects from user-space, and sysfs for viewing and manipulating objects from...

  • tmpfs
    TMPFS
    tmpfs is a common name for a temporary file storage facility on many Unix-like operating systems. It is intended to appear as a mounted file system, but stored in volatile memory instead of a persistent storage device...

  • sysctl
    Sysctl
    Sysctl is an interface for examining and dynamically changing parameters in the BSD and Linux operating systems. The implementation mechanism in these two systems is very different....

    , alternative way of exporting configuration used in BSD systems

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK