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

poll() on raspberry-gpio (sysfs) raspberry

as the title states, I have a problem porting some userspace-interrupt code from another armv7 embedded linux platform onto the Raspberry Pi 2 Model B. I'm aware of the wiringPi library (and got it to work that way), but for evaluation reasons I…
patteb
  • 31
  • 5
2
votes
1 answer

How to stop/restart USB device (Linux embedded system)

Hello USB / Linux gurus! I have an embedded system based on an Atmel ARM Cortex-A5 CPU. It runs embedded Linux kernel V3.10 that configures its high-speed USB port as a USB device. The USB device is configured as a USB composite made up of HID,…
Jeepster
  • 129
  • 2
  • 11
2
votes
1 answer

Recommended way to create many sysfs directories and attributes for a linux device driver

I need to create a whole bunch of attributes for a driver, which makes it impractical to allocate them statically (64 directories with 5 attributes each). It looks like there are multiple ways to create directories in sysfs. One seems to be…
Jan
  • 485
  • 3
  • 9
2
votes
0 answers

Determine Mac driver that is associated with a device when knowing major and minor numbers

Is there a way in Mac OS X that I can determine which device driver is associated with a particular device inside the /dev directory when device's major and minor numbers are known? I have an FTDI device connected to my computer and need to know…
KoKa
  • 797
  • 1
  • 14
  • 31
2
votes
1 answer

Kernel module export many device attributes to userspace

I'm working with a kernel driver for an I2C device and up until now I've been making simple attributes available using the sysfs DEVICE_ATTR helper. Now I need to make a long list of attributes available like /sys/bus/i2c/device/.../param0,…
fwrawx
  • 171
  • 1
  • 10
2
votes
0 answers

How to know when Linux has been awakened from standby mode?

I'm working on an ARM-based Linux computer that has enabled a few features of the sysfs power interface. I know how to send it to standby (writing "standby" to /sys/power/state) but I can't find how to acknowledge the wakeup (which I perform though…
Carles Araguz
  • 1,157
  • 1
  • 17
  • 37
2
votes
1 answer

Linux USB: libusb vs sysfs

On a Linux system, I need to list all USB hosts and devices with various information like class, product id, etc. I figure both libusb and sysfs are up to the task (correct?). So which one is the better?
lang2
  • 11,433
  • 18
  • 83
  • 133
2
votes
1 answer

How to store an array on sysfs in Linux kernel module?

I am writing Linux Kernel module, where I'm creating some sysfs files to store variables. But I need to implement arrays, something like: struct ats { struct attribute attr; unsigned long value[5]; }; struct ats m_ats = { …
2rdv1
  • 25
  • 4
2
votes
2 answers

How to create a folder within a folder in sysfs

I am trying to create a sysfs for an implementation of mine in android and stuck at creating a folder of my own in CLASS. My requirement: /sys/class/example_class/my_sysfs_directory/file_one. Code: #include
Madara
  • 163
  • 2
  • 11
2
votes
2 answers

Where is memory interleaving and memory split up into ranks happening in Linux kernel?

I am working on a course homework on sysfs virtual file system in Linux Kernel. As part of setting up sysfs virtual file system, Linux kernel organizes the physical memory in to blocks and further into sections in this directoy…
Srikanth Kandalam
  • 965
  • 3
  • 15
  • 26
2
votes
1 answer

What linux kernel code creates /sys/devices/system/cpu/cpuX?

I am developing a cpufreq driver (as a loadable kernel module) for the microblaze architecture. I have some FPGA logic that is able to scale the on-system clock and it works quite well. I have followed the information in…
jlamorie
  • 41
  • 5
2
votes
3 answers

Getting screen brightness in a Linux kernel module

I'm trying to get current screen brightness in my Linux kernel module. However, I don't know how can I access the brightness variable, though easily get it in an user-space application using the sysfs interface. Please let me know a clue about this…
Brian
  • 1,663
  • 5
  • 18
  • 26
1
vote
0 answers

How can I query/interrogate a USB device which is not listed in vfs /sys/class/hwmon*?

I have a Corsair HX1000i PSU, but looks like I can't quite get information for it in the vfs /sys/class/hwmon*; this is my output: ema@scv:~$ ls -la /sys/class/hwmon/ total 0 drwxr-xr-x 2 root root 0 Jan 21 20:22 . drwxr-xr-x 85 root root 0 Jan 21…
Emanuele
  • 1,408
  • 1
  • 15
  • 39
1
vote
1 answer

Why sysfs and procfs aren't displayed by df on Linux?

When I type df -Th I only get this : $ df -Th Filesystem Type Size Used Avail Use% Mounted on tmpfs tmpfs 987M 2.1M 984M 1% /run /dev/sda3 ext4 59G 34G 23G 60% / tmpfs tmpfs 4.9G 0 4.9G 0%…
Autechre
  • 171
  • 7
1
vote
1 answer

Why beaglebone gpio is not working with sysfs (kernel_version=5.10.153-bone69)

I am trying to use a gpio P9_23 (gpio 49) to light up an LED via sysfs and kernel module, and I used this link to bring up SD card https://forum.digikey.com/t/debian-getting-started-with-the-beaglebone-black/12967 kernel: am33x-v5.10 (Longterm…
mrigendra
  • 1,472
  • 3
  • 19
  • 33