Questions tagged [sysfs]

Sysfs is a virtual file system provided by Linux. It is a ram-based file-system initially based on ramfs. It provides a means to export kernel data structures, their attributes, and the linkages between them to userspace.

Sysfs exports information about devices and drivers from the kernel device model to user space, and is also used for configuration. The Linux 2.6 kernel introduced this. It is similar to the sysctl mechanism found in BSD systems, but implemented as a file system instead of a separate mechanism.

It provides a view of the kobject object hierarchy. It enables users to view the device topology of their system as a simple filesystem.

The sysfs file system is mounted at /sys/ and contains directories that organize the devices attached to the system in several different ways. The /sysfs/ subdirectories include:

  • The /devices/ directory - represent all the subchannels detected by the Linux kernel and configuration options for the device
  • The /bus/ directory - contains contains a symbolic link to the device directories and for each device driver currently loaded on the system.
  • The /class/ directory - contains directories that group together similar devices such as ttys, SCSI tape drives, network devices, and other miscellaneous devices.
  • The /block/ directory - contains directories for each of the block devices on the system.

Read more

230 questions
1
vote
1 answer

mount sysfs with write permissions on unpriviliged docker container

when running docker run -v /sys:/sys:rw $NAME $COMMAND , the container tries to write to a file in /sys, but this causes a "Permission denied" error. The container user is root. In host, root has write permission to the files. this issue is fixed…
jsofri
  • 227
  • 1
  • 10
1
vote
0 answers

Embedded Linux: Adding device file to existing device sysfs class

I am using Linux kernel release 5.4. I have one kernel built-in driver, which creates a sysfs class: /sys/night_owl/tick1/* using class_create() and device_create_file() function. I am developing another kernel loadable module, which reuses the…
1
vote
2 answers

How can I create a soft link(symbolic link) under /sys/kernel/config/nvmet/ports?

Since I am trying to configure the NVMet-RDMA target on the server, I want to create a symbolic link by the following command(according to…
白家栋
  • 11
  • 1
1
vote
2 answers

How to add a disk back to sysfs after deleting it

A fs disk failure was simulated by: echo 1 > /sys/block/sda/device/delete which removes it from /dev dir. What is the procedure of adding it back?
John Karasev
  • 151
  • 2
  • 11
1
vote
0 answers

Linux Kernel API: meaning and stability of nodes under `/sys/devices/pci...` tree in sysfs

The essence of my question is almost painfully simple: Given my current hardware, would the design of Linux sysfs allow me to expect that the device at /sys/devices/pci0000:00/0000:00:14.0/usb1/1-6 will always be the same device at that same…
pestophagous
  • 4,069
  • 3
  • 33
  • 42
1
vote
1 answer

How to check whether an ethernet interface is up with some IP or not in LINUX only using sysfs?

While searching this i came across /sys/class/net/eth0/operstate(will contain "up/down") and /sys/class/net/eth0/carrier(will contain either "0/1") , whose values depends on whether the interface is "up/down" and any physical Ethernet cable is…
rakd
  • 179
  • 1
  • 2
  • 12
1
vote
0 answers

Testing sysfs thermal driver APIs

I'm setting and reading different values of the temperature threshold. I set it by echoing the value to the following file: /sys/devices/virtual/thermal/thermal_zoneN/trip_point_X_temp It works fine but how do I verify the behavior through logs? Is…
xyf
  • 664
  • 1
  • 6
  • 16
1
vote
1 answer

how to use poll(2) or select(2) service call to watch a pseudo file for changes with Kotlin

I am working with a DragonBoard 410C using Android 5.1 and Kotlin to experiment with the GPIO pins on the 40 pin low power connector. The library I'm using is using the sysfs interface for interacting with the GPIO pins which requires opening…
Richard Chambers
  • 16,643
  • 4
  • 81
  • 106
1
vote
1 answer

How can I get a filesystem label from sysfs?

How can I get the label of a filesystem using /sys? I know I can get much of the info about a block device by going to /sys/class/block/, e.g. /sys/class/block/sr1 for a cd that I know has the filesystem label config. I hunted through each…
deitch
  • 14,019
  • 14
  • 68
  • 96
1
vote
0 answers

PWM on NVIDIA Jetson Nano Developer Kit

I'm working on a Jetson Nano for my MSc thesis. At this time I have to control a camera using PWM signal generated from NVIDIA SBC, so after set PWM capability with their own tool (Jetson-IO), I'm trying to produce the signal. I have been successful…
J. De Luca
  • 11
  • 1
1
vote
2 answers

How can I dynamically remove or retrigger the probing an EEPROM via sysFS?

I am wondering what the proper way is to remove EEPROMs dynamically. An alternate approach that will also work is telling the device to re-do the probe. I tried just echoing it to delete_device, but that gives an error that it can't find it in the…
Eskimoalva
  • 449
  • 8
  • 20
1
vote
3 answers

ftell/fseek is different from the actual readable data length in a /sys/class file

embedded linux system ls -al /sys/class/xxxx -r--r--r-- 4096 ftell/lstat(st_size) return 4096 fread(fp, 1, 4096, buf) returns 3 Actually, there are only 3 bytes in file using vi to open it. What's the problem?
Kathy.Pu
  • 97
  • 6
1
vote
0 answers

sysfs_store gets called multiple times after error is returned

I created a kernel module with the following function for test purposes: ssize_t sysfs_store(struct device *dev, struct device_attribute *attr, const char *buffer, size_t count) { printk(KERN_ERR "test" ); return -EINVAL; } However,…
Mathijs
  • 177
  • 3
  • 18
1
vote
2 answers

echo: write error: Invalid argument while setting io_poll for NVMe SSD

I am using the following command as a root user to enable Linux kernel polling for a NVMe SSD device. # echo 1 > /sys/block/nvme2n1/queue/io_poll I get the following error: bash: echo: write error: Invalid argument OS details : Ubuntu 16.04, Linux…
1
vote
0 answers

Unable to reset USB LTE modem after -EPROTO error

BLUF I can no longer toggle the power of an LTE Modem via sysfs because it is now being removed from sysfs after an error occurs. How can I get it back into the usb sysfs and toggle the power? Background I am using an USB LTE modem with the…
Liam Kelly
  • 3,524
  • 1
  • 17
  • 41