Fact-checked by Grok 2 weeks ago

sysfs

Sysfs is a , RAM-based filesystem in the that provides an interface for exporting data structures, their attributes, and the linkages between them to userspace. It is inherently tied to the 's kobject infrastructure, which manages the lifecycle and representation of objects, enabling a hierarchical view of devices, buses, and subsystems. Originally introduced in , sysfs serves as a key component of the device model, allowing userspace tools to query and sometimes modify state without direct access to internal structures. Typically mounted at the /sys directory—either automatically during boot or manually with the command mount -t sysfs sysfs /sys—sysfs requires the CONFIG_SYSFS configuration option to be enabled. The filesystem organizes information into directories that mirror the 's object ; for instance, top-level directories such as /sys/[block](/page/Block)/, /sys/bus/, /sys/[class](/page/Class)/, and /sys/[devices](/page/Device)/ represent devices, buses, device es, and the overall device , respectively, with links facilitating navigation between related objects. Attributes within sysfs appear as simple files, usually containing ASCII text , where reading a file invokes a kernel-defined show() to retrieve values, and writing invokes a store() to apply changes, all limited to a size of one (typically 4096 bytes on x86 architectures). This design promotes a clean separation between internals and userspace interaction, supporting tasks like device discovery, driver loading, and performance monitoring through tools such as udev or custom scripts. However, sysfs is not intended for high-volume or as a general-purpose , and its interface may evolve with changes, requiring users to follow guidelines for stable access patterns.

Introduction

Definition and Purpose

Sysfs is a RAM-based pseudo-filesystem in the , initially implemented on top of ramfs, that serves as a for exporting structures, their attributes, and the relationships between them to userspace in a hierarchical manner. It represents objects through directories, with attributes exposed as regular files containing textual representations of , and linkages depicted via symbolic links, all stored in rather than on disk. The primary purpose of sysfs is to offer a stable and structured interface for userspace applications to query and, in some cases, configure objects such as , drivers, and subsystems, without requiring modifications to the kernel itself. This enables dynamic management of system resources, such as device enumeration and parameter adjustment, promoting interoperability between components and userspace tools. By providing this abstraction, sysfs facilitates tasks like hotplug event handling and device discovery, ensuring that userspace can interact with the internal state in a predictable way. At its core, sysfs is intrinsically linked to the kernel's kobject infrastructure, which handles object lifecycle management, including and hierarchical organization. Each directory in sysfs corresponds to a kobject, allowing the filesystem to mirror the kernel's object model directly. Sysfs was introduced in the 2.6 kernel series to complement and largely replace ad-hoc entries in the /proc filesystem for device-related information, thereby establishing a unified device model that ties filesystem representations closely to data structures for greater accuracy and scalability.

Mounting and Access

Sysfs is a pseudo-filesystem that requires specific configuration and mounting procedures to make its contents accessible in user space. To enable sysfs support, the must be compiled with the CONFIG_SYSFS option set to 'y', which is the default in most distributions since its introduction in kernel version 2.6. In typical environments, sysfs is mounted automatically during the system boot process by the system, such as , often early in the initramfs stage to provide access to kernel objects before the root filesystem is fully mounted. Alternatively, it can be mounted manually using the command mount -t sysfs none /sys, where /sys is the conventional mount point. For persistent automatic mounting, an entry can be added to /etc/[fstab](/page/Fstab), such as sysfs /sys sysfs defaults 0 0, though many modern distributions handle this without explicit fstab configuration due to built-in boot scripts. Once mounted at /sys, sysfs operates as an in-memory, RAM-based filesystem with no associated disk I/O, where directories and files are dynamically generated by the on demand to reflect current kernel data structures and object linkages. This virtual nature ensures low overhead, as content is produced in real-time rather than stored persistently. Unmounting sysfs is straightforward via umount /sys, though it is generally not unmounted during normal operation since it is integral to system monitoring and configuration. Access to sysfs follows a permissions model where the mount point and its contents are owned by root, with most attribute files defaulting to world-readable permissions (mode 0644) to allow safe inspection by non-privileged users, while write access is restricted to root for security. Non-root users thus have read-only access to sysfs by default, though file permissions can be adjusted using standard tools like chmod if needed for specific use cases. This design balances usability with protection against unintended kernel modifications.

