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
6
votes
1 answer

Under what conditions would /sys/kernel/debug/gpio be empty?

Summary My aim is to control the GPIO pins in Peppermint 4 Linux (Kernel version 3.8.0) on an Intel motherboard (NM70 chipset with C1037U processor). I'm debugging issues I'm having using the sysfs interface and am trying to understand the…
CalumJEadie
  • 189
  • 4
  • 12
5
votes
1 answer

poll() from userspace on a sysfs file and sysfs_notify() from kernelspace won´t work tegether

My kernel module for raspi, written to get a double light barrier, reads monotonic time if each of two input gpio´s edges are rising and an interrupt occours. The time value is passed via normal sysfs files to userspace(not dev files). This works…
pfau
  • 101
  • 1
  • 8
5
votes
1 answer

Can a sysfs attribute take a non numeric value in Linux Device Driver?

I am developing a Linux device driver where I have to pass a string of characters to it using sysfs interface. Can the sysfs attributes accept the data in a string form (something like echo "somedata" > sysfs_interface )? I have implemented it…
Raulp
  • 7,758
  • 20
  • 93
  • 155
5
votes
1 answer

How to calculate the time remaining until the end of the battery charge

I have the following output: $ cat…
mhd
  • 535
  • 1
  • 5
  • 12
5
votes
1 answer

Capturing Global Keyboard Events On Linux With NodeJS

I have a headless Debian ARM machine that I'm running Node on. The device has hard buttons that are mapped to normal keyboard events using gpio-keys. My goal is to capture the global events from both the hard buttons as well as any attached…
Wasabi Fan
  • 1,763
  • 3
  • 22
  • 36
5
votes
0 answers

Count number of preemption for a running process in Linux

Is there any way to count preemption for specific PID from user space ? I am interested to measure how many times a process is preempted.
ARH
  • 1,355
  • 3
  • 18
  • 32
5
votes
1 answer

How is sysfs updated when a GPIO changes state?

Assume that the gpio X can be exported in sysfs as an input pin, after doing that a directory called gpioX will be created into /sys/class/gpio/. gpioX/ contains few file such as "value" which represents the current state of the gpio X (high or…
b0b0b
  • 134
  • 1
  • 8
5
votes
2 answers

How does linux kernel creates sysfs?

I have started looking at linux kernel code for my OS course. In that I'm interested in sys file system (sysfs). I'm interested in finding out when and how sysfs gets created? Which files in linux kernel code generate this file system? I have setup…
Rajesh Golani
  • 448
  • 1
  • 6
  • 13
4
votes
1 answer

Linux Userspace GPIO Interrupts using sysfs

I would like to use interrupts with GPIO on userspace using sysfs. I use these commands : [root@at91]:gpio109 > echo 109 > export [root@at91]:gpio109 > cd gpio109/ [root@at91]:gpio109 > ll -rw-r--r-- 1 root 0 4096 Jan 1 00:17…
lgm42
  • 591
  • 1
  • 6
  • 29
4
votes
2 answers

what is the /sys/class/gpio/export and `/sys/class/gpio/unexport mechanism and what is the underlying sysfs functionality?

Using the legacy sysfs GPIO under Android and Linux the first step in the process is toe export the particular GPIO pins you want to use. And when you are done with the GPIO pin to unexport it. I've been looking for an explanation of what the export…
Richard Chambers
  • 16,643
  • 4
  • 81
  • 106
4
votes
0 answers

Adding own sysfs device attribute group to existing standard device class attributes

One of Linux kernel training courses task is to add sysfs support to one of previously written device drivers. I choose my ds1307 rtc driver and want to add device attributes, not to replace rtc device ones. But I am not sure that my solution is…
ReAl
  • 1,231
  • 1
  • 8
  • 19
4
votes
2 answers

Open a file as root, but drop privileges before reading from it?

TL;DR I am writing a C program. I need to have root privileges to fopen a sysfs file, and I still need root privileges in order to read from it. However, since my program will need to continuously read the sysfs file, this implies that it will need…
Marco Merlini
  • 875
  • 7
  • 29
4
votes
2 answers

IIO Linux : How to know when the buffer is full?

I am using IIO drivers from userspace to read the value of an ADC (AD7924). I have all steps to get a triggered acquisition working ( create a trigger, assign it, enable the ADC channels, set the dimension of the buffer, and enable it). Here is the…
dudu721
  • 342
  • 1
  • 3
  • 13
4
votes
1 answer

How to read sysfs device path?

I have a USB touchscreen connected to my hardware setup. and when I use cat /proc/bus/input/devices I get the following details about my device: I: Bus=0003 Vendor=2965 Product=5023 Version=0110 N: Name="Kortek Kortek Touch" P:…
Monku
  • 2,440
  • 4
  • 33
  • 57
4
votes
1 answer

How to get a parent kobject for a path in sysfs?

How it is possible to get a kobject for, say, a path of /sys/devices, for use as parent kobject for your own sysfs entry ?
Alexander Tumin
  • 1,561
  • 4
  • 22
  • 33
1
2
3
15 16