diff options
Diffstat (limited to 'src/udev/udev-watch.c')
-rw-r--r-- | src/udev/udev-watch.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c index 15b76dd6ab..9ce5e975de 100644 --- a/src/udev/udev-watch.c +++ b/src/udev/udev-watch.c @@ -17,13 +17,14 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <errno.h> -#include <stdio.h> #include <dirent.h> +#include <errno.h> #include <stddef.h> -#include <unistd.h> +#include <stdio.h> #include <sys/inotify.h> +#include <unistd.h> +#include "stdio-util.h" #include "udev.h" static int inotify_fd = -1; @@ -83,9 +84,8 @@ unlink: closedir(dir); rmdir("/run/udev/watch.old"); - } else if (errno != ENOENT) { + } else if (errno != ENOENT) log_error_errno(errno, "unable to move watches dir /run/udev/watch; old watches will not be restored: %m"); - } } void udev_watch_begin(struct udev *udev, struct udev_device *dev) { @@ -100,11 +100,11 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev) { wd = inotify_add_watch(inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE); if (wd < 0) { log_error_errno(errno, "inotify_add_watch(%d, %s, %o) failed: %m", - inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE); + inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE); return; } - snprintf(filename, sizeof(filename), "/run/udev/watch/%d", wd); + xsprintf(filename, "/run/udev/watch/%d", wd); mkdir_parents(filename, 0755); unlink(filename); r = symlink(udev_device_get_id_filename(dev), filename); @@ -128,7 +128,7 @@ void udev_watch_end(struct udev *udev, struct udev_device *dev) { log_debug("removing watch on '%s'", udev_device_get_devnode(dev)); inotify_rm_watch(inotify_fd, wd); - snprintf(filename, sizeof(filename), "/run/udev/watch/%d", wd); + xsprintf(filename, "/run/udev/watch/%d", wd); unlink(filename); udev_device_set_watch_handle(dev, -1); @@ -142,7 +142,7 @@ struct udev_device *udev_watch_lookup(struct udev *udev, int wd) { if (inotify_fd < 0 || wd < 0) return NULL; - snprintf(filename, sizeof(filename), "/run/udev/watch/%d", wd); + xsprintf(filename, "/run/udev/watch/%d", wd); len = readlink(filename, device, sizeof(device)); if (len <= 0 || (size_t)len == sizeof(device)) return NULL; |