After running make
command, there will be one module:
After loading the module, this will create two sysfs attributes in /sys/hello
:
# 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.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。