Details of serial port locking / UUCP locking
kaechele opened this issue · 2 comments
Currently, as far as I can tell, gensio only implements its own UUCP-style locking mechanism.
It seems that at least on Linux there are other (and possibly better) ways of locking serial ports.
There was an effort within Debian in 2014 to streamline this: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=734086
From this discussion one of the participants developed some recommendations for best practices around this issue: https://stackoverflow.com/questions/30316722/what-is-the-best-practice-for-locking-serial-ports-and-other-devices-in-linux
- Would it be beneficial for gensio to support
flock(1)
based locking of serial ports on Linux, given that the information above suggests it could be more robust? - Would using
liblockdev
be beneficial on distributions that utilize it more or less consistently (like Fedora)?
It is my understanding, that when using flock(1)
UUCP-style locking (with or without liblockdev
) can still occur to support programs that use or require it as it does not interfere with programs that ignore it.
Less relevant context on why I bring this up
ser2net
recently started shipping a systemd unit file.
In this unit file there is a definition of a User
and a Group
. In trying to incorporate this in my Fedora package I noticed that ser2net would not be able to write to /var/lock
, gensio's default UUCP lock path, unless ser2net was run as root. So I looked into the issue further and found that most other software in Fedora uses lockdev
(and liblockdev
) to facilitate UUCP-style locking and the path to use for that would be /run/lock/lockdev
, which is group writeable by users in the lock
group.
So I fixed the issue as suggested in the gensio README: by creating a ser2net
user and adding it to both the dialout
and lock
groups and compiling gensio with the --with-uucp-locking=/run/lock/lockdev
option.
SVr4 and flock locking is now added. Thanks again.