summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ata_id/ata_id.c2
-rw-r--r--src/libudev/libudev-device-private.c2
-rw-r--r--src/libudev/libudev-device.c2
-rw-r--r--src/libudev/libudev-hwdb.c4
-rw-r--r--src/libudev/libudev-monitor.c8
-rw-r--r--src/scsi_id/scsi_id.c2
-rw-r--r--src/scsi_id/scsi_serial.c6
-rw-r--r--src/shared/smack-util.c2
-rw-r--r--src/shared/util.c4
-rw-r--r--src/udev/udev-builtin-keyboard.c4
-rw-r--r--src/udev/udev-ctrl.c16
-rw-r--r--src/udev/udev-event.c24
-rw-r--r--src/udev/udev-node.c10
-rw-r--r--src/udev/udev-rules.c6
-rw-r--r--src/udev/udev-watch.c10
-rw-r--r--src/udev/udevadm-monitor.c6
-rw-r--r--src/udev/udevadm-trigger.c2
-rw-r--r--src/udev/udevd.c24
18 files changed, 67 insertions, 67 deletions
diff --git a/src/ata_id/ata_id.c b/src/ata_id/ata_id.c
index 46a65fb477..626547725a 100644
--- a/src/ata_id/ata_id.c
+++ b/src/ata_id/ata_id.c
@@ -497,7 +497,7 @@ int main(int argc, char *argv[])
} else {
/* If this fails, then try HDIO_GET_IDENTITY */
if (ioctl(fd, HDIO_GET_IDENTITY, &id) != 0) {
- log_debug("HDIO_GET_IDENTITY failed for '%s': %m", node);
+ log_debug_errno(errno, "HDIO_GET_IDENTITY failed for '%s': %m", node);
rc = 2;
goto close;
}
diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c
index aa3b2270e0..be3f17fd47 100644
--- a/src/libudev/libudev-device-private.c
+++ b/src/libudev/libudev-device-private.c
@@ -129,7 +129,7 @@ int udev_device_update_db(struct udev_device *udev_device)
mkdir_parents(filename_tmp, 0755);
f = fopen(filename_tmp, "we");
if (f == NULL) {
- log_debug("unable to create temporary db file '%s': %m", filename_tmp);
+ log_debug_errno(errno, "unable to create temporary db file '%s': %m", filename_tmp);
return -errno;
}
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index fc7d928721..400fb74d83 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -535,7 +535,7 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile)
f = fopen(dbfile, "re");
if (f == NULL) {
- log_debug("no db file to read %s: %m", dbfile);
+ log_debug_errno(errno, "no db file to read %s: %m", dbfile);
return -errno;
}
diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c
index 09e7c337b4..d457604a07 100644
--- a/src/libudev/libudev-hwdb.c
+++ b/src/libudev/libudev-hwdb.c
@@ -284,14 +284,14 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
if (fstat(fileno(hwdb->f), &hwdb->st) < 0 ||
(size_t)hwdb->st.st_size < offsetof(struct trie_header_f, strings_len) + 8) {
- log_debug("error reading " UDEV_HWDB_BIN ": %m");
+ log_debug_errno(errno, "error reading " UDEV_HWDB_BIN ": %m");
udev_hwdb_unref(hwdb);
return NULL;
}
hwdb->map = mmap(0, hwdb->st.st_size, PROT_READ, MAP_SHARED, fileno(hwdb->f), 0);
if (hwdb->map == MAP_FAILED) {
- log_debug("error mapping " UDEV_HWDB_BIN ": %m");
+ log_debug_errno(errno, "error mapping " UDEV_HWDB_BIN ": %m");
udev_hwdb_unref(hwdb);
return NULL;
}
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index 6335fcc6cc..efdabf0c3c 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -121,7 +121,7 @@ static bool udev_has_devtmpfs(struct udev *udev) {
r = name_to_handle_at(AT_FDCWD, "/dev", &h.handle, &mount_id, 0);
if (r < 0) {
if (errno != EOPNOTSUPP)
- log_debug("name_to_handle_at on /dev: %m");
+ log_debug_errno(errno, "name_to_handle_at on /dev: %m");
return false;
}
@@ -190,7 +190,7 @@ struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const c
if (fd < 0) {
udev_monitor->sock = socket(PF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_KOBJECT_UEVENT);
if (udev_monitor->sock == -1) {
- log_debug("error getting socket: %m");
+ log_debug_errno(errno, "error getting socket: %m");
free(udev_monitor);
return NULL;
}
@@ -407,14 +407,14 @@ _public_ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor)
if (err == 0)
udev_monitor->snl.nl.nl_pid = snl.nl.nl_pid;
} else {
- log_debug("bind failed: %m");
+ log_debug_errno(errno, "bind failed: %m");
return -errno;
}
/* enable receiving of sender credentials */
err = setsockopt(udev_monitor->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
if (err < 0)
- log_debug("setting SO_PASSCRED failed: %m");
+ log_debug_errno(errno, "setting SO_PASSCRED failed: %m");
return 0;
}
diff --git a/src/scsi_id/scsi_id.c b/src/scsi_id/scsi_id.c
index befe3542ba..762e70bc56 100644
--- a/src/scsi_id/scsi_id.c
+++ b/src/scsi_id/scsi_id.c
@@ -178,7 +178,7 @@ static int get_file_options(struct udev *udev,
if (errno == ENOENT)
return 1;
else {
- log_error("can't open %s: %m", config_file);
+ log_error_errno(errno, "can't open %s: %m", config_file);
return -1;
}
}
diff --git a/src/scsi_id/scsi_serial.c b/src/scsi_id/scsi_serial.c
index 3e30aed419..37081adc1f 100644
--- a/src/scsi_id/scsi_serial.c
+++ b/src/scsi_id/scsi_serial.c
@@ -365,7 +365,7 @@ resend:
dev_scsi->use_sg = 3;
goto resend;
}
- log_debug("%s: ioctl failed: %m", dev_scsi->kernel);
+ log_debug_errno(errno, "%s: ioctl failed: %m", dev_scsi->kernel);
goto error;
}
@@ -823,12 +823,12 @@ int scsi_std_inquiry(struct udev *udev,
fd = open(devname, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
if (fd < 0) {
- log_debug("scsi_id: cannot open %s: %m", devname);
+ log_debug_errno(errno, "scsi_id: cannot open %s: %m", devname);
return 1;
}
if (fstat(fd, &statbuf) < 0) {
- log_debug("scsi_id: cannot stat %s: %m", devname);
+ log_debug_errno(errno, "scsi_id: cannot stat %s: %m", devname);
err = 2;
goto out;
}
diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c
index 992a2e3372..c8f052cec9 100644
--- a/src/shared/smack-util.c
+++ b/src/shared/smack-util.c
@@ -194,7 +194,7 @@ int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
if (ignore_erofs && errno == EROFS)
return 0;
- log_debug("Unable to fix SMACK label of %s: %m", path);
+ log_debug_errno(errno, "Unable to fix SMACK label of %s: %m", path);
r = -errno;
}
#endif
diff --git a/src/shared/util.c b/src/shared/util.c
index 85f2957a53..ebf654a43e 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1603,7 +1603,7 @@ int execute_command(const char *command, char *const argv[]) {
return status;
if ((pid = fork()) < 0) {
- log_error("Failed to fork: %m");
+ log_error_errno(errno, "Failed to fork: %m");
return pid;
}
@@ -1611,7 +1611,7 @@ int execute_command(const char *command, char *const argv[]) {
execvp(command, argv);
- log_error("Failed to execute %s: %m", command);
+ log_error_errno(errno, "Failed to execute %s: %m", command);
_exit(EXIT_FAILURE);
}
else while (1)
diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c
index 2deb8b9fbb..273b27ddcb 100644
--- a/src/udev/udev-builtin-keyboard.c
+++ b/src/udev/udev-builtin-keyboard.c
@@ -140,7 +140,7 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
fd = open(udev_device_get_devnode(dev), O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (fd < 0) {
- log_error("Error, opening device '%s': %m", node);
+ log_error_errno(errno, "Error, opening device '%s': %m", node);
return EXIT_FAILURE;
}
@@ -149,7 +149,7 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
log_debug("keyboard: mapping scan code %d (0x%x) to key code %d (0x%x)",
map[i].scan, map[i].scan, map[i].key, map[i].key);
if (ioctl(fd, EVIOCSKEYCODE, &map[i]) < 0)
- log_error("Error calling EVIOCSKEYCODE on device node '%s' (scan code 0x%x, key code %d): %m", node, map[i].scan, map[i].key);
+ log_error_errno(errno, "Error calling EVIOCSKEYCODE on device node '%s' (scan code 0x%x, key code %d): %m", node, map[i].scan, map[i].key);
}
/* install list of force-release codes */
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 8581732821..898ef54514 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -85,7 +85,7 @@ struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) {
if (fd < 0) {
uctrl->sock = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
if (uctrl->sock < 0) {
- log_error("error getting socket: %m");
+ log_error_errno(errno, "error getting socket: %m");
udev_ctrl_unref(uctrl);
return NULL;
}
@@ -95,7 +95,7 @@ struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) {
}
r = setsockopt(uctrl->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
if (r < 0)
- log_warning("could not set SO_PASSCRED: %m");
+ log_warning_errno(errno, "could not set SO_PASSCRED: %m");
uctrl->saddr.sun_family = AF_LOCAL;
strscpy(uctrl->saddr.sun_path, sizeof(uctrl->saddr.sun_path), "/run/udev/control");
@@ -119,14 +119,14 @@ int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl) {
if (err < 0) {
err = -errno;
- log_error("bind failed: %m");
+ log_error_errno(errno, "bind failed: %m");
return err;
}
err = listen(uctrl->sock, 0);
if (err < 0) {
err = -errno;
- log_error("listen failed: %m");
+ log_error_errno(errno, "listen failed: %m");
return err;
}
@@ -209,7 +209,7 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
if (conn->sock < 0) {
if (errno != EINTR)
- log_error("unable to receive ctrl connection: %m");
+ log_error_errno(errno, "unable to receive ctrl connection: %m");
goto err;
}
@@ -227,7 +227,7 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
/* enable receiving of the sender credentials in the messages */
r = setsockopt(conn->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
if (r < 0)
- log_warning("could not set SO_PASSCRED: %m");
+ log_warning_errno(errno, "could not set SO_PASSCRED: %m");
udev_ctrl_ref(uctrl);
return conn;
@@ -383,7 +383,7 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) {
goto err;
} else {
if (!(pfd[0].revents & POLLIN)) {
- log_error("ctrl connection error: %m");
+ log_error_errno(errno, "ctrl connection error: %m");
goto err;
}
}
@@ -396,7 +396,7 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) {
size = recvmsg(conn->sock, &smsg, 0);
if (size < 0) {
- log_error("unable to receive ctrl message: %m");
+ log_error_errno(errno, "unable to receive ctrl message: %m");
goto err;
}
cmsg = CMSG_FIRSTHDR(&smsg);
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index afcf262ebb..5c1352b1b9 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -388,7 +388,7 @@ static int spawn_exec(struct udev_event *event,
if (fd_stderr < 0)
dup2(fd, STDERR_FILENO);
} else
- log_error("open /dev/null failed: %m");
+ log_error_errno(errno, "open /dev/null failed: %m");
/* connect pipes to std{out,err} */
if (fd_stdout >= 0) {
@@ -410,7 +410,7 @@ static int spawn_exec(struct udev_event *event,
execve(argv[0], argv, envp);
/* exec failed */
- log_error("failed to execute '%s' '%s': %m", argv[0], cmd);
+ log_error_errno(errno, "failed to execute '%s' '%s': %m", argv[0], cmd);
return -errno;
}
@@ -438,14 +438,14 @@ static void spawn_read(struct udev_event *event,
fd_ep = epoll_create1(EPOLL_CLOEXEC);
if (fd_ep < 0) {
- log_error("error creating epoll fd: %m");
+ log_error_errno(errno, "error creating epoll fd: %m");
return;
}
if (fd_stdout >= 0) {
r = epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_stdout, &ep_outpipe);
if (r < 0) {
- log_error("fail to add stdout fd to epoll: %m");
+ log_error_errno(errno, "fail to add stdout fd to epoll: %m");
return;
}
}
@@ -453,7 +453,7 @@ static void spawn_read(struct udev_event *event,
if (fd_stderr >= 0) {
r = epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_stderr, &ep_errpipe);
if (r < 0) {
- log_error("fail to add stderr fd to epoll: %m");
+ log_error_errno(errno, "fail to add stderr fd to epoll: %m");
return;
}
}
@@ -482,7 +482,7 @@ static void spawn_read(struct udev_event *event,
if (fdcount < 0) {
if (errno == EINTR)
continue;
- log_error("failed to poll: %m");
+ log_error_errno(errno, "failed to poll: %m");
return;
} else if (fdcount == 0) {
log_error("timeout '%s'", cmd);
@@ -528,7 +528,7 @@ static void spawn_read(struct udev_event *event,
} else if (ev[i].events & EPOLLHUP) {
r = epoll_ctl(fd_ep, EPOLL_CTL_DEL, *fd, NULL);
if (r < 0) {
- log_error("failed to remove fd from epoll: %m");
+ log_error_errno(errno, "failed to remove fd from epoll: %m");
return;
}
*fd = -1;
@@ -577,7 +577,7 @@ static int spawn_wait(struct udev_event *event,
if (errno == EINTR)
continue;
err = -errno;
- log_error("failed to poll: %m");
+ log_error_errno(errno, "failed to poll: %m");
goto out;
}
if (fdcount == 0) {
@@ -588,7 +588,7 @@ static int spawn_wait(struct udev_event *event,
if (errno == EINTR)
continue;
err = -errno;
- log_error("failed to poll: %m");
+ log_error_errno(errno, "failed to poll: %m");
goto out;
}
if (fdcount == 0) {
@@ -692,14 +692,14 @@ int udev_event_spawn(struct udev_event *event,
if (result != NULL || log_get_max_level() >= LOG_INFO) {
if (pipe2(outpipe, O_NONBLOCK) != 0) {
err = -errno;
- log_error("pipe failed: %m");
+ log_error_errno(errno, "pipe failed: %m");
goto out;
}
}
if (log_get_max_level() >= LOG_INFO) {
if (pipe2(errpipe, O_NONBLOCK) != 0) {
err = -errno;
- log_error("pipe failed: %m");
+ log_error_errno(errno, "pipe failed: %m");
goto out;
}
}
@@ -736,7 +736,7 @@ int udev_event_spawn(struct udev_event *event,
_exit(2 );
case -1:
- log_error("fork of '%s' failed: %m", cmd);
+ log_error_errno(errno, "fork of '%s' failed: %m", cmd);
err = -1;
goto out;
default:
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index c9a273d003..c30a428ea1 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -112,12 +112,12 @@ static int node_symlink(struct udev_device *dev, const char *node, const char *s
mac_selinux_create_file_clear();
} while (err == -ENOENT);
if (err != 0) {
- log_error("symlink '%s' '%s' failed: %m", target, slink_tmp);
+ log_error_errno(errno, "symlink '%s' '%s' failed: %m", target, slink_tmp);
goto exit;
}
err = rename(slink_tmp, slink);
if (err != 0) {
- log_error("rename '%s' '%s' failed: %m", slink_tmp, slink);
+ log_error_errno(errno, "rename '%s' '%s' failed: %m", slink_tmp, slink);
unlink(slink_tmp);
}
exit:
@@ -264,7 +264,7 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
if (lstat(devnode, &stats) != 0) {
err = -errno;
- log_debug("can not stat() node '%s' (%m)", devnode);
+ log_debug_errno(errno, "can not stat() node '%s' (%m)", devnode);
goto out;
}
@@ -283,10 +283,10 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
log_debug("set permissions %s, %#o, uid=%u, gid=%u", devnode, mode, uid, gid);
err = chmod(devnode, mode);
if (err < 0)
- log_warning("setting mode of %s to %#o failed: %m", devnode, mode);
+ log_warning_errno(errno, "setting mode of %s to %#o failed: %m", devnode, mode);
err = chown(devnode, uid, gid);
if (err < 0)
- log_warning("setting owner of %s to uid=%u, gid=%u failed: %m", devnode, uid, gid);
+ log_warning_errno(errno, "setting owner of %s to uid=%u, gid=%u failed: %m", devnode, uid, gid);
} else {
log_debug("preserve permissions %s, %#o, uid=%u, gid=%u", devnode, mode, uid, gid);
}
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 7816d9dc7b..5e901598f5 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -2593,10 +2593,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules,
f = fopen(attr, "we");
if (f != NULL) {
if (fprintf(f, "%s", value) <= 0)
- log_error("error writing ATTR{%s}: %m", attr);
+ log_error_errno(errno, "error writing ATTR{%s}: %m", attr);
fclose(f);
} else {
- log_error("error opening ATTR{%s} for writing: %m", attr);
+ log_error_errno(errno, "error opening ATTR{%s} for writing: %m", attr);
}
break;
}
@@ -2720,7 +2720,7 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
strscpyl(tag_symlink, sizeof(tag_symlink), tags_dir, unescaped_filename, NULL);
r = symlink(device_node, tag_symlink);
if (r < 0 && errno != EEXIST) {
- log_error("failed to create symlink %s -> %s: %m", tag_symlink, device_node);
+ log_error_errno(errno, "failed to create symlink %s -> %s: %m", tag_symlink, device_node);
return -errno;
} else
r = 0;
diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c
index 061bd05875..6ba8674d77 100644
--- a/src/udev/udev-watch.c
+++ b/src/udev/udev-watch.c
@@ -39,7 +39,7 @@ static int inotify_fd = -1;
int udev_watch_init(struct udev *udev) {
inotify_fd = inotify_init1(IN_CLOEXEC);
if (inotify_fd < 0)
- log_error("inotify_init failed: %m");
+ log_error_errno(errno, "inotify_init failed: %m");
return inotify_fd;
}
@@ -56,7 +56,7 @@ void udev_watch_restore(struct udev *udev) {
dir = opendir("/run/udev/watch.old");
if (dir == NULL) {
- log_error("unable to open old watches dir /run/udev/watch.old; old watches will not be restored: %m");
+ log_error_errno(errno, "unable to open old watches dir /run/udev/watch.old; old watches will not be restored: %m");
return;
}
@@ -88,7 +88,7 @@ unlink:
rmdir("/run/udev/watch.old");
} else if (errno != ENOENT) {
- log_error("unable to move watches dir /run/udev/watch; old watches will not be restored: %m");
+ log_error_errno(errno, "unable to move watches dir /run/udev/watch; old watches will not be restored: %m");
}
}
@@ -103,7 +103,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev) {
log_debug("adding watch on '%s'", udev_device_get_devnode(dev));
wd = inotify_add_watch(inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE);
if (wd < 0) {
- log_error("inotify_add_watch(%d, %s, %o) failed: %m",
+ log_error_errno(errno, "inotify_add_watch(%d, %s, %o) failed: %m",
inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE);
return;
}
@@ -113,7 +113,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev) {
unlink(filename);
r = symlink(udev_device_get_id_filename(dev), filename);
if (r < 0)
- log_error("Failed to create symlink %s: %m", filename);
+ log_error_errno(errno, "Failed to create symlink %s: %m", filename);
udev_device_set_watch_handle(dev, wd);
}
diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
index e776fb99dc..1a5f516ddc 100644
--- a/src/udev/udevadm-monitor.c
+++ b/src/udev/udevadm-monitor.c
@@ -155,7 +155,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) {
fd_ep = epoll_create1(EPOLL_CLOEXEC);
if (fd_ep < 0) {
- log_error("error creating epoll fd: %m");
+ log_error_errno(errno, "error creating epoll fd: %m");
return 1;
}
@@ -195,7 +195,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) {
ep_udev.events = EPOLLIN;
ep_udev.data.fd = fd_udev;
if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_udev, &ep_udev) < 0) {
- log_error("fail to add fd to epoll: %m");
+ log_error_errno(errno, "fail to add fd to epoll: %m");
return 2;
}
@@ -229,7 +229,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) {
ep_kernel.events = EPOLLIN;
ep_kernel.data.fd = fd_kernel;
if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_kernel, &ep_kernel) < 0) {
- log_error("fail to add fd to epoll: %m");
+ log_error_errno(errno, "fail to add fd to epoll: %m");
return 5;
}
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index e8a0c2fef6..4308466b84 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -54,7 +54,7 @@ static void exec_list(struct udev_enumerate *udev_enumerate, const char *action)
if (fd < 0)
continue;
if (write(fd, action, strlen(action)) < 0)
- log_debug("error writing '%s' to '%s': %m", action, filename);
+ log_debug_errno(errno, "error writing '%s' to '%s': %m", action, filename);
close(fd);
}
}
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index f2898d0dfa..75efa67d22 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -218,14 +218,14 @@ static void worker_new(struct event *event) {
sigfillset(&mask);
fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
if (fd_signal < 0) {
- log_error("error creating signalfd %m");
+ log_error_errno(errno, "error creating signalfd %m");
rc = 2;
goto out;
}
fd_ep = epoll_create1(EPOLL_CLOEXEC);
if (fd_ep < 0) {
- log_error("error creating epoll fd: %m");
+ log_error_errno(errno, "error creating epoll fd: %m");
rc = 3;
goto out;
}
@@ -241,7 +241,7 @@ static void worker_new(struct event *event) {
if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 ||
epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_monitor, &ep_monitor) < 0) {
- log_error("fail to add fds to epoll: %m");
+ log_error_errno(errno, "fail to add fds to epoll: %m");
rc = 4;
goto out;
}
@@ -291,7 +291,7 @@ static void worker_new(struct event *event) {
if (d) {
fd_lock = open(udev_device_get_devnode(d), O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
if (fd_lock >= 0 && flock(fd_lock, LOCK_SH|LOCK_NB) < 0) {
- log_debug("Unable to flock(%s), skipping event handling: %m", udev_device_get_devnode(d));
+ log_debug_errno(errno, "Unable to flock(%s), skipping event handling: %m", udev_device_get_devnode(d));
err = -EWOULDBLOCK;
fd_lock = safe_close(fd_lock);
goto skip;
@@ -350,7 +350,7 @@ skip:
if (fdcount < 0) {
if (errno == EINTR)
continue;
- log_error("failed to poll: %m");
+ log_error_errno(errno, "failed to poll: %m");
goto out;
}
@@ -390,7 +390,7 @@ out:
udev_monitor_unref(worker_monitor);
event->state = EVENT_QUEUED;
free(worker);
- log_error("fork of child failed: %m");
+ log_error_errno(errno, "fork of child failed: %m");
break;
default:
/* close monitor, but keep address around */
@@ -421,7 +421,7 @@ static void event_run(struct event *event) {
count = udev_monitor_send_device(monitor, worker->monitor, event->dev);
if (count < 0) {
- log_error("worker [%u] did not accept message %zi (%m), kill it", worker->pid, count);
+ log_error_errno(errno, "worker [%u] did not accept message %zi (%m), kill it", worker->pid, count);
kill(worker->pid, SIGKILL);
worker->state = WORKER_KILLED;
continue;
@@ -1168,7 +1168,7 @@ int main(int argc, char *argv[]) {
/* set umask before creating any file/directory */
r = chdir("/");
if (r < 0) {
- log_error("could not change dir to /: %m");
+ log_error_errno(errno, "could not change dir to /: %m");
goto exit;
}
@@ -1178,7 +1178,7 @@ int main(int argc, char *argv[]) {
r = mkdir("/run/udev", 0755);
if (r < 0 && errno != EEXIST) {
- log_error("could not create /run/udev: %m");
+ log_error_errno(errno, "could not create /run/udev: %m");
goto exit;
}
@@ -1255,7 +1255,7 @@ int main(int argc, char *argv[]) {
case 0:
break;
case -1:
- log_error("fork of daemon failed: %m");
+ log_error_errno(errno, "fork of daemon failed: %m");
rc = 4;
goto exit;
default:
@@ -1328,7 +1328,7 @@ int main(int argc, char *argv[]) {
fd_ep = epoll_create1(EPOLL_CLOEXEC);
if (fd_ep < 0) {
- log_error("error creating epoll fd: %m");
+ log_error_errno(errno, "error creating epoll fd: %m");
goto exit;
}
if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_ctrl, &ep_ctrl) < 0 ||
@@ -1336,7 +1336,7 @@ int main(int argc, char *argv[]) {
epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 ||
epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_netlink, &ep_netlink) < 0 ||
epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_worker, &ep_worker) < 0) {
- log_error("fail to add fds to epoll: %m");
+ log_error_errno(errno, "fail to add fds to epoll: %m");
goto exit;
}