History

Origins

Sysfs originated in 2003 as a key component of the 's driver core overhaul, spearheaded by Patrick Mochel to unify and standardize device management across subsystems. This effort addressed the growing complexity of hardware support in the , particularly with the rise of modular and hotpluggable devices, by introducing a consistent framework for exporting device information to userspace. Mochel's initial work on the driver model began with an in 2001, evolving into the unified model merged into the 2.5 development series around 2002-2003. The primary motivations for sysfs stemmed from the limitations of existing mechanisms like /proc and devfs, which suffered from fragmentation and instability in representing device data. Information about devices was scattered across various /proc entries, making it difficult for userspace tools to access a coherent view of the system's , while devfs—introduced in kernel 2.3.13 for dynamic /dev population—faced criticism for embedding decisions in the , such as naming conventions that violated standards like the (LSB), and unfixable race conditions. As devfs was phased out starting in 2005 and fully removed in kernel 2.6.18, sysfs provided a stable, policy-free alternative by focusing on exporting kernel object attributes in a hierarchical, read-only structure. Initially implemented as an in-memory filesystem based on ramfs for efficiency, sysfs—originally named "ddfs" (Device Driver Filesystem) and later "driverfs"—was designed during the 2.4 kernel stabilization period but first integrated into the 2.5 development cycle, preceding the stable 2.6 release in December 2003. This ramfs foundation ensured low overhead, with the entire implementation spanning about 2,000 lines of code across nine files in fs/sysfs/. A core goal was to support the emerging device model, enabling dynamic device discovery and hotplugging; for instance, it facilitated the development of in 2003 by , which used sysfs events via /sbin/hotplug to manage /dev nodes in userspace, replacing devfs functionality. By providing a unified view of devices, buses, and classes, sysfs laid the groundwork for scalable hardware interaction in modern systems.

Evolution and Key Milestones

Sysfs was formally integrated into the stable Linux kernel with the release of version 2.6 on December 17, 2003, marking its transition from experimental development in the 2.5 series to a core feature for exporting kernel objects, including basic device information, through a ram-based pseudo-filesystem. This inclusion established sysfs as the primary interface for userspace access to device hierarchies and attributes, replacing ad hoc mechanisms like procfs entries for device management. Subsequent evolutions enhanced sysfs's role in dynamic system events and subsystem support. In kernel 2.6.10 (December 2004), sysfs integrated with uevents via the socket mechanism, enabling efficient hotplug notifications to userspace for device addition and removal without relying on slower polling or legacy hotplug scripts. Further expansions included dedicated directories for specialized subsystems: /sys/firmware for platform-specific data like tables, introduced in early 2.6 releases to support firmware loading and querying; /sys/power for system-wide suspend and resume controls, unified across architectures starting in 2.6; and /sys/hypervisor for virtualization metadata, added in kernel 2.6.30 to expose capabilities such as features. A significant milestone occurred in 2011 with a comprehensive revision by Mike Murphy on August 16, which formalized guidelines for attribute creation and underscored the ABI stability of sysfs's directory structure and interfaces to prevent disruptions in userspace tools. This update, building on the original 2003 by Patrick Mochel, committed the kernel community to maintaining for existing attributes. Since 2011, sysfs has remained largely stable, with no major ABI breaks, allowing long-term userspace reliance on its structure. Minor enhancements have focused on integration with emerging features, such as support for Rust-based modules in kernels 6.8 and later, including sysfs attribute exposure for Rust drivers in 6.18 to facilitate safer device management without altering core ABI.

Core Architecture

Kobject Infrastructure

