1 Star 2 Fork 2

e665107/Linux-Device-Drivers-Development

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
Chapter02
Chapter03
Chapter04
Chapter05
Chapter07
Chapter10
Chapter11
Chapter12
Chapter13/sysfs-poll
Makefile
README.md
sysfs-poll-user.c
sysfs-poll.c
sysfs-select-user.c
Chapter14
Chapter15
Chapter17
Chapter18
Chapter19
Chapter20
Chapter22
LICENSE
README.md
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Pollable sysfs attributes

After running make command, there will be one module:

  • sysfs-poll.ko

After loading the module, this will create two sysfs attributes in /sys/hello:

  • /sys/hello/trigger
  • /sys/hello/notify
# insmod ./sysfs-poll.ko

# ls -l /sys/hello/
total 0
-rw-r--r-- 1 root root 4096 oct.  13 11:54 notify
-rw-r--r-- 1 root root 4096 oct.  13 11:54 trigger

For testing, one can build either compile either the file sysfs-select-user.c or sysfs-poll-user.c.

$ gcc sysfs-select-user.c -o sysfs-select

Now one should execute sysfs-select binary as sudo:

# sudo ./sysfs-select 

Open another console, and then write anything into either /sys/hello/trigger or /sys/hello/notify.

# echo "john" > /sys/hello/trigger

The app wainting will then print something like:

# sudo ./sysfs-select 
Change detected in /sys/hello/trigger

Same for writing in /sys/hello/notify (in console 1):

# echo "john" > /sys/hello/notify

which will produce below output (in console 2):

# ./sysfs-select 
Change detected in /sys/hello/notify

Additionally, one can use dmesg command for debug messages.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/e665107/Linux-Device-Drivers-Development.git
git@gitee.com:e665107/Linux-Device-Drivers-Development.git
e665107
Linux-Device-Drivers-Development
Linux-Device-Drivers-Development
master

搜索帮助