~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/admin-guide/sysfs-rules.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/admin-guide/sysfs-rules.rst (Version linux-6.12-rc7) and /Documentation/admin-guide/sysfs-rules.rst (Version policy-sample)


  1 Rules on how to access information in sysfs       
  2 ===========================================       
  3                                                   
  4 The kernel-exported sysfs exports internal ker    
  5 and depends on internal kernel structures and     
  6 by the kernel developers that the Linux kernel    
  7 internal API. Therefore, there are aspects of     
  8 may not be stable across kernel releases.         
  9                                                   
 10 To minimize the risk of breaking users of sysf    
 11 low-level userspace applications, with a new k    
 12 of sysfs must follow some rules to use an as-a    
 13 access this filesystem. The current udev and H    
 14 implement this and users are encouraged to plu    
 15 abstractions these programs provide instead of    
 16                                                   
 17 But if you really do want or need to access sy    
 18 the following rules and then your programs sho    
 19 versions of the sysfs interface.                  
 20                                                   
 21 - Do not use libsysfs                             
 22     It makes assumptions about sysfs which are    
 23     offer any abstraction, it exposes all the     
 24     implementation details in its own API. The    
 25     reading directories and opening the files     
 26     Also, it is not actively maintained, in th    
 27     current kernel development. The goal of pr    
 28     to sysfs has failed; it causes more proble    
 29     violates many of the rules in this documen    
 30                                                   
 31 - sysfs is always at ``/sys``                     
 32     Parsing ``/proc/mounts`` is a waste of tim    
 33     system configuration bug you should not tr    
 34     possibly support a ``SYSFS_PATH`` environm    
 35     application's behavior, but never try to s    
 36     to mount it, if you are not an early boot     
 37                                                   
 38 - devices are only "devices"                      
 39     There is no such thing like class-, bus-,     
 40     interfaces, and such that you can rely on     
 41     just simply a "device". Class-, bus-, phys    
 42     kernel implementation details which should    
 43     applications that look for devices in sysf    
 44                                                   
 45     The properties of a device are:               
 46                                                   
 47     - devpath (``/devices/pci0000:00/0000:00:1    
 48                                                   
 49       - identical to the DEVPATH value in the     
 50         at device creation and removal            
 51       - the unique key to the device at that p    
 52       - the kernel's path to the device direct    
 53         ``/sys``, and always starting with a s    
 54       - all elements of a devpath must be real    
 55         pointing to /sys/devices must always b    
 56         target and the target path must be use    
 57         That way the devpath to the device mat    
 58         kernel used at event time.                
 59       - using or exposing symlink values as el    
 60         is a bug in the application               
 61                                                   
 62     - kernel name (``sda``, ``tty``, ``0000:00    
 63                                                   
 64       - a directory name, identical to the las    
 65       - applications need to handle spaces and    
 66         the name                                  
 67                                                   
 68     - subsystem (``block``, ``tty``, ``pci``,     
 69                                                   
 70       - simple string, never a path or a link     
 71       - retrieved by reading the "subsystem"-l    
 72         last element of the target path           
 73                                                   
 74     - driver (``tg3``, ``ata_piix``, ``uhci_hc    
 75                                                   
 76       - a simple string, which may contain spa    
 77         link                                      
 78       - it is retrieved by reading the "driver    
 79         last element of the target path           
 80       - devices which do not have "driver"-lin    
 81         driver; copying the driver value in a     
 82         bug in the application                    
 83                                                   
 84     - attributes                                  
 85                                                   
 86       - the files in the device directory or f    
 87         of the same device directory              
 88       - accessing attributes reached by a syml    
 89         like the "device"-link, is a bug in th    
 90                                                   
 91     Everything else is just a kernel driver-co    
 92     that should not be assumed to be stable ac    
 93                                                   
 94 - Properties of parent devices never belong in    
 95     Always look at the parent devices themselv    
 96     context properties. If the device ``eth0``    
 97     "driver"-link, then this device does not h    
 98     Never copy any property of the parent-devi    
 99     device properties may change dynamically w    
100     child device.                                 
101                                                   
102 - Hierarchy in a single device tree               
103     There is only one valid place in sysfs whe    
104     and this is below: ``/sys/devices.``          
105     It is planned that all device directories     
106     below this directory.                         
107                                                   
108 - Classification by subsystem                     
109     There are currently three places for class    
110     ``/sys/block,`` ``/sys/class`` and ``/sys/    
111     not contain any device directories themsel    
112     symlinks pointing to the unified ``/sys/de    
113     All three places have completely different    
114     device information. It is planned to merge    
115     classification directories into one place     
116     following the layout of the bus directorie    
117     classes, including the converted block sub    
118     there.                                        
119     The devices belonging to a subsystem will     
120     "devices" directory at ``/sys/subsystem/<n    
121                                                   
122     If ``/sys/subsystem`` exists, ``/sys/bus``    
123     can be ignored. If it does not exist, you     
124     places, as the kernel is free to move a su    
125     the other, as long as the devices are stil    
126     subsystem name.                               
127                                                   
128     Assuming ``/sys/class/<subsystem>`` and ``    
129     ``/sys/block`` and ``/sys/class/block`` ar    
130     the application.                              
131                                                   
132 - Block                                           
133     The converted block subsystem at ``/sys/cl    
134     ``/sys/subsystem/block`` will contain the     
135     at the same level, never in a hierarchy. A    
136     contain only disks and not partition devic    
137     a bug in the application.                     
138                                                   
139 - "device"-link and <subsystem>:<kernel name>-    
140     Never depend on the "device"-link. The "de    
141     for the old layout, where class devices ar    
142     ``/sys/devices/`` like the bus devices. If    
143     device directory does not end in ``/sys/de    
144     "device"-link to find the parent devices i    
145     single valid use of the "device"-link; it     
146     path as an element. Assuming the existence    
147     a device in ``/sys/devices/`` is a bug in     
148     Accessing ``/sys/class/net/eth0/device`` i    
149                                                   
150     Never depend on the class-specific links b    
151     directory.  These links are also a workaro    
152     that class devices are not created in ``/s    
153     directory does not contain directories for    
154     may be used to find the child devices in `    
155     valid use of these links; they must never     
156     element. Assuming the existence of these l    
157     real child device directories in the ``/sy    
158     the application.                              
159                                                   
160     It is planned to remove all these links wh    
161     directories live in ``/sys/devices.``         
162                                                   
163 - Position of devices along device chain can c    
164     Never depend on a specific parent device p    
165     or the chain of parent devices. The kernel    
166     the chain. You must always request the par    
167     by its subsystem value. You need to walk u    
168     the device that matches the expected subsy    
169     position of a parent device or exposing re    
170     access the chain of parents is a bug in th    
171                                                   
172 - When reading and writing sysfs device attrib    
173     on specific error codes wherever possible.    
174     the error handling implementation within t    
175                                                   
176     In general, failures to read or write sysf    
177     propagate errors wherever possible. Common    
178     limited to:                                   
179                                                   
180         ``-EIO``: The read or store operation     
181         returned by the sysfs system itself if    
182         is ``NULL``.                              
183                                                   
184         ``-ENXIO``: The read or store operatio    
185                                                   
186     Error codes will not be changed without go    
187     to error codes result in user-space breaka    
188     the offending change will be reverted.        
189                                                   
190     Userspace applications can, however, expec    
191     the attribute files to remain consistent i    
192     attribute change in the context of a given    
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php