diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-04-14 23:38:33 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-11 18:36:06 +0200 |
commit | 3fb94c70621d73f656e02c016400075175b8b0bf (patch) | |
tree | 992567d9eb2164b93a57237149375fea1654cd42 /src/udev/udev-watch.c | |
parent | udev: warn on udev_watch_{begin,end}() failure (diff) | |
download | systemd-3fb94c70621d73f656e02c016400075175b8b0bf.tar.xz systemd-3fb94c70621d73f656e02c016400075175b8b0bf.zip |
sd-device: move device_new_from_watch_handle_at() to udev-watch.c
And drop unused watch handle related functions.
Diffstat (limited to 'src/udev/udev-watch.c')
-rw-r--r-- | src/udev/udev-watch.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c index 0cc83ddb9c..2a9ff2909b 100644 --- a/src/udev/udev-watch.c +++ b/src/udev/udev-watch.c @@ -19,6 +19,29 @@ #include "string-util.h" #include "udev-watch.h" +int device_new_from_watch_handle_at(sd_device **ret, int dirfd, int wd) { + char path_wd[STRLEN("/run/udev/watch/") + DECIMAL_STR_MAX(int)]; + _cleanup_free_ char *id = NULL; + int r; + + assert(ret); + + if (wd < 0) + return -EBADF; + + if (dirfd >= 0) { + xsprintf(path_wd, "%d", wd); + r = readlinkat_malloc(dirfd, path_wd, &id); + } else { + xsprintf(path_wd, "/run/udev/watch/%d", wd); + r = readlink_malloc(path_wd, &id); + } + if (r < 0) + return r; + + return sd_device_new_from_device_id(ret, id); +} + int udev_watch_restore(int inotify_fd) { _cleanup_closedir_ DIR *dir = NULL; int r; |