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

Kernel module's parameters in sysfs - quick reaction for changes

Is it possible to notify the module when one of it's sys files was changed? My task is to do a file which controls size of buffer inside the module, I want to resize the buffer when the value in the file is changed. My other idea (if I can't notify…
Wojciech Reszelewski
  • 2,656
  • 2
  • 18
  • 27
3
votes
2 answers

What is the kernel module responsible for /sys/class/power_supply/BAT0?

After twiddling LEDs with /sys/class/leds/, I'm now trying to understand how to control the battery in my computer with linux kernel power supply attributes, specifically CHARGE_CONTROL_LIMIT. However, no such attribute exists in…
RemarkableBucket
  • 340
  • 4
  • 11
3
votes
1 answer

Create a symlink to a file in kernel module

I am trying to create a symbolic link to a file in a Linux kernel module. With the following code, I have created a directory in sys/kernel and then created a file in that directory: // Create the base directory in sys/kernel if…
Łukasz Przeniosło
  • 2,725
  • 5
  • 38
  • 74
3
votes
1 answer

How to send HDMI-CEC commands from Amlogic 905x board to the TV using sysfs

I want to send raw HDMI-CEC commands (adb shell) from an Amlogic 905x ARM board (Android 6) to test the functionality. The board is rooted (tested, 'adb root' works) and connected to a TV with CEC capabilities (enabled, tested with video game…
orouwk
  • 355
  • 3
  • 13
3
votes
1 answer

reading "/proc/bus/input/devices" programmatically

Is there a way to read contents /proc/bus/input/devices programmatically using some sysfs structures ? I know I can parse the file and get values. But I am looking if there is a better method.
Monku
  • 2,440
  • 4
  • 33
  • 57
3
votes
1 answer

How to get interface name from IPv4 ip address using only fs and bash in Linux?

How to get interface name from IPv4 ip address using only filesystem like /proc, /dev, /sys and bash? Is this possible without using the commands (such as ip, ifconfig, etc.)? I am also not able to use any packages or install any tools. Edit: The…
3
votes
1 answer

Portable way to determine sector size in Linux

I want to write a small program in C which can determine the sector size of a hard disk. I wanted to read the file located in /sys/block/sd[X]/queue/hw_sector_size, and it worked in CentOS 6/7. However when I tested in CentOS 5.11, the file…
vesontio
  • 381
  • 1
  • 7
  • 19
3
votes
1 answer

Why doesn't configfs support mmap?

I'm developing a linux kernel module for an embedded system. The system contains programmable logic (PL), which needs to be accessed from userspace processes. The PL can change at runtime. My module allows processes to access specified hw…
drechsler
  • 33
  • 4
3
votes
0 answers

How to find a device node in /dev from physical USB port?

Given two identical USB devices with the exact same USB descriptors and thus with absolutely no way to differentiate them only using the leaf information of the device information view (the USB device descriptor) as usually done (yes, this device is…
Julio Guerra
  • 5,523
  • 9
  • 51
  • 75
3
votes
0 answers

Is it necessary to perform sysfs_remove_file() when you're removing that entire kobject anyways?

In the code for my Linux Kernel module, I create a kobject, which becomes a directory in the /sys/ directory, and then create a sysfs file in it. So it looks like /sys/KobjName/SysfsFile. This is the only file in that kobject directory, and both the…
Jon
  • 359
  • 1
  • 2
  • 10
3
votes
1 answer

number bytes read from gpio input is zero

I have some strange behaviour when trying to read gpio output pin. I get that the first read return 1 (1 bytes read), but all next read from same gpio return 0. I would assume that it should always read 1, because there is always something to read…
ransh
  • 1,589
  • 4
  • 30
  • 56
3
votes
1 answer

Sysfs GPIO level-triggered interrupts

I'm a newbie trying to get level triggered interrupts on an embedded linux board. I'm using poll() to wait for the interrupt event. I was successful in getting edge triggered interrupts. How can I get level-triggered interrupts? What do I set the…
Zaxter
  • 2,939
  • 3
  • 31
  • 48
3
votes
2 answers

Multiple Battery entries in /sys/class/power_supply on Android

I am trying to read battery information from an NDK app. The only way I know to accomplish this is to read the values out /sys/class/power_supply. My difficulty is that I find multiple entries with type "Battery" and I don't know which one to…
aschmied
  • 908
  • 2
  • 10
  • 26
3
votes
1 answer

What is the difference between Virtual File System and System Call?

As I understand, kernel provides mainly two interface for user space to do something in kernel, these are System Call and Virtual File system (procfs, sysfs etc). What I read in a book, that internally VFS also uses System Call. So I want to know,…
Rahul
  • 1,607
  • 3
  • 23
  • 41
3
votes
0 answers

How can you check whether your kernel supports GPIO on your hardware?

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). How can you check whether your kernel supports GPIO on your hardware? Background Motherboard: Intel with…
CalumJEadie
  • 189
  • 4
  • 12
1 2
3
15 16