Access to /var/lock or alternatives?


i am trying to build a snap based on deconz. It is build using Qt5 and is using Qtserialport.
QtSerialport creates a lock file for a connected interface in /var/lock, in a confined snap this fails. I tried to use Layouts to map /var/lock into $SNAP_DATA without success. Because /var/lock is already a symlink to /run/lock. So i tried to create a layout definition to /run/lock but this fails with “can not create a top level directory /run”.

Are there alternatives or to get access to /var/lock?

Currently running in devmode, but that is not a solution for production.


1 Like

You can use /run/lock/snap.$SNAP_INSTANCE_NAME instead

It doesn’t look like the QtSerialport code allows you to customise the lock file path like that:

It is creating the standard lock files like LCK..ttyS0.

@mapero: if it is an option for you, perhaps you could build your own copy of QtSerialport with the locking code disabled. Your lock files wouldn’t be visible to host system executables, so disabling the locking code entirely isn’t a big loss.


Yeah, that is what I am trying right now. It’s a pity that it does not work with layout :frowning:

1 Like

Id did not disable the locking code complete, but comment out everything except “/tmp”.