The kobject serves as the foundational object type in the , represented by the struct kobject , which is typically embedded within larger kernel objects such as devices or subsystems rather than used standalone. It manages essential lifecycle aspects, including a name for identification, a to track usage, and a pointer to establish hierarchical relationships among objects. Reference counting is handled through functions like kobject_get() to increment the count and kobject_put() to decrement it, with the latter potentially triggering object release when the count reaches zero. Naming is set during object initialization and addition to the kernel, ensuring unique identifiers within the hierarchy, while parent-child links allow for tree-like organization that mirrors kernel object topologies. Sysfs is inherently tied to the kobject infrastructure, where each registered kobject automatically generates a corresponding directory in the /sys filesystem, positioned as a subdirectory of its parent's directory to reflect these relationships. This linkage enables the export of objects to userspace in a structured manner, with the kobject's addition via kobject_add() creating the sysfs entry and its removal via kobject_del() handling the deletion. For deferred operations, such as those required during file access in sysfs, the kernel employs sysfs_schedule_callback() to safely modify kobject reference counts without risking deadlocks or inconsistencies. Key supporting concepts include ksets and ktypes, which extend the kobject's functionality for grouping and typing. A kset, defined by struct kset, acts as a container for related kobjects, providing a unified unit that also manifests as a top-level sysfs directory for the group, such as for device classes. Ktypes, via struct kobj_type, define the behavioral template for kobjects of a specific category, including a release callback for cleanup and pointers to sysfs operations that govern attribute handling. Together, these ensure a consistent hierarchical export of kernel objects through sysfs, with automatic cleanup occurring upon kobject release—triggered when the reference count drops to zero—removing associated directories and preventing resource leaks.

Directory Hierarchy

Sysfs organizes its directory hierarchy to mirror the internal relationships among kernel objects, providing a structured view of the system's devices, subsystems, and parameters. This hierarchy is rooted in the kobject infrastructure, where each directory represents a kobject and subdirectories reflect parent-child linkages, ensuring that the filesystem layout corresponds directly to the kernel's object model. At the top level, sysfs features several key directories that categorize different aspects of the kernel's state and hardware. The block/ directory contains symbolic links to block devices located under /sys/devices/. The bus/ directory presents a flat structure of bus types, each with subdirectories for devices/ (symlinks to /sys/devices/) and drivers/ (directories for bound drivers). The class/ directory holds subdirectories for device classes, each containing symlinks to the corresponding devices in /sys/devices/. The devices/ directory serves as the primary representation of the kernel's device tree, encompassing physical and logical devices in a hierarchical manner, such as /sys/devices/pci0000:00/ for the PCI root hub. The firmware/ directory manages system firmware data, including interfaces for loading firmware to devices. The kernel/ directory exposes runtime kernel parameters and status information. The module/ directory provides access to parameters and state for loaded kernel modules. The power/ directory contains information related to power management features. Additional top-level directories include dev/, fs/, and hypervisor/, where dev/ specifically offers subdirectories char/ and block/ with symlinks named <major>:<minor> for quick mapping to device nodes in /sys/devices/. The hierarchy's mechanics enforce a strict parent-child organization based on kobject associations, with top-level directories acting as common ancestors for related subsystems; for instance, device directories under /sys/devices/ nest according to bus and controller relationships. This structure avoids arbitrary placements, ensuring that all paths logically trace back to kernel object linkages. Sysfs is inherently dynamic, with directories and their contents created or removed in real-time as kernel objects are registered or unregistered, such as during device hotplug events; unlike traditional filesystems, it contains no static files and resides entirely in RAM, limiting its total size to available memory.

Sysfs Attributes

File Types and Representation

Sysfs primarily exposes data through regular files representing attributes, which are formatted as plain ASCII text files containing a single value or a simple array per file. These attributes allow userspace to read or write kernel object properties, with handled via specialized show and store callback functions that format output into text or parse input accordingly. Directories in sysfs organize sub-objects hierarchically, mirroring the kobject structure, while symbolic links denote relationships between objects, such as those connecting devices to their drivers in the /sys/bus/ hierarchy. Attributes are defined using the struct attribute within a kobject type (ktype), which includes the name, ownership module, and permission ; by default, attributes are read-only ( 0444) unless the writable is set via 0644 to enable the store callback. Sysfs does not support files, with all interactions occurring through standard operations like reading with cat or writing with echo. For representation, sysfs limits attribute values to a buffer of PAGE_SIZE, typically 4096 bytes on x86 architectures, ensuring efficient kernel-to-userspace transfers without excessive memory use. Multi-line output is discouraged to maintain simplicity, favoring single-line or newline-separated values that fit within the buffer constraints. This design emphasizes exporting kernel data in a straightforward, text-based format accessible via the virtual filesystem mounted at /sys.

Reading and Writing Mechanisms

Sysfs attributes are accessed through standard file read and write operations, with the kernel implementing custom callbacks to handle these interactions dynamically. On the kernel side, reading an attribute file invokes the show() callback function associated with the attribute, which is responsible for formatting the current value of the underlying kernel object into a user-provided buffer typically sized to one page (PAGE_SIZE, often 4096 bytes on x86 architectures). This callback must use functions like sysfs_emit() to safely write the formatted string to the buffer and return the number of bytes written, ensuring null-termination for string data. The show() method is triggered by the read() system call from userspace, and for partial reads or seeks, it may be invoked multiple times to refill the buffer. For writing to sysfs attributes, the kernel employs the store() callback, which parses and processes the incoming data from the userspace write . This callback receives the entire content (up to PAGE_SIZE - 1 bytes, null-terminated) and is expected to validate the input, apply changes to the object if valid, and return the number of bytes successfully processed or an error code. The store() method is called in response to the write() system call, receiving up to PAGE_SIZE - 1 bytes from the userspace (null-terminated). Userspace should provide the complete value in a single write, as partial writes may not be handled correctly by the object. From the userspace perspective, simple command-line tools suffice for basic interactions with sysfs attributes. Reading is commonly performed using cat to display the attribute's value, such as cat /sys/class/net/eth0/speed to retrieve the link speed of a network interface. Writing involves tools like echo to send data to the attribute file, for example, echo mem > /sys/power/state to suspend the system to RAM, though such operations typically require root privileges due to the ownership and permissions of /sys files (usually mode 0644, owned by root). Error handling in these mechanisms ensures robustness; both show() and store() callbacks can return negative error codes to indicate issues, with -EINVAL commonly used for invalid input formats or arguments that cannot be parsed or applied. For instance, if the store() callback encounters malformed data, it returns -EINVAL to signal the error back to userspace via the write system call. Buffer overflows during formatting in show() are handled by truncation via safe printing functions like snprintf(), preventing kernel memory corruption. Many writeable attributes, upon successful processing, trigger kernel-side actions such as device reconfiguration or state changes, bridging userspace commands directly to hardware or subsystem behaviors.

Device and Subsystem Integration

Buses and Devices

In sysfs, buses are represented under the /sys/bus/ , which provides a flat layout of available bus types supported by the . Each bus type, such as pci/, usb/, or platform/, has its own subdirectory containing two primary subdirectories: devices/ and drivers/. The devices/ subdirectory holds symbolic links to the corresponding directories located under /sys/devices/, allowing userspace to discover all devices attached to that bus. Similarly, the drivers/ subdirectory includes entries for each loaded driver associated with the bus, facilitating driver-device interactions without exposing the full tree. Individual devices are exposed in a hierarchical manner under the /sys/devices/ directory, which mirrors the internal device derived from struct device relationships. Each device directory features a unique path reflecting its position in the hardware topology; for example, a device might appear as /sys/devices/pci0000:00/0000:00:1f.0/, where the path encodes the bus, segment, and device function details. Common attributes in these directories include vendor for the device ID and modalias for the device modalias string, which encodes identification information used for driver matching. The representation of buses and devices in sysfs emphasizes system topology through extensive use of symbolic links. For instance, links from /sys/bus/<bus_type>/devices/ point directly to the full device paths in /sys/devices/, enabling traversal of parent-child relationships such as a USB controller connected to a bus. This linking supports dynamic hotplug events via uevents, where kernel-generated notifications (e.g., "add" or "remove" actions) are emitted through the uevent file in each device directory, allowing userspace tools to respond to hardware changes without manual intervention. Bus-specific attributes provide targeted information about device capabilities and configurations. In the USB bus, for example, each device directory under /sys/bus/usb/devices/ includes a speed attribute indicating the connection speed, such as "480" for high-speed USB 2.0. Virtual buses like the platform/ bus handle non-discoverable devices integrated into System-on-Chip (SoC) architectures, where devices are registered statically during boot; these appear under /sys/bus/platform/devices/ with attributes tailored to embedded hardware, such as GPIO or clock controls, without relying on physical enumeration.

Classes and Drivers

In sysfs, device classes are organized under the /sys/class/ directory, which groups devices by their functional type rather than physical bus , providing a logical for userspace access. Each class subdirectory, such as net/ for devices, block/ for storage, or input/ for input peripherals, contains entries representing instances of that . For example, network interfaces appear as subdirectories like /sys/class/net/eth0/, where eth0 is a symbolic link to the actual location in /sys/devices/, allowing users to query class-specific attributes such as link status or without navigating the full . This functional grouping facilitates targeted management of similar devices across the system. Classes also offer user-friendly views tailored to specific subsystems; for instance, the power/supply/ class provides attributes for battery information, including charge level and status, enabling tools to monitor and control power sources uniformly. Similarly, the /sys/class/firmware/ directory supports firmware loading by allowing userspace applications to write firmware blobs to a loading attribute, triggering delivery to devices. Drivers are exported in sysfs under /sys/bus/<bus_type>/drivers/, with a subdirectory for each loaded driver on that bus, such as PCI or USB, containing attributes for runtime control. Key files include bind and unbind, which permit manual attachment or detachment of devices to the driver by writing device names to them, useful for testing or resolving binding issues. When a device binds successfully to a driver, a symbolic link appears in the driver's directory pointing to the device's sysfs entry, and vice versa from the device to the driver, establishing bidirectional linkages for querying associations. The driver_override attribute in device directories allows forcing a specific driver binding by writing its name, overriding automatic matching for specialized scenarios. Driver information, particularly for loadable modules, is further detailed in /sys/module/<module_name>/, where subdirectories like parameters/ expose tunable options and sections/ lists ELF section offsets (e.g., .text with its start address) for purposes, provided symbols are enabled via CONFIG_KALLSYMS.

Userspace Interaction

Command-Line Usage

Sysfs provides a straightforward for userspace interaction through standard commands, allowing administrators to discover, query, and configure objects without specialized software. Typically mounted at /sys, it supports operations using tools like cat, echo, ls, and find, which read or write ASCII text to pseudo-files representing attributes. These interactions leverage the underlying read/write mechanisms where attribute files are accessed via simple file I/O, with reads invoking show() functions and writes invoking store() functions, limited to PAGE_SIZE buffers (usually 4096 bytes). For device enumeration and discovery, the /sys/devices/ directory organizes the device hierarchy as a tree of directories and symlinks, reflecting bus topologies and parent-child relationships. The command ls /sys/devices/ lists top-level devices and buses, providing an overview of connected hardware such as PCI, USB, and platform devices. To locate device identifiers for driver matching, find /sys -name modalias searches for modalias files containing kernel module aliases, aiding in tasks like package management for hardware support. Additionally, symlinks in /sys/dev/char/ and /sys/dev/block/ map device major:minor numbers to their directories, enabling quick lookups by device node. Querying sysfs attributes involves reading files to retrieve state information, often as plain integers or strings. For instance, cat /sys/block/sda/size outputs the size of the first block device (e.g., a hard disk) in 512-byte sectors, allowing calculation of total capacity by multiplying by 512. Similarly, cat /sys/class/[thermal](/page/Thermal)/thermal_zone0/temp returns the temperature of the primary zone in millidegrees (e.g., 45000 indicates 45.0°C), useful for monitoring hardware health. These reads are non-destructive and reflect real-time data without requiring root privileges for most view-only attributes. Configuration changes are made by writing values to writable attributes, typically using echo to set runtime parameters. For example, echo 1 > /sys/module/usbcore/parameters/autosuspend sets the default USB autosuspend delay to 1 second, enabling power saving for idle devices by allowing them to suspend after the specified timeout. Writable files must receive the full buffer content, so partial writes are avoided; always verify readability first and handle potential errors from the kernel's store() function. Direct writes in scripts require error checking, such as verifying the exit status of echo or testing file permissions, to prevent silent failures. Hotplug events, triggered by device addition or removal, generate uevents that sysfs exposes for monitoring and handling. In modern kernels (since version 3.15 as of 2014), uevents are primarily handled directly by userspace processes like via sockets for efficient, real-time delivery, bypassing legacy helpers. Historically, the /sys/kernel/uevent_helper specified the path to a userspace helper program (e.g., /sbin/mdev or empty for netlink-based systems like ), which processed these events; reading it shows the current helper, while writing updates it at runtime. However, this mechanism is deprecated and optional (via CONFIG_UEVENT_HELPER), and is not used in contemporary distributions with /. Udev rules, defined in /etc/udev/rules.d/, are commonly triggered by sysfs changes, such as attribute matches, to automate actions like mounting filesystems or loading modules during hotplug. Monitoring can involve watching /sys/kernel/uevent sequences or using tools to tail event logs, but direct sysfs polling is inefficient compared to event-based mechanisms. The sysfsutils package provides the systool command for structured querying of sysfs, simplifying device and attribute inspection beyond basic shell tools. Running systool without arguments lists all bus types, classes, and root devices; systool -b usb -a displays USB bus devices with their attributes, such as vendor IDs and statuses. For module-specific views, systool -m usbcore shows parameters like autosuspend, aiding without manual traversal. While convenient, systool relies on libsysfs and is best for one-off queries rather than real-time scripting.

Tools and Libraries

Several command-line tools facilitate interaction with sysfs beyond basic shell commands. The systool utility, part of the sysfsutils package, allows users to query and list devices and drivers by bus, class, or topology, providing a structured view of sysfs contents. Similarly, udevadm from the systemd package enables inspection of uevents and sysfs properties, such as printing all attributes along a device's sysfs chain for rule matching or monitoring kernel events in real-time. For programmatic access, historical libraries like libsysfs offered an over sysfs for querying devices, but it has been deprecated since in favor of direct filesystem access or modern alternatives. Contemporary applications typically use , which provides an to enumerate devices, query sysfs attributes, and monitor uevents through the udev database, though it is now recommended to migrate to sd-device for new projects. In scripting languages like , sysfs is accessed directly via the standard os module for path handling and built-in file operations to read or write attribute files. Sysfs integrates with higher-level frameworks for device management; the deprecated Hardware Abstraction Layer (HAL) formerly used sysfs and uevents to expose hardware information via D-Bus for event propagation to desktop environments. Modern systems rely on systemd, which leverages sysfs through udev for dynamic device handling, creating device units and propagating changes via D-Bus to services like udisks or NetworkManager. In embedded and scripting environments, lightweight tools like provide essential applets such as and echo to read and write sysfs files efficiently, supporting minimal setups without full utilities. Developers should avoid deprecated APIs like libsysfs post-2006 to ensure compatibility with current kernels.

Guidelines and Considerations

Attribute Design Rules

Sysfs attributes should represent a single integer or value per file to maintain simplicity and predictability, avoiding , multi-value outputs, or mixed data types within the same file. This "one value per file" principle, a core design goal of sysfs, ensures efficient and reduces complexity for userspace tools, though arrays of similar types are occasionally permitted as an exception. Mixing different data types, using multiple lines, or employing non-standard formatting in a single attribute file is discouraged, with developers encouraged to use subdirectories for organizing complex or hierarchical data instead. It is recommended to use consistent units for attribute values to facilitate ; for example, frequencies should be expressed in Hertz (Hz). Read and write operations are limited to a buffer size of PAGE_SIZE, typically 4096 bytes on x86 architectures, requiring the show() callback to fill the completely and the store() callback to process the full null-terminated input provided on the first write. Developers must handle potential partial writes gracefully in the store() function by validating and parsing the input robustly, as sysfs passes the entire at once but userspace may modify only portions after reading. For security, writable attributes require thorough input validation in their store() callbacks to prevent invalid or malicious data from affecting kernel behavior or system stability. Best practices include documenting all new attributes in the kernel's directory to establish their and stability expectations, and avoiding placement of sysfs callbacks on critical paths to prevent spikes, as these operations can involve or complex computations.

ABI Stability and Documentation

Sysfs constitutes a critical component of the 's (ABI), providing a stable mechanism for userspace applications to access and manipulate -managed device information and configurations. The development policy mandates that documented sysfs interfaces maintain for a minimum of two years, allowing userspace programs to rely on them without fear of disruption from updates. This commitment extends to sysfs exports, where changes that could break existing userspace tools are rigorously avoided through structured processes. To implement this stability, any proposed modifications to stable sysfs attributes must first transition them to an "obsolete" status, accompanied by a detailed rationale, timeline for removal (often spanning multiple releases), and provision of alternatives to mitigate impact on userspace. For example, the /sys/class/ interface, which exposes and status, cannot be removed without establishing equivalent replacements, ensuring continuity for tools like daemons. New attributes can be introduced to enhance functionality, but existing ones in the stable ABI remain preserved to uphold this guarantee. Documentation for sysfs interfaces is centralized in the kernel source tree under the /ABI directory, with stable entries specifically in /ABI/stable/sysfs-, detailing each attribute's purpose, access methods, and expected behavior. Kernel contributors are required to document all new sysfs attributes in this format upon submission, including a rationale for their addition and classification as stable, testing, or otherwise, to facilitate review and long-term maintenance. This formalized practice, emphasizing transparency, helps userspace developers understand stability levels and plan accordingly.

References

  1. [1]
    sysfs - _The_ filesystem for exporting kernel objects
    Aug 16, 2011 · sysfs is a RAM-based filesystem initially based on ramfs. It provides a means to export kernel data structures, their attributes, and the linkages between them ...
  2. [2]
    sysfs(5) - Linux manual page - man7.org
    This manual page is incomplete, possibly inaccurate, and is the kind of thing that needs to be updated very often. SEE ALSO top. proc(5), udev(7) P. Mochel. ( ...
  3. [3]
    Rules on how to access information in sysfs
    The kernel-exported sysfs exports internal kernel implementation details and depends on internal kernel structures and layout. It is agreed upon by the kernel ...
  4. [4]
    sysfs - _The_ filesystem for exporting kernel objects — The Linux Kernel documentation
    ### Summary of sysfs from https://www.kernel.org/doc/html/latest/filesystems/sysfs.html
  5. [5]
    [PDF] The sysfs Filesystem - The Linux Kernel Archives
    sysfs is a feature of the Linux 2.6 kernel that al- lows kernel code to export information to user processes via an in-memory filesystem. The or- ganization of ...
  6. [6]
    [PDF] The Linux Device Model - LWN.net
    Sysfs representation. Every object that shows up in sysfs has, underneath it, a kobject that interacts with the kernel to create its visible representation.
  7. [7]
    [PDF] The sysfs Filesystem - The Linux Kernel Archives
    Most distri- butions that support the 2.6 kernel have entries for sysfs in /etc/fstab. An example entry is shown in Table 2. Note that the directory that sysfs ...
  8. [8]
    devfs - The Linux Kernel Archives
    The files fs/devfs/*, include/linux/devfs_fs*.h were removed, along with the assorted devfs function calls throughout the kernel tree. Users:
  9. [9]
    sysfs.txt - The Linux Kernel Archives
    Aug 16, 2011 · It provides a means to export kernel data structures, their attributes, and the linkages between them to userspace. sysfs is tied inherently to ...
  10. [10]
    [PDF] udev – A Userspace Implementation of devfs
    Also, without Pat Mochel's sysfs and driver model core, udev would not even have been possible to implement. The author is indebted to him for undertaking what.Missing: history | Show results with:history
  11. [11]
    Kernel development - LWN.net
    Kernel release status. The current stable 2.6 release is 2.6.13.3, announced on October 3. It adds a handful of fixes, many in the networking subsystem.Missing: uevents | Show results with:uevents
  12. [12]
    sysfs-hypervisor-xen
    What: /sys/hypervisor/properties/features Date: March 2009 KernelVersion: 2.6.30 Contact: xen-devel@lists.xenproject.org Description: If running under Xen: ...
  13. [13]
    A Lot Of Rust Code Lining Up For The Linux 6.18 Kernel - Phoronix
    Sep 29, 2025 · ... sysfs integration enhancements, and various other Rust driver changes. The locking pull request meanwhile adds initial support for generic ...
  14. [14]
  15. [15]
    Device Drivers - The Linux Kernel documentation
    When a driver is registered, a sysfs directory is created in its bus's directory. In this directory, the driver can export an interface to userspace to control ...
  16. [16]
    sysfs-module
    The /sys/module tree consists of the following structure: What: /sys/module/<MODULENAME> Description: The name of the module that is in the kernel. This module ...
  17. [17]
    Module section offsets in /sys/module [LWN.net]
    # cd /sys/module/$1/sections echo -n add-symbol-file $2 `/bin/cat .text` for section in .[a-z]* *; do if [ $section != ".text" ]; then echo " \\" echo -n ...
  18. [18]
    Determine the size of a block device - Unix & Linux Stack Exchange
    Jun 22, 2009 · cat /sys/class/block/sda/size. This gives you its size in 512-byte ... For example /sbin/fdisk -l /dev/cdrom will work on my system and ...Calculate disk Byte size exclusively from /sys/blockGet block device model name and manufacturer from pseudo-fsMore results from unix.stackexchange.comMissing: sysfs | Show results with:sysfs
  19. [19]
    Thermal Zone
    This interface function adds a new thermal zone device (sensor) to /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the thermal cooling ...
  20. [20]
    Power Management for USB - The Linux Kernel Archives
    Setting the initial default idle-delay to -1 will prevent any autosuspend of any USB device. This has the benefit of allowing you then to enable autosuspend for ...
  21. [21]
    systool(1) — sysfsutils — Debian unstable - Debian Manpages
    Mar 28, 2025 · Calling systool without parameters will present all available bus types, device classes, and root devices. When device is supplied, the ...Missing: line examples
  22. [22]
    udevadm(8) - Linux manual page - man7.org
    It controls the runtime behavior of systemd-udevd, requests kernel events, manages the event queue, and provides simple debugging mechanisms.Missing: inspection | Show results with:inspection
  23. [23]
    Bug#856062: Please don't use obsolete libsysfs-dev any more
    Feb 27, 2017 · ... libsysfs-deprecation Hello, Some years ago libsysfs (source package: sysfsutils) was written as an abstraction layer for accessing /sys/.Missing: sysfs | Show results with:sysfs
  24. [24]
    libudev - Freedesktop.org
    libudev.h provides an API to introspect and enumerate devices on the local system. This library is supported, but should not be used in new projects.
  25. [25]
    os — Miscellaneous operating system interfaces — Python 3.14.0 ...
    This module provides a portable way of using operating system dependent functionality. If you just want to read or write a file see open().Os.path · Shutil · Generic Operating System... · Interpreting stat() results
  26. [26]
    HAL 0.5.14 Specification - FreeDesktop.Org
    This document concerns the specification of HAL which is a piece of software that provides a view of the various hardware attached to a system.
  27. [27]
    systemd.device - Freedesktop.org
    A unit configuration file whose name ends in ".device" encodes information about a device unit as exposed in the sysfs/udev(7) device tree.
  28. [28]
    A critical look at sysfs attribute values - LWN.net
    Mar 17, 2010 · The key design goal relating to attribute files is the stipulation - almost a mantra - of "one file, one value" or sometimes "one item per file".Missing: documentation | Show results with:documentation
  29. [29]
    Linux ABI description - The Linux Kernel documentation
    We have four different levels of ABI stability, as shown by the four different subdirectories in this location. Interfaces may change levels of stability ...
  30. [30]
    Sysfs and a stable kernel ABI - LWN.net
    Feb 22, 2006 · Back in the dim and distant past (last year), the "user events" mechanism was added to the kernel. One of the first events to be implemented was ...Missing: uevents | Show results with:uevents
  31. [31]
    ABI obsolete symbols - The Linux Kernel documentation
    ABI obsolete symbols¶. Documents interfaces that are still remaining in the kernel, but are marked to be removed at some later point in time.
  32. [32]
    documentation for /sys/class/power_supply
    Negative values are used for discharging batteries, positive values for charging batteries and for USB IBUS current. What: /sys/class/power_supply/<supply_name ...Missing: stable | Show results with:stable