diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-10-22 06:21:16 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-10-23 15:44:07 +0200 |
commit | 4d04259d4114bc73696f269f0d5dc2d5b50f666a (patch) | |
tree | 989d40ec4946fbb0cfb51e410ef962694f9beacb /src/udev/udev-watch.c | |
parent | udev-node: use log_device_*() (diff) | |
download | systemd-4d04259d4114bc73696f269f0d5dc2d5b50f666a.tar.xz systemd-4d04259d4114bc73696f269f0d5dc2d5b50f666a.zip |
udev-watch: use log_device_*()
Diffstat (limited to 'src/udev/udev-watch.c')
-rw-r--r-- | src/udev/udev-watch.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c index 3f5885c52e..4924b75c50 100644 --- a/src/udev/udev-watch.c +++ b/src/udev/udev-watch.c @@ -9,6 +9,7 @@ #include "alloc-util.h" #include "device-private.h" +#include "device-util.h" #include "dirent-util.h" #include "fs-util.h" #include "mkdir.h" @@ -67,12 +68,7 @@ int udev_watch_restore(void) { goto unlink; } - if (DEBUG_LOGGING) { - const char *devnode = NULL; - - (void) sd_device_get_devname(dev, &devnode); - log_debug("Restoring old watch on '%s'", strnull(devnode)); - } + log_device_debug(dev, "Restoring old watch"); (void) udev_watch_begin(dev); unlink: (void) unlinkat(dirfd(dir), ent->d_name, 0); @@ -94,49 +90,45 @@ int udev_watch_begin(sd_device *dev) { r = sd_device_get_devname(dev, &devnode); if (r < 0) - return log_error_errno(r, "Failed to get device name: %m"); + return log_device_error_errno(dev, r, "Failed to get device name: %m"); - log_debug("Adding watch on '%s'", devnode); + log_device_debug(dev, "Adding watch on '%s'", devnode); wd = inotify_add_watch(inotify_fd, devnode, IN_CLOSE_WRITE); if (wd < 0) - return log_error_errno(errno, "Failed to add device '%s' to watch: %m", devnode); + return log_device_error_errno(dev, errno, "Failed to add device '%s' to watch: %m", devnode); device_set_watch_handle(dev, wd); xsprintf(filename, "/run/udev/watch/%d", wd); r = mkdir_parents(filename, 0755); if (r < 0) - return log_error_errno(r, "Failed to create parent directory of '%s': %m", filename); + return log_device_error_errno(dev, r, "Failed to create parent directory of '%s': %m", filename); (void) unlink(filename); r = device_get_id_filename(dev, &id_filename); if (r < 0) - return log_error_errno(r, "Failed to get device id-filename: %m"); + return log_device_error_errno(dev, r, "Failed to get device id-filename: %m"); if (symlink(id_filename, filename) < 0) - return log_error_errno(errno, "Failed to create symlink %s: %m", filename); + return log_device_error_errno(dev, errno, "Failed to create symlink %s: %m", filename); return 0; } int udev_watch_end(sd_device *dev) { char filename[STRLEN("/run/udev/watch/") + DECIMAL_STR_MAX(int)]; - const char *name = NULL; int wd, r; if (inotify_fd < 0) return log_error_errno(EINVAL, "Invalid inotify descriptor."); - if (sd_device_get_devname(dev, &name) < 0) - (void) sd_device_get_syspath(dev, &name); - r = device_get_watch_handle(dev, &wd); if (r == -ENOENT) return 0; if (r < 0) - return log_error_errno(r, "Failed to get watch handle for device '%s', ignoring: %m", strnull(name)); + return log_device_error_errno(dev, r, "Failed to get watch handle, ignoring: %m"); - log_debug("Removing watch on '%s'", strnull(name)); + log_device_debug(dev, "Removing watch"); (void) inotify_rm_watch(inotify_fd, wd); xsprintf(filename, "/run/udev/watch/%d", wd); |