Can't write to a file from udev Run+=
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- bash, linux, raspberry-pi
- Domain
- embedded-iot, operating-systems
Research direction
Start with /etc/udev/rules.d/99-bt.rules and /home/pi/bt_disconnected, then compare syslog.txt with syslog_after.txt. Reproduce the Bluetooth disconnect before and after sudo /etc/init.d/udev restart, and inspect the reported udev exit code and boot messages. Done means the cause of the write failure is identified and a reproducible fix or documented resolution is provided.
Written by the indexing model from the issue text.
Description
Fresh install of 3/13/2018 stretch-lite on an rpi zero W. The only things that were done to the "stock" image:
headless config--added wpa_supplicant.conf and ssh file to /boot
raspi-config stuff
added /home/pi/.ssh directory (for ssh keys)
I have a udev rule that matches when a bluetooth device disconnects:
ACTION=="remove", KERNEL=="input[0-9]*", RUN+="/home/pi/bt_disconnected"
The script bt_disconnected runs when the device is disconnected, but fails if it tries to write to a file in /tmp or /home/pi. It fails, even if the rule is not added to /etc/udev/rules.d/99-bt.rules until after a fresh boot. File permissions are 777.
It seems the file system is readonly for udev after boot has finished.- At least directories /tmp and /home/pi--tried both those locations for the disconnects file). Yet, the logger command has no problem writing to /var/log/syslog.
Here's the script:
#!/bin/bash
logger "Disconnected"
#logger "$(whoami)"
echo "hello" >> "/tmp/disconnects"
The udev rule triggers, when I disconnect a connected bluetooth device from the device. The logger command works and reports the user is root, when the command is not commented. But, the last line fails without writing to the file and a message in /var/log/syslog reports it exited with return code 1:
Apr 7 20:32:29 Ipad2GMA root: Bluetooth Disconnected
Apr 7 20:32:29 Ipad2GMA systemd-udevd[690]: Process '/home/pi/bt_disconnected' failed with exit code 1.
If the following command is executed:
sudo /etc/init.d/udev restart
future bt disconnects trigger the udev rule and the bt_disconnected script writes to the /tmp/disconnects file without issue.
Using the command:
udevadm control --reload-rules
doesn't "fix" the issue. Just the udev restart.
Workaround is to restart udev in /etc/rc.local or in a daemon that runs late in the boot process.
Maybe related--this message occurs in /var/log/syslog, whether my rules are in udev or not:
Apr 7 20:32:21 Ipad2GMA systemd-udevd[685]: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Not sure if it's normal, but I see this in dmesg after booting (before adding the udev rules);
[ 1.448736] VFS: Mounted root (ext4 filesystem) readonly on device 179:2
Here's the syslog without the udev rules added:
And, with the 99-bt.rules file:
Note these records which only appear in /var/log/syslog when the 99-bt.rules file has the rule for triggering the script execution:
Apr 8 10:33:29 Ipad2GMA systemd[1]: Stopping Session c1 of user pi.
Apr 8 10:33:29 Ipad2GMA systemd[1]: Unmounting RPC Pipe File System...
Apr 8 10:33:29 Ipad2GMA systemd[449]: Stopped target Basic System.
But, based on the timestamps and the location of these records in the /var/syslog file, they were written at shutdown, not at the beginning of the reboot sequence.
- Dominant language
- C
- Stars
- 13.2k
- Forks
- 5.5k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 21
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from raspberrypi/linux
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
raspberrypi/linux#7415 · 2 comments · 1 reaction ·
-
rp1-cfe doesn't forward V4L2_EVENT_SOURCE_CHANGE event from csi-2 sensor driver to userspace app Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
raspberrypi/linux#7399 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
raspberrypi/linux#7357 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
raspberrypi/linux#7054 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
raspberrypi/linux#7634 · 8 comments · 1 reaction ·
All issues in raspberrypi/linux
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
[Bounty proposal] fix(web): memory insights count an evening memory on the next day ($25 proposed) Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
BasedHardware/omi#15320 ·
-
[adam] AdamNet network read doesn't cap to MAX_ADAM_PACKET_LEN, overflows client receive buffers Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
FujiNetWIFI/fujinet-firmware#1649 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
HarbourMasters/Shipwright#7229 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
riscv-software-src/riscv-isa-sim#2435 · 1 comment ·