sd-device: introduce sd_device_open()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 30 Mar 2022 18:29:23 +0000 (03:29 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 1 Apr 2022 06:13:18 +0000 (15:13 +0900)
commitf9a726abefe1c25d952b36cd554e026e4c782967
tree0af9baedf3a534d81c062a3aaa8a24cdcb7254c2
parent7e93a65868394792e70b847ccb31288b569b3a68
sd-device: introduce sd_device_open()

We usually open() device node obtained by sd_device_get_devname().
However, the device node corresponds to the sd-device object may be
already removed, and another device node with the same path may be
created, hence an unexpected device may be opened.

The sd_device_open() opens device node, and checks the devnum and
diskseq of opened devnum, to avoid the above possibility.

Prompted by https://github.com/systemd/systemd/issues/22906#issuecomment-1082736443.
src/libsystemd/libsystemd.sym
src/libsystemd/sd-device/sd-device.c
src/systemd/sd-device.h