Deduplicate error string patterns (#37676)

I wanted to see if moving moving out constant string arguments our of
error messages results in smaller binary sizes. Turns out it does, but
the savings are not consistent. Sometimes we get a few kB in a single
binary, sometimes there is no size change.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-06-02 15:34:17 +02:00
committed by GitHub
44 changed files with 162 additions and 150 deletions
+1 -1
View File
@@ -1930,7 +1930,7 @@ int vsock_get_local_cid(unsigned *ret) {
vsock_fd = open("/dev/vsock", O_RDONLY|O_CLOEXEC);
if (vsock_fd < 0)
return log_debug_errno(errno, "Failed to open /dev/vsock: %m");
return log_debug_errno(errno, "Failed to open %s: %m", "/dev/vsock");
unsigned tmp;
if (ioctl(vsock_fd, IOCTL_VM_SOCKETS_GET_LOCAL_CID, ret ?: &tmp) < 0)
+1 -1
View File
@@ -344,7 +344,7 @@ static int open_dev_autofs(Manager *m) {
m->dev_autofs_fd = open("/dev/autofs", O_CLOEXEC|O_RDONLY);
if (m->dev_autofs_fd < 0)
return log_error_errno(errno, "Failed to open /dev/autofs: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/dev/autofs");
init_autofs_dev_ioctl(&param);
r = RET_NERRNO(ioctl(m->dev_autofs_fd, AUTOFS_DEV_IOCTL_VERSION, &param));
+1 -1
View File
@@ -626,7 +626,7 @@ static int import_credentials_initrd(ImportCredentialContext *c) {
if (errno == ENOENT)
log_debug_errno(errno, "No credentials passed from initrd.");
else
log_warning_errno(errno, "Failed to open '/run/credentials/@initrd', ignoring: %m");
log_warning_errno(errno, "Failed to open '%s', ignoring: %m", "/run/credentials/@initrd");
return 0;
}
+4 -4
View File
@@ -245,7 +245,7 @@ static int console_setup(void) {
tty_fd = open_terminal("/dev/console", O_RDWR|O_NOCTTY|O_CLOEXEC);
if (tty_fd < 0)
return log_error_errno(tty_fd, "Failed to open /dev/console: %m");
return log_error_errno(tty_fd, "Failed to open %s: %m", "/dev/console");
/* We don't want to force text mode. Plymouth may be showing pictures already from initrd. */
reset_dev_console_fd(tty_fd, /* switch_to_text= */ false);
@@ -1619,7 +1619,7 @@ static void redirect_telinit(int argc, char *argv[]) {
return;
execv(SYSTEMCTL_BINARY_PATH, argv);
log_error_errno(errno, "Failed to exec " SYSTEMCTL_BINARY_PATH ": %m");
log_error_errno(errno, "Failed to execute %s: %m", SYSTEMCTL_BINARY_PATH);
exit(EXIT_FAILURE);
#endif
}
@@ -2604,12 +2604,12 @@ static int do_queue_default_job(
/* Fall back to default.target, which we used to always use by default. Only do this if no
* explicit configuration was given. */
log_info("Falling back to " SPECIAL_DEFAULT_TARGET ".");
log_info("Falling back to %s.", SPECIAL_DEFAULT_TARGET);
r = manager_load_startable_unit_or_warn(m, SPECIAL_DEFAULT_TARGET, NULL, &target);
}
if (r < 0) {
log_info("Falling back to " SPECIAL_RESCUE_TARGET ".");
log_info("Falling back to %s.", SPECIAL_RESCUE_TARGET);
r = manager_load_startable_unit_or_warn(m, SPECIAL_RESCUE_TARGET, NULL, &target);
if (r < 0) {
+1 -1
View File
@@ -497,7 +497,7 @@ static int manager_enable_special_signals(Manager *m) {
fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY|O_CLOEXEC);
if (fd < 0)
/* Support systems without virtual console (ENOENT) gracefully */
log_full_errno(fd == -ENOENT ? LOG_DEBUG : LOG_WARNING, fd, "Failed to open /dev/tty0, ignoring: %m");
log_full_errno(fd == -ENOENT ? LOG_DEBUG : LOG_WARNING, fd, "Failed to open %s, ignoring: %m", "/dev/tty0");
else {
/* Enable that we get SIGWINCH on kbrequest */
if (ioctl(fd, KDSIGACCEPT, SIGWINCH) < 0)
+3 -4
View File
@@ -2034,10 +2034,9 @@ static void mount_enumerate_perpetual(Manager *m) {
u = manager_get_unit(m, SPECIAL_ROOT_MOUNT);
if (!u) {
r = unit_new_for_name(m, sizeof(Mount), SPECIAL_ROOT_MOUNT, &u);
if (r < 0) {
log_error_errno(r, "Failed to allocate the special " SPECIAL_ROOT_MOUNT " unit: %m");
return;
}
if (r < 0)
return (void) log_error_errno(r, "Failed to allocate the special %s unit: %m",
SPECIAL_ROOT_MOUNT);
}
u->perpetual = true;
+1 -1
View File
@@ -2264,7 +2264,7 @@ static int apply_mounts(
if (reterr_path)
*reterr_path = strdup("/proc/self/mountinfo");
return log_debug_errno(r, "Failed to open /proc/self/mountinfo: %m");
return log_debug_errno(r, "Failed to open %s: %m", "/proc/self/mountinfo");
}
/* First round, establish all mounts we need */
+3 -4
View File
@@ -705,10 +705,9 @@ static void scope_enumerate_perpetual(Manager *m) {
u = manager_get_unit(m, SPECIAL_INIT_SCOPE);
if (!u) {
r = unit_new_for_name(m, sizeof(Scope), SPECIAL_INIT_SCOPE, &u);
if (r < 0) {
log_error_errno(r, "Failed to allocate the special " SPECIAL_INIT_SCOPE " unit: %m");
return;
}
if (r < 0)
return (void) log_error_errno(r, "Failed to allocate the special %s unit: %m",
SPECIAL_INIT_SCOPE);
}
u->transient = true;
+2 -2
View File
@@ -819,12 +819,12 @@ static int service_setup_bus_name(Service *s) {
if (s->type == SERVICE_DBUS) {
r = unit_add_dependency_by_name(UNIT(s), UNIT_REQUIRES, SPECIAL_DBUS_SOCKET, true, UNIT_DEPENDENCY_FILE);
if (r < 0)
return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on " SPECIAL_DBUS_SOCKET ": %m");
return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on %s: %m", SPECIAL_DBUS_SOCKET);
/* We always want to be ordered against dbus.socket if both are in the transaction. */
r = unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_DBUS_SOCKET, true, UNIT_DEPENDENCY_FILE);
if (r < 0)
return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on " SPECIAL_DBUS_SOCKET ": %m");
return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on %s: %m", SPECIAL_DBUS_SOCKET);
}
r = unit_watch_bus_name(UNIT(s), s->bus_name);
+62 -55
View File
@@ -13,6 +13,7 @@
#include "alloc-util.h"
#include "dirent-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "log.h"
@@ -49,33 +50,34 @@ static int fdopen_unlocked_at(int dfd, const char *dir, const char *name, int *s
static int write_access2_rules(const char *srcdir) {
_cleanup_close_ int load2_fd = -EBADF, change_fd = -EBADF;
_cleanup_closedir_ DIR *dir = NULL;
int dfd = -EBADF, r = 0;
int dfd, r;
load2_fd = open("/sys/fs/smackfs/load2", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (load2_fd < 0) {
if (errno != ENOENT)
log_warning_errno(errno, "Failed to open '/sys/fs/smackfs/load2': %m");
return -errno; /* negative error */
load2_fd = r = RET_NERRNO(open("/sys/fs/smackfs/load2", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
if (r < 0) {
if (r != -ENOENT)
log_warning_errno(r, "Failed to open %s: %m", "/sys/fs/smackfs/load2");
return r;
}
change_fd = open("/sys/fs/smackfs/change-rule", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (change_fd < 0) {
if (errno != ENOENT)
log_warning_errno(errno, "Failed to open '/sys/fs/smackfs/change-rule': %m");
return -errno; /* negative error */
change_fd = r = RET_NERRNO(open("/sys/fs/smackfs/change-rule", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
if (r < 0) {
if (r != -ENOENT)
log_warning_errno(r, "Failed to open %s: %m", "/sys/fs/smackfs/change-rule");
return r;
}
/* write rules to load2 or change-rule from every file in the directory */
dir = opendir(srcdir);
if (!dir) {
if (errno != ENOENT)
log_warning_errno(errno, "Failed to opendir '%s': %m", srcdir);
log_warning_errno(errno, "Failed to open %s/: %m", srcdir);
return errno; /* positive on purpose */
}
dfd = dirfd(dir);
assert(dfd >= 0);
r = 0;
FOREACH_DIRENT(entry, dir, return 0) {
_cleanup_fclose_ FILE *policy = NULL;
@@ -92,7 +94,7 @@ static int write_access2_rules(const char *srcdir) {
q = read_line(policy, NAME_MAX, &buf);
if (q < 0)
return log_error_errno(q, "Failed to read line from '%s': %m", entry->d_name);
return log_error_errno(q, "%s/%s: failed to read line: %m", srcdir, entry->d_name);
if (q == 0)
break;
@@ -102,15 +104,17 @@ static int write_access2_rules(const char *srcdir) {
/* if 3 args -> load rule : subject object access1 */
/* if 4 args -> change rule : subject object access1 access2 */
if (sscanf(buf, "%ms %ms %ms %ms", &sbj, &obj, &acc1, &acc2) < 3) {
log_error_errno(errno, "Failed to parse rule '%s' in '%s', ignoring.", buf, entry->d_name);
log_error_errno(errno, "%s/%s: failed to parse rule '%s', ignoring.",
srcdir, entry->d_name, buf);
continue;
}
if (write(isempty(acc2) ? load2_fd : change_fd, buf, strlen(buf)) < 0) {
if (r == 0)
r = -errno;
log_error_errno(errno, "Failed to write '%s' to '%s' in '%s': %m",
buf, isempty(acc2) ? "/sys/fs/smackfs/load2" : "/sys/fs/smackfs/change-rule", entry->d_name);
q = RET_NERRNO(write(isempty(acc2) ? load2_fd : change_fd, buf, strlen(buf)));
if (q < 0) {
log_error_errno(q, "%s/%s: failed to write '%s' to '%s': %m",
srcdir, entry->d_name,
buf, isempty(acc2) ? "/sys/fs/smackfs/load2" : "/sys/fs/smackfs/change-rule");
RET_GATHER(r, q);
}
}
}
@@ -121,26 +125,27 @@ static int write_access2_rules(const char *srcdir) {
static int write_cipso2_rules(const char *srcdir) {
_cleanup_close_ int cipso2_fd = -EBADF;
_cleanup_closedir_ DIR *dir = NULL;
int dfd = -EBADF, r = 0;
int dfd, r;
cipso2_fd = open("/sys/fs/smackfs/cipso2", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (cipso2_fd < 0) {
if (errno != ENOENT)
log_warning_errno(errno, "Failed to open '/sys/fs/smackfs/cipso2': %m");
return -errno; /* negative error */
cipso2_fd = r = RET_NERRNO(open("/sys/fs/smackfs/cipso2", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
if (r < 0) {
if (r != -ENOENT)
log_warning_errno(r, "Failed to open %s: %m", "/sys/fs/smackfs/cipso2");
return r;
}
/* write rules to cipso2 from every file in the directory */
dir = opendir(srcdir);
if (!dir) {
if (errno != ENOENT)
log_warning_errno(errno, "Failed to opendir '%s': %m", srcdir);
log_warning_errno(errno, "Failed to open %s/: %m", srcdir);
return errno; /* positive on purpose */
}
dfd = dirfd(dir);
assert(dfd >= 0);
r = 0;
FOREACH_DIRENT(entry, dir, return 0) {
_cleanup_fclose_ FILE *policy = NULL;
@@ -157,18 +162,20 @@ static int write_cipso2_rules(const char *srcdir) {
q = read_line(policy, NAME_MAX, &buf);
if (q < 0)
return log_error_errno(q, "Failed to read line from '%s': %m", entry->d_name);
return log_error_errno(q, "%s/%s: failed to read line: %m",
srcdir, entry->d_name);
if (q == 0)
break;
if (isempty(buf) || strchr(COMMENTS, buf[0]))
continue;
if (write(cipso2_fd, buf, strlen(buf)) < 0) {
if (r == 0)
r = -errno;
log_error_errno(errno, "Failed to write '%s' to '/sys/fs/smackfs/cipso2' in '%s': %m",
buf, entry->d_name);
q = RET_NERRNO(write(cipso2_fd, buf, strlen(buf)));
if (q < 0) {
log_error_errno(q, "%s/%s: failed to write '%s' to %s: %m",
srcdir, entry->d_name,
buf, "/sys/fs/smackfs/cipso2");
RET_GATHER(r, q);
break;
}
}
@@ -180,12 +187,12 @@ static int write_cipso2_rules(const char *srcdir) {
static int write_netlabel_rules(const char *srcdir) {
_cleanup_fclose_ FILE *dst = NULL;
_cleanup_closedir_ DIR *dir = NULL;
int dfd = -EBADF, r = 0;
int dfd, r;
dst = fopen("/sys/fs/smackfs/netlabel", "we");
if (!dst) {
if (errno != ENOENT)
log_warning_errno(errno, "Failed to open /sys/fs/smackfs/netlabel: %m");
log_warning_errno(errno, "Failed to open %s/: %m", "/sys/fs/smackfs/netlabel");
return -errno; /* negative error */
}
@@ -193,13 +200,14 @@ static int write_netlabel_rules(const char *srcdir) {
dir = opendir(srcdir);
if (!dir) {
if (errno != ENOENT)
log_warning_errno(errno, "Failed to opendir %s: %m", srcdir);
log_warning_errno(errno, "Failed to open %s/: %m", srcdir);
return errno; /* positive on purpose */
}
dfd = dirfd(dir);
assert(dfd >= 0);
r = 0;
FOREACH_DIRENT(entry, dir, return 0) {
_cleanup_fclose_ FILE *policy = NULL;
@@ -213,21 +221,20 @@ static int write_netlabel_rules(const char *srcdir) {
q = read_line(policy, NAME_MAX, &buf);
if (q < 0)
return log_error_errno(q, "Failed to read line from %s: %m", entry->d_name);
return log_error_errno(q, "%s/%s: failed to read line: %m",
srcdir, entry->d_name);
if (q == 0)
break;
if (!fputs(buf, dst)) {
if (r == 0)
r = -EINVAL;
log_error_errno(errno, "Failed to write line to /sys/fs/smackfs/netlabel: %m");
log_error_errno(errno, "Failed to write line to %s: %m", "/sys/fs/smackfs/netlabel");
RET_GATHER(r, -errno);
break;
}
q = fflush_and_check(dst);
if (q < 0) {
if (r == 0)
r = q;
log_error_errno(q, "Failed to flush writes to /sys/fs/smackfs/netlabel: %m");
log_error_errno(q, "Failed to flush %s: %m", "/sys/fs/smackfs/netlabel");
RET_GATHER(r, q);
break;
}
}
@@ -246,7 +253,7 @@ static int write_onlycap_list(void) {
f = fopen("/etc/smack/onlycap", "re");
if (!f) {
if (errno != ENOENT)
log_warning_errno(errno, "Failed to read '/etc/smack/onlycap': %m");
log_warning_errno(errno, "Failed to open %s: %m", "/etc/smack/onlycap");
return errno == ENOENT ? ENOENT : -errno;
}
@@ -257,7 +264,7 @@ static int write_onlycap_list(void) {
r = read_line(f, LONG_LINE_MAX, &buf);
if (r < 0)
return log_error_errno(r, "Failed to read line from /etc/smack/onlycap: %m");
return log_error_errno(r, "%s: failed to read line: %m", "/etc/smack/onlycap");
if (r == 0)
break;
@@ -277,16 +284,17 @@ static int write_onlycap_list(void) {
list[len - 1] = 0;
onlycap_fd = open("/sys/fs/smackfs/onlycap", O_WRONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (onlycap_fd < 0) {
if (errno != ENOENT)
log_warning_errno(errno, "Failed to open '/sys/fs/smackfs/onlycap': %m");
return -errno; /* negative error */
onlycap_fd = r = RET_NERRNO(open("/sys/fs/smackfs/onlycap", O_WRONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
if (r < 0) {
if (r != -ENOENT)
log_warning_errno(r, "Failed to open %s: %m", "/sys/fs/smackfs/onlycap");
return r;
}
r = write(onlycap_fd, list, len);
r = RET_NERRNO(write(onlycap_fd, list, len));
if (r < 0)
return log_error_errno(errno, "Failed to write onlycap list(%s) to '/sys/fs/smackfs/onlycap': %m", list);
return log_error_errno(r, "%s: failed to write onlycap list(%s): %m",
"/sys/fs/smackfs/onlycap", list);
return 0;
}
@@ -296,12 +304,11 @@ static int write_onlycap_list(void) {
int mac_smack_setup(bool *loaded_policy) {
#if ENABLE_SMACK
int r;
assert(loaded_policy);
r = write_access2_rules("/etc/smack/accesses.d/");
r = write_access2_rules("/etc/smack/accesses.d");
switch (r) {
case -ENOENT:
log_debug("Smack is not enabled in the kernel.");
@@ -333,7 +340,7 @@ int mac_smack_setup(bool *loaded_policy) {
log_warning_errno(r, "Failed to set SMACK netlabel rule \"127.0.0.1 -CIPSO\": %m");
#endif
r = write_cipso2_rules("/etc/smack/cipso.d/");
r = write_cipso2_rules("/etc/smack/cipso.d");
switch (r) {
case -ENOENT:
log_debug("Smack/CIPSO is not enabled in the kernel.");
@@ -348,7 +355,7 @@ int mac_smack_setup(bool *loaded_policy) {
log_warning_errno(r, "Failed to load Smack/CIPSO access rules, ignoring: %m");
}
r = write_netlabel_rules("/etc/smack/netlabel.d/");
r = write_netlabel_rules("/etc/smack/netlabel.d");
switch (r) {
case -ENOENT:
log_debug("Smack/CIPSO is not enabled in the kernel.");
+1 -1
View File
@@ -1317,7 +1317,7 @@ static void swap_enumerate(Manager *m) {
if (errno == ENOENT)
log_debug_errno(errno, "Not swap enabled, skipping enumeration.");
else
log_warning_errno(errno, "Failed to open /proc/swaps, ignoring: %m");
log_warning_errno(errno, "Failed to open %s, ignoring: %m", "/proc/swaps");
return;
}
+1 -1
View File
@@ -156,7 +156,7 @@ static int display_emergency_message_fullscreen(const char *message) {
else {
fd = open_terminal("/dev/tty1", O_RDWR|O_NOCTTY|O_CLOEXEC);
if (fd < 0)
return log_error_errno(fd, "Failed to open /dev/tty1: %m");
return log_error_errno(fd, "Failed to open %s: %m", "/dev/tty1");
r = find_next_free_vt(fd, &free_vt, &original_vt);
if (r < 0)
+1 -1
View File
@@ -2059,7 +2059,7 @@ static int manager_open_hostname(Manager *m) {
m->hostname_fd = open("/proc/sys/kernel/hostname",
O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (m->hostname_fd < 0)
return log_error_errno(errno, "Failed to open /proc/sys/kernel/hostname: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/proc/sys/kernel/hostname");
r = sd_event_add_io(m->event, &m->hostname_event_source, m->hostname_fd, 0, dispatch_hostname_change, m);
if (r < 0)
+5 -5
View File
@@ -105,31 +105,31 @@ char** device_make_log_fields(sd_device *device) {
r = sd_device_get_devnum(device, &devnum);
if (r < 0 && r != -ENOENT)
log_device_debug_errno(device, r, "Failed to get device \"DEVNUM\" property, ignoring: %m");
log_device_debug_errno(device, r, "Failed to get device \"%s\" property, ignoring: %m", "DEVNUM");
if (r >= 0)
(void) strv_extendf(&strv, "DEVNUM="DEVNUM_FORMAT_STR, DEVNUM_FORMAT_VAL(devnum));
r = sd_device_get_ifindex(device, &ifindex);
if (r < 0 && r != -ENOENT)
log_device_debug_errno(device, r, "Failed to get device \"IFINDEX\" property, ignoring: %m");
log_device_debug_errno(device, r, "Failed to get device \"%s\" property, ignoring: %m", "IFINDEX");
if (r >= 0)
(void) strv_extendf(&strv, "IFINDEX=%i", ifindex);
r = sd_device_get_action(device, &action);
if (r < 0 && r != -ENOENT)
log_device_debug_errno(device, r, "Failed to get device \"ACTION\" property, ignoring: %m");
log_device_debug_errno(device, r, "Failed to get device \"%s\" property, ignoring: %m", "ACTION");
if (r >= 0)
(void) strv_extendf(&strv, "ACTION=%s", device_action_to_string(action));
r = sd_device_get_seqnum(device, &seqnum);
if (r < 0 && r != -ENOENT)
log_device_debug_errno(device, r, "Failed to get device \"SEQNUM\" property, ignoring: %m");
log_device_debug_errno(device, r, "Failed to get device \"%s\" property, ignoring: %m", "SEQNUM");
if (r >= 0)
(void) strv_extendf(&strv, "SEQNUM=%"PRIu64, seqnum);
r = sd_device_get_diskseq(device, &diskseq);
if (r < 0 && r != -ENOENT)
log_device_debug_errno(device, r, "Failed to get device \"DISKSEQ\" property, ignoring: %m");
log_device_debug_errno(device, r, "Failed to get device \"%s\" property, ignoring: %m", "DISKSEQ");
if (r >= 0)
(void) strv_extendf(&strv, "DISKSEQ=%"PRIu64, diskseq);
+1 -1
View File
@@ -1761,7 +1761,7 @@ static int flush_devices(Manager *m) {
d = opendir("/etc/udev/rules.d");
if (!d) {
if (errno != ENOENT)
log_warning_errno(errno, "Failed to open /etc/udev/rules.d: %m");
log_warning_errno(errno, "Failed to open %s: %m", "/etc/udev/rules.d");
} else
FOREACH_DIRENT_ALL(de, d, break) {
if (!dirent_is_file(de))
+6 -6
View File
@@ -256,7 +256,7 @@ static int manager_enumerate_seats(Manager *m) {
if (errno == ENOENT)
return 0;
return log_error_errno(errno, "Failed to open /run/systemd/seats/: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/run/systemd/seats/");
}
FOREACH_DIRENT(de, d, return -errno) {
@@ -290,7 +290,7 @@ static int manager_enumerate_linger_users(Manager *m) {
if (errno == ENOENT)
return 0;
return log_error_errno(errno, "Failed to open /var/lib/systemd/linger/: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/var/lib/systemd/linger/");
}
FOREACH_DIRENT(de, d, return -errno) {
@@ -329,7 +329,7 @@ static int manager_enumerate_users(Manager *m) {
if (errno == ENOENT)
return 0;
return log_error_errno(errno, "Failed to open /run/systemd/users/: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/run/systemd/users/");
}
FOREACH_DIRENT(de, d, return -errno) {
@@ -537,7 +537,7 @@ static int manager_enumerate_sessions(Manager *m) {
if (errno == ENOENT)
return 0;
return log_error_errno(errno, "Failed to open /run/systemd/sessions/: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/run/systemd/sessions/");
}
FOREACH_DIRENT(de, d, return -errno) {
@@ -584,7 +584,7 @@ static int manager_enumerate_inhibitors(Manager *m) {
if (errno == ENOENT)
return 0;
return log_error_errno(errno, "Failed to open /run/systemd/inhibit/: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/run/systemd/inhibit/");
}
FOREACH_DIRENT(de, d, return -errno) {
@@ -889,7 +889,7 @@ static int manager_connect_console(Manager *m) {
return 0;
}
return log_error_errno(errno, "Failed to open /sys/class/tty/tty0/active: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/sys/class/tty/tty0/active");
}
r = sd_event_add_io(m->event, &m->console_active_event_source, m->console_active_fd, 0, manager_dispatch_console, m);
+1 -1
View File
@@ -179,7 +179,7 @@ static int manager_enumerate_machines(Manager *m) {
if (errno == ENOENT)
return 0;
return log_error_errno(errno, "Failed to open /run/systemd/machines: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/run/systemd/machines");
}
FOREACH_DIRENT(de, d, return -errno) {
+1 -1
View File
@@ -292,7 +292,7 @@ int verb_persistent_storage(int argc, char *argv[], void *userdata) {
fd = open("/var/lib/systemd/network/", O_CLOEXEC | O_DIRECTORY);
if (fd < 0)
return log_error_errno(errno, "Failed to open /var/lib/systemd/network/: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/var/lib/systemd/network/");
r = sd_varlink_push_fd(vl, fd);
if (r < 0)
+1 -1
View File
@@ -599,7 +599,7 @@ static int persistent_storage_open(void) {
fd = open("/var/lib/systemd/network/", O_CLOEXEC | O_DIRECTORY);
if (fd < 0)
return log_debug_errno(errno, "Failed to open /var/lib/systemd/network/, ignoring: %m");
return log_debug_errno(errno, "Failed to open %s, ignoring: %m", "/var/lib/systemd/network/");
r = fd_is_read_only_fs(fd);
if (r < 0)
+1 -1
View File
@@ -1634,7 +1634,7 @@ static int create_tap(
if (errno == ENOENT) /* Turn ENOENT → EOPNOTSUPP */
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Network tap device node /dev/net/tun not found, cannot create network interface.");
return log_error_errno(errno, "Failed to open /dev/net/tun: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/dev/net/tun");
}
if (ioctl(fd, TUNSETIFF, &ifr) < 0)
+17 -15
View File
@@ -102,12 +102,14 @@ static CreditEntropy may_credit(int seed_fd) {
static int random_seed_size(int seed_fd, size_t *ret_size) {
struct stat st;
int r;
assert(ret_size);
assert(seed_fd >= 0);
if (fstat(seed_fd, &st) < 0)
return log_error_errno(errno, "Failed to stat() seed file " RANDOM_SEED ": %m");
r = RET_NERRNO(fstat(seed_fd, &st));
if (r < 0)
return log_error_errno(r, "Failed to stat seed file %s: %m", RANDOM_SEED);
/* If the seed file is larger than what the kernel expects, then honour the existing size and
* save/restore as much as it says */
@@ -157,11 +159,11 @@ static int load_seed_file(
k = loop_read(seed_fd, buf, seed_size, false);
if (k < 0) {
log_warning_errno(k, "Failed to read seed from " RANDOM_SEED ": %m");
log_warning_errno(k, "Failed to read seed from %s: %m", RANDOM_SEED);
return 0;
}
if (k == 0) {
log_debug("Seed file " RANDOM_SEED " not yet initialized, proceeding.");
log_debug("Seed file %s not yet initialized, proceeding.", RANDOM_SEED);
return 0;
}
@@ -384,11 +386,11 @@ static int run(int argc, char *argv[]) {
r = mkdir_parents(RANDOM_SEED, 0755);
if (r < 0)
return log_error_errno(r, "Failed to create directory " RANDOM_SEED_DIR ": %m");
return log_error_errno(r, "Failed to create directory %s: %m", RANDOM_SEED);
random_fd = open("/dev/urandom", O_RDWR|O_CLOEXEC|O_NOCTTY);
if (random_fd < 0)
return log_error_errno(errno, "Failed to open /dev/urandom: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/dev/urandom");
/* When we load the seed we read it and write it to the device and then immediately update the saved
* seed with new data, to make sure the next boot gets seeded differently. */
@@ -399,20 +401,20 @@ static int run(int argc, char *argv[]) {
* load_machine_id() for an explanation why. */
load_machine_id(random_fd);
seed_fd = open(RANDOM_SEED, O_RDWR|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600);
seed_fd = RET_NERRNO(open(RANDOM_SEED, O_RDWR|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600));
if (seed_fd < 0) {
int open_rw_error = -errno;
int open_rw_error = seed_fd;
write_seed_file = false;
seed_fd = open(RANDOM_SEED, O_RDONLY|O_CLOEXEC|O_NOCTTY);
seed_fd = RET_NERRNO(open(RANDOM_SEED, O_RDONLY|O_CLOEXEC|O_NOCTTY));
if (seed_fd < 0) {
bool missing = errno == ENOENT;
bool missing = seed_fd == -ENOENT;
int level = missing ? LOG_DEBUG : LOG_ERR;
log_full_errno(level, open_rw_error, "Failed to open " RANDOM_SEED " for writing: %m");
log_full_errno(level, errno, "Failed to open " RANDOM_SEED " for reading: %m");
return missing ? 0 : -errno;
log_full_errno(level, open_rw_error, "Failed to open %s for writing: %m", RANDOM_SEED);
log_full_errno(level, seed_fd, "Failed to open %s for reading: %m", RANDOM_SEED);
return missing ? 0 : seed_fd;
}
} else
write_seed_file = true;
@@ -422,9 +424,9 @@ static int run(int argc, char *argv[]) {
break;
case ACTION_SAVE:
seed_fd = open(RANDOM_SEED, O_WRONLY|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600);
seed_fd = RET_NERRNO(open(RANDOM_SEED, O_WRONLY|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600));
if (seed_fd < 0)
return log_error_errno(errno, "Failed to open " RANDOM_SEED ": %m");
return log_error_errno(seed_fd, "Failed to open %s: %m", RANDOM_SEED);
read_seed_file = false;
write_seed_file = true;
+1 -1
View File
@@ -365,7 +365,7 @@ static int manager_etc_hosts_read(Manager *m) {
f = fopen("/etc/hosts", "re");
if (!f) {
if (errno != ENOENT)
return log_error_errno(errno, "Failed to open /etc/hosts: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/etc/hosts");
manager_etc_hosts_flush(m);
return 0;
+1 -1
View File
@@ -106,7 +106,7 @@ int manager_read_resolv_conf(Manager *m) {
if (errno == ENOENT)
return 0;
r = log_warning_errno(errno, "Failed to open /etc/resolv.conf: %m");
r = log_warning_errno(errno, "Failed to open %s: %m", "/etc/resolv.conf");
goto clear;
}
+1 -1
View File
@@ -291,7 +291,7 @@ static int run(int argc, char *argv[]) {
return 0;
}
return log_error_errno(errno, "Failed to open /dev/rfkill: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/dev/rfkill");
}
} else {
c.rfkill_fd = SD_LISTEN_FDS_START;
+5 -5
View File
@@ -41,7 +41,7 @@ static int clean_sysvipc_shm(uid_t delete_uid, gid_t delete_gid, bool rm) {
if (errno == ENOENT)
return 0;
return log_warning_errno(errno, "Failed to open /proc/sysvipc/shm: %m");
return log_warning_errno(errno, "Failed to open %s: %m", "/proc/sysvipc/shm");
}
for (;;) {
@@ -105,7 +105,7 @@ static int clean_sysvipc_sem(uid_t delete_uid, gid_t delete_gid, bool rm) {
if (errno == ENOENT)
return 0;
return log_warning_errno(errno, "Failed to open /proc/sysvipc/sem: %m");
return log_warning_errno(errno, "Failed to open %s: %m", "/proc/sysvipc/sem");
}
for (;;) {
@@ -164,7 +164,7 @@ static int clean_sysvipc_msg(uid_t delete_uid, gid_t delete_gid, bool rm) {
if (errno == ENOENT)
return 0;
return log_warning_errno(errno, "Failed to open /proc/sysvipc/msg: %m");
return log_warning_errno(errno, "Failed to open %s: %m", "/proc/sysvipc/msg");
}
for (;;) {
@@ -302,7 +302,7 @@ static int clean_posix_shm(uid_t uid, gid_t gid, bool rm) {
if (errno == ENOENT)
return 0;
return log_warning_errno(errno, "Failed to open /dev/shm: %m");
return log_warning_errno(errno, "Failed to open %s: %m", "/dev/shm");
}
return clean_posix_shm_internal("/dev/shm", dir, uid, gid, rm);
@@ -317,7 +317,7 @@ static int clean_posix_mq(uid_t uid, gid_t gid, bool rm) {
if (errno == ENOENT)
return 0;
return log_warning_errno(errno, "Failed to open /dev/mqueue: %m");
return log_warning_errno(errno, "Failed to open %s: %m", "/dev/mqueue");
}
FOREACH_DIRENT_ALL(de, dir, goto fail) {
+1 -1
View File
@@ -519,7 +519,7 @@ static int condition_test_firmware_devicetree_compatible(const char *dtcarg) {
if (r < 0) {
/* if the path doesn't exist it is incompatible */
if (r != -ENOENT)
log_debug_errno(r, "Failed to open() '%s', assuming machine is incompatible: %m", DTCOMPAT_FILE);
log_debug_errno(r, "Failed to open '%s', assuming machine is incompatible: %m", DTCOMPAT_FILE);
return false;
}
+1 -1
View File
@@ -590,7 +590,7 @@ int _fork_agent(const char *name, char * const *argv, const int except[], size_t
* stdin around. */
fd = open_terminal("/dev/tty", stdin_is_tty ? O_WRONLY : (stdout_is_tty && stderr_is_tty) ? O_RDONLY : O_RDWR);
if (fd < 0) {
log_error_errno(fd, "Failed to open /dev/tty: %m");
log_error_errno(fd, "Failed to open %s: %m", "/dev/tty");
_exit(EXIT_FAILURE);
}
+1 -1
View File
@@ -257,7 +257,7 @@ static int read_swap_entries(SwapEntries *ret) {
f = fopen("/proc/swaps", "re");
if (!f)
return log_debug_errno(errno, "Failed to open /proc/swaps: %m");
return log_debug_errno(errno, "Failed to open %s: %m", "/proc/swaps");
/* Remove header */
(void) fscanf(f, "%*s %*s %*s %*s %*s\n");
+1 -1
View File
@@ -235,7 +235,7 @@ static int killall(int sig, Set *pids, bool send_sighup) {
r = proc_dir_open(&dir);
if (r < 0)
return log_warning_errno(r, "Failed to open /proc/: %m");
return log_warning_errno(r, "Failed to open %s: %m", "/proc/");
for (;;) {
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
+1 -1
View File
@@ -72,7 +72,7 @@ static int locale_context_load_conf(LocaleContext *c, LocaleLoadFlag flag) {
if (fd == -ENOENT)
return 0;
if (fd < 0)
return log_debug_errno(errno, "Failed to open /etc/locale.conf: %m");
return log_debug_errno(errno, "Failed to open %s: %m", "/etc/locale.conf");
if (fstat(fd, &st) < 0)
return log_debug_errno(errno, "Failed to stat /etc/locale.conf: %m");
+5 -5
View File
@@ -146,7 +146,7 @@ int machine_id_setup(const char *root, sd_id128_t machine_id, MachineIdSetupFlag
r = chase("/etc/", root, CHASE_PREFIX_ROOT|CHASE_MKDIR_0755|CHASE_MUST_BE_DIRECTORY, &etc, &etc_fd);
if (r < 0)
return log_error_errno(r, "Failed to open '/etc/': %m");
return log_error_errno(r, "Failed to open %s: %m", "/etc/");
etc_machine_id = path_join(etc, "machine-id");
if (!etc_machine_id)
@@ -251,7 +251,7 @@ int machine_id_setup(const char *root, sd_id128_t machine_id, MachineIdSetupFlag
r = chase("/run/", root, CHASE_PREFIX_ROOT|CHASE_MKDIR_0755|CHASE_MUST_BE_DIRECTORY, &run, &run_fd);
if (r < 0)
return log_error_errno(r, "Failed to open '/run/': %m");
return log_error_errno(r, "Failed to open %s: %m", "/run/");
run_machine_id = path_join(run, "machine-id");
if (!run_machine_id)
@@ -269,7 +269,7 @@ int machine_id_setup(const char *root, sd_id128_t machine_id, MachineIdSetupFlag
} else {
r = chase("/run/machine-id", root, CHASE_PREFIX_ROOT|CHASE_MUST_BE_REGULAR, &run_machine_id, /* ret_fd= */ NULL);
if (r < 0)
return log_error_errno(r, "Failed to open '/run/machine-id': %m");
return log_error_errno(r, "Failed to open %s: %m", "/run/machine-id");
}
/* And now, let's mount it over */
@@ -322,7 +322,7 @@ int machine_id_commit(const char *root) {
_cleanup_free_ char *etc = NULL;
r = chase("/etc/", root, CHASE_PREFIX_ROOT|CHASE_MUST_BE_DIRECTORY, &etc, &etc_fd);
if (r < 0)
return log_error_errno(r, "Failed to open /etc/: %m");
return log_error_errno(r, "Failed to open %s: %m", "/etc/");
_cleanup_free_ char *etc_machine_id = path_join(etc, "machine-id");
if (!etc_machine_id)
@@ -370,7 +370,7 @@ int machine_id_commit(const char *root) {
_cleanup_close_ int etc_fd_again = -EBADF;
r = chase("/etc/", root, CHASE_PREFIX_ROOT|CHASE_MUST_BE_DIRECTORY, /* ret_path= */ NULL, &etc_fd_again);
if (r < 0)
return log_error_errno(r, "Failed to open /etc/: %m");
return log_error_errno(r, "Failed to open %s: %m", "/etc/");
r = umountat_detach_verbose(LOG_ERR, etc_fd_again, "machine-id");
if (r < 0)
+2 -2
View File
@@ -45,7 +45,7 @@ int umount_recursive_full(const char *prefix, int flags, char **keep) {
f = fopen("/proc/self/mountinfo", "re"); /* Pin the file, in case we unmount /proc/ as part of the logic here */
if (!f)
return log_debug_errno(errno, "Failed to open /proc/self/mountinfo: %m");
return log_debug_errno(errno, "Failed to open %s: %m", "/proc/self/mountinfo");
for (;;) {
_cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
@@ -454,7 +454,7 @@ int bind_remount_one(const char *path, unsigned long new_flags, unsigned long fl
proc_self_mountinfo = fopen("/proc/self/mountinfo", "re");
if (!proc_self_mountinfo)
return log_debug_errno(errno, "Failed to open /proc/self/mountinfo: %m");
return log_debug_errno(errno, "Failed to open %s: %m", "/proc/self/mountinfo");
return bind_remount_one_with_mountinfo(path, new_flags, flags_mask, proc_self_mountinfo);
}
+2 -2
View File
@@ -6029,7 +6029,7 @@ int tpm2_list_devices(bool legend, bool quiet) {
d = opendir("/sys/class/tpmrm");
if (!d) {
log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR, errno, "Failed to open /sys/class/tpmrm: %m");
log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR, errno, "Failed to open %s: %m", "/sys/class/tpmrm");
if (errno != ENOENT)
return -errno;
} else {
@@ -6099,7 +6099,7 @@ int tpm2_find_device_auto(char **ret) {
d = opendir("/sys/class/tpmrm");
if (!d) {
log_debug_errno(errno, "Failed to open /sys/class/tpmrm: %m");
log_debug_errno(errno, "Failed to open %s: %m", "/sys/class/tpmrm");
if (errno != ENOENT)
return -errno;
} else {
+1 -1
View File
@@ -109,7 +109,7 @@ static int delete_dm(DeviceMapper *m) {
fd = open("/dev/mapper/control", O_RDWR|O_CLOEXEC);
if (fd < 0)
return log_debug_errno(errno, "Failed to open /dev/mapper/control: %m");
return log_debug_errno(errno, "Failed to open %s: %m", "/dev/mapper/control");
return RET_NERRNO(ioctl(fd, DM_DEV_REMOVE, &(struct dm_ioctl) {
.version = {
+1 -1
View File
@@ -197,7 +197,7 @@ static int sync_making_progress(unsigned long long *prev_dirty) {
f = fopen("/proc/meminfo", "re");
if (!f)
return log_warning_errno(errno, "Failed to open /proc/meminfo: %m");
return log_warning_errno(errno, "Failed to open %s: %m", "/proc/meminfo");
for (;;) {
_cleanup_free_ char *line = NULL;
+1 -1
View File
@@ -188,7 +188,7 @@ static void log_umount_blockers(const char *mnt) {
_cleanup_closedir_ DIR *dir = opendir("/proc");
if (!dir)
return (void) log_warning_errno(errno, "Failed to open /proc/: %m");
return (void) log_warning_errno(errno, "Failed to open %s: %m", "/proc/");
FOREACH_DIRENT_ALL(de, dir, break) {
if (!IN_SET(de->d_type, DT_DIR, DT_UNKNOWN))
+12 -7
View File
@@ -108,7 +108,7 @@ static int get_battery_discharge_rate(sd_device *dev, int *ret) {
f = fopen(DISCHARGE_RATE_FILEPATH, "re");
if (!f)
return log_debug_errno(errno, "Failed to read discharge rate from " DISCHARGE_RATE_FILEPATH ": %m");
return log_debug_errno(errno, "Failed to read discharge rate from %s: %m", DISCHARGE_RATE_FILEPATH);
current_hash_id = system_battery_identifier_hash(dev);
@@ -119,20 +119,22 @@ static int get_battery_discharge_rate(sd_device *dev, int *ret) {
r = read_line(f, LONG_LINE_MAX, &line);
if (r < 0)
return log_debug_errno(r, "Failed to read discharge rate from " DISCHARGE_RATE_FILEPATH ": %m");
return log_debug_errno(r, "Failed to read discharge rate from %s: %m", DISCHARGE_RATE_FILEPATH);
if (r == 0)
break;
p = line;
r = extract_many_words(&p, NULL, 0, &stored_hash_id, &stored_discharge_rate);
if (r < 0)
return log_debug_errno(r, "Failed to parse hash_id and discharge_rate read from " DISCHARGE_RATE_FILEPATH ": %m");
return log_debug_errno(r, "Failed to parse hash_id and discharge_rate read from %s: %m",
DISCHARGE_RATE_FILEPATH);
if (r != 2)
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid number of items fetched from " DISCHARGE_RATE_FILEPATH);
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid number of items fetched from %s.",
DISCHARGE_RATE_FILEPATH);
r = safe_atou64(stored_hash_id, &hash_id);
if (r < 0)
return log_debug_errno(r, "Failed to parse hash ID read from " DISCHARGE_RATE_FILEPATH " location: %m");
return log_debug_errno(r, "Failed to parse hash ID read from %s: %m", DISCHARGE_RATE_FILEPATH);
if (current_hash_id != hash_id)
/* matching device not found, move to next line */
@@ -140,10 +142,13 @@ static int get_battery_discharge_rate(sd_device *dev, int *ret) {
r = safe_atoi(stored_discharge_rate, &discharge_rate);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to parse discharge rate read from " DISCHARGE_RATE_FILEPATH ": %m");
return log_device_debug_errno(dev, r, "Failed to parse discharge rate read from %s: %m",
DISCHARGE_RATE_FILEPATH);
if (!battery_discharge_rate_is_valid(discharge_rate))
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ERANGE), "Invalid battery discharge percentage rate per hour.");
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ERANGE),
"Invalid battery discharge percentage rate per hour read from %s.",
DISCHARGE_RATE_FILEPATH);
*ret = discharge_rate;
return 0; /* matching device found, exit iteration */
+1 -1
View File
@@ -266,7 +266,7 @@ static int execute(
/* This file is opened first, so that if we hit an error, we can abort before modifying any state. */
state_fd = open("/sys/power/state", O_WRONLY|O_CLOEXEC);
if (state_fd < 0)
return log_error_errno(errno, "Failed to open /sys/power/state: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/sys/power/state");
if (sleep_needs_mem_sleep(sleep_config, operation)) {
r = write_mode("/sys/power/mem_sleep", sleep_config->mem_modes);
+2 -2
View File
@@ -420,7 +420,7 @@ static int nvme_subsystem_add(const char *node, int consumed_fd, sd_device *devi
_cleanup_close_ int subsystems_fd = -EBADF;
subsystems_fd = RET_NERRNO(open("/sys/kernel/config/nvmet/subsystems", O_DIRECTORY|O_CLOEXEC|O_RDONLY));
if (subsystems_fd < 0)
return log_error_errno(subsystems_fd, "Failed to open /sys/kernel/config/nvmet/subsystems: %m");
return log_error_errno(subsystems_fd, "Failed to open %s: %m", "/sys/kernel/config/nvmet/subsystems");
_cleanup_close_ int subsystem_fd = -EBADF;
subsystem_fd = open_mkdir_at(subsystems_fd, j, O_EXCL|O_RDONLY|O_CLOEXEC, 0777);
@@ -635,7 +635,7 @@ static int nvme_port_add(const char *name, int ip_family, NvmePort **ret) {
_cleanup_close_ int ports_fd = -EBADF;
ports_fd = RET_NERRNO(open("/sys/kernel/config/nvmet/ports", O_DIRECTORY|O_RDONLY|O_CLOEXEC));
if (ports_fd < 0)
return log_error_errno(ports_fd, "Failed to open /sys/kernel/config/nvmet/ports: %m");
return log_error_errno(ports_fd, "Failed to open %s: %m", "/sys/kernel/config/nvmet/ports");
_cleanup_close_ int port_fd = -EBADF;
uint16_t portnr = calculate_start_port(name, ip_family);
+1 -1
View File
@@ -382,7 +382,7 @@ TEST(umount_recursive) {
/* Open /p/s/m file before we unmount everything (which might include /proc/) */
f = fopen("/proc/self/mountinfo", "re");
if (!f) {
log_error_errno(errno, "Failed to open /proc/self/mountinfo: %m");
log_error_errno(errno, "Failed to open %s: %m", "/proc/self/mountinfo");
_exit(EXIT_FAILURE);
}
+1 -1
View File
@@ -466,7 +466,7 @@ static int load_unix_sockets(Context *c) {
f = fopen("/proc/net/unix", "re");
if (!f)
return log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, errno,
"Failed to open /proc/net/unix, ignoring: %m");
"Failed to open %s, ignoring: %m", "/proc/net/unix");
/* Skip header */
r = read_line(f, LONG_LINE_MAX, NULL);
+1 -1
View File
@@ -43,7 +43,7 @@ static int builtin_btrfs(UdevEvent *event, int argc, char *argv[]) {
return 0;
}
return log_device_debug_errno(dev, errno, "Failed to open /dev/btrfs-control: %m");
return log_device_debug_errno(dev, errno, "Failed to open %s: %m", "/dev/btrfs-control");
}
struct btrfs_ioctl_vol_args args = {};
+2 -2
View File
@@ -415,7 +415,7 @@ static int udev_watch_clear_by_wd(sd_device *dev, int dirfd, int wd) {
if (dirfd < 0) {
dirfd_close = RET_NERRNO(open("/run/udev/watch/", O_CLOEXEC | O_DIRECTORY | O_NOFOLLOW | O_RDONLY));
if (dirfd_close < 0)
return log_device_debug_errno(dev, dirfd_close, "Failed to open '/run/udev/watch/': %m");
return log_device_debug_errno(dev, dirfd_close, "Failed to open %s: %m", "/run/udev/watch/");
dirfd = dirfd_close;
}
@@ -595,7 +595,7 @@ int manager_remove_watch(Manager *manager, sd_device *dev) {
if (dirfd == -ENOENT)
return 0;
if (dirfd < 0)
return log_device_debug_errno(dev, dirfd, "Failed to open '/run/udev/watch/': %m");
return log_device_debug_errno(dev, dirfd, "Failed to open %s: %m", "/run/udev/watch/");
/* First, clear symlinks. */
r = udev_watch_clear(dev, dirfd, &wd);
+2 -2
View File
@@ -1040,7 +1040,7 @@ static int display_services(int argc, char *argv[], void *userdata) {
return 0;
}
return log_error_errno(errno, "Failed to open /run/systemd/userdb/: %m");
return log_error_errno(errno, "Failed to open %s: %m", "/run/systemd/userdb/");
}
t = table_new("service", "listening");
@@ -1461,7 +1461,7 @@ static int load_credentials(int argc, char *argv[], void *userdata) {
/* xopen_flags= */ XO_LABEL,
/* mode= */ 0755);
if (userdb_dir_fd < 0)
return log_error_errno(userdb_dir_fd, "Failed to open '/etc/userdb/': %m");
return log_error_errno(userdb_dir_fd, "Failed to open %s: %m", "/etc/userdb/");
FOREACH_ARRAY(i, des->entries, des->n_entries) {
struct dirent *de = *i;