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

How to change a sysfs_create_file()'s permissions later?

I'm writing a module for the Linux kernel. This module is exposing some I/O as a file /sys/kernel/mymodule/foo: static struct kobj_attribute foo_attribute =__ATTR(foo, 0660, foo_show, foo_store); ... ret = sysfs_create_file(&mymodule->kobj,…
fadedbee
  • 42,671
  • 44
  • 178
  • 308
1
vote
2 answers

Writing a Sysfs module

I'm attempting to learn how to write a sysfs module, and am confused at the basic initialization. In this document looking at the kobject.h file, there are several different functions related to creating a sysfs entry. From the looks of it, the…
Zephyr
  • 337
  • 5
  • 23
1
vote
0 answers

how to write information to sysfs from kernel?

I am modifying and debugging the Linux Kernel about the schedule on multicore board. I need to check some information and I find the printk cost too much and the system can go wrong. So I try to send these information via sysfs. Then I can get this…
X.F
  • 43
  • 1
  • 4
1
vote
2 answers

Linux Kernel IIO events sysfs files only readable

I have the problem that I registered IIO events for rising and falling thresholds. I can see the sysfs files in events subfolder and can read them, but when I try to write a new threshold it says "permission denied". following setup: static const…
lobi
  • 58
  • 8
1
vote
0 answers

User Space sysfs

I want to be able to create, read and write attributes in sysfs from user space. I've tried this in a UIO driver (which supposedly runs in user space, so they say) but I came across the same issue with accessing sysfs from user space apps... no…
Bryan Wilcutt
  • 335
  • 2
  • 9
1
vote
1 answer

sysfs_create_group(): Where to call?

currently i write an driver module which offers some entries in the sysfs. I read a lot through the driver source tree and the internet. I found two approches where the sysfs_create_group() is called: a) most commonly: In the probe() function of the…
schorsch_76
  • 794
  • 5
  • 19
1
vote
1 answer

poll() not blocking, returns immediately

I'm trying to catch an interrupt on GPIO through sysfs using poll(). I have -1 in the third position so it can block, but it seems to be always returning. I've checked out some similar posts on SO. Notably this (1), this (2), and this (3). In (1),…
Stephan GM
  • 245
  • 3
  • 15
1
vote
3 answers

Should I keep sysfs file open for extended period of time?

On the device I'm working on, I can write to /sys/class/leds to turn a led light on/off. Can I keep the file open in my code and only close when the process exits, or should I only open the file when I need to write to it?
mr49
  • 1,053
  • 1
  • 8
  • 26
1
vote
1 answer

Qt 5 Write Linux SysFs Entry with QFile and QDataStream

I can echo 100 > /sys/class/soft_pwm/pwm-35/duty_cycle as root just fine from the command line but I cannot get my Qt 5 code to do the same when running as root. Below is the code - what am I doing wrong? Thanks. /** * Set the PWM on the Red /…
PhilBot
  • 748
  • 18
  • 85
  • 173
1
vote
1 answer

if there is no sysfs in /etc/fstab, how sysfs is mounted?

If I type $mount on shell, it shows several mount point proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) sys on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) dev on /dev type devtmpfs…
user3444572
  • 61
  • 2
  • 9
1
vote
2 answers

Linux kernel: How to get dev_t of whole disk from partitioned disk?

I want to retrieve the dev_t structure for a whole disk, given that of a partition on the disk. This is for for a blkext driver, like nvme. Something like: dev_t part_disk; dev_t whole_disk = get_whole_disk_dev_t(part_disk); I would like my the…
1
vote
2 answers

Which filesystem to use to expose readings/limits for temperature sensor

I currently have the trouble of some hardware overheating regularly. Looking through the Linux kernel, I found that the thermal sensors are currently fully supported, however the preconfigured limits seem much too high. I am currently looking to…
LiKao
  • 10,408
  • 6
  • 53
  • 91
1
vote
0 answers

Reading a sysfs GPIO input pin (direction as "in") always print a fixed value (0)

After enabling the GPIO device support in kernel device driver (Kernel verion 3.10.92) I wanted to read the value of an input pin of my GPIO expander through GPIO sysfs. After exporting and setting the direction as in, on reading, the value is…
M P Singh
  • 11
  • 3
1
vote
0 answers

Module parameters

I have two modules, let me call them module_A and module_B. Module_A has a public parameter declared as static unsigned int my_param = 0; #define PERMISSION_MASK 0777 module_param(my_param, uint, PERMISSION_MASK); I'm looking for a solution to…
mcfan
  • 159
  • 3
1
vote
0 answers

How to recive the device path from uDevice event informations?

I have written so far a Qt-Application that is able to detect through the socket communication with the uDevice daemon(?) when I add or remove a usb device. But the related informations I'm recieving aren't that usefull for me(at least not from the…
dhein
  • 6,431
  • 4
  • 42
  • 74