summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-04-21 12:34:37 +0200
committerLennart Poettering <lennart@poettering.net>2023-04-21 12:41:15 +0200
commit67458536afcdceb25b63b8367837ab5402f3983e (patch)
tree151dd10f3a6ea5766ce393594e0d09c0a6739d1f /src
parent21453b8b4bfb4d1fa3efd1df3fe1208d48cbd41b (diff)
downloadsystemd-67458536afcdceb25b63b8367837ab5402f3983e.tar.gz
tree-wide: convert more cases do DEVNUM_FORMAT_STR()/DEVNUM_FORMAT_VAL()
Let's use our nice macros a bit more. (Not comprehensive)
Diffstat (limited to 'src')
-rw-r--r--src/journal/journalctl.c5
-rw-r--r--src/libsystemd/sd-device/sd-device.c6
-rw-r--r--src/login/logind-session.c2
-rw-r--r--src/shutdown/umount.c5
4 files changed, 10 insertions, 8 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 5c07caa8f3..12119b302c 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -26,6 +26,7 @@
#include "chase.h"
#include "chattr-util.h"
#include "constants.h"
+#include "devnum-util.h"
#include "dissect-image.h"
#include "fd-util.h"
#include "fileio.h"
@@ -194,7 +195,7 @@ static int add_matches_for_device(sd_journal *j, const char *devpath) {
r = sd_device_new_from_stat_rdev(&device, &st);
if (r < 0)
- return log_error_errno(r, "Failed to get device from devnum %u:%u: %m", major(st.st_rdev), minor(st.st_rdev));
+ return log_error_errno(r, "Failed to get device from devnum " DEVNUM_FORMAT_STR ": %m", DEVNUM_FORMAT_VAL(st.st_rdev));
for (d = device; d; ) {
_cleanup_free_ char *match = NULL;
@@ -224,7 +225,7 @@ static int add_matches_for_device(sd_journal *j, const char *devpath) {
if (r < 0)
return log_error_errno(r, "Failed to stat() device node \"%s\": %m", devnode);
- r = asprintf(&match1, "_KERNEL_DEVICE=%c%u:%u", S_ISBLK(st.st_mode) ? 'b' : 'c', major(st.st_rdev), minor(st.st_rdev));
+ r = asprintf(&match1, "_KERNEL_DEVICE=%c" DEVNUM_FORMAT_STR, S_ISBLK(st.st_mode) ? 'b' : 'c', DEVNUM_FORMAT_VAL(st.st_rdev));
if (r < 0)
return log_oom();
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index e2eac651bd..2c7b97ab4d 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -301,7 +301,7 @@ int device_new_from_mode_and_devnum(sd_device **ret, mode_t mode, dev_t devnum)
if (major(devnum) == 0)
return -ENODEV;
- if (asprintf(&syspath, "/sys/dev/%s/%u:%u", t, major(devnum), minor(devnum)) < 0)
+ if (asprintf(&syspath, "/sys/dev/%s/" DEVNUM_FORMAT_STR, t, DEVNUM_FORMAT_VAL(devnum)) < 0)
return -ENOMEM;
r = sd_device_new_from_syspath(&dev, syspath);
@@ -1654,9 +1654,9 @@ int device_get_device_id(sd_device *device, const char **ret) {
if (sd_device_get_devnum(device, &devnum) >= 0) {
/* use dev_t — b259:131072, c254:0 */
- if (asprintf(&id, "%c%u:%u",
+ if (asprintf(&id, "%c" DEVNUM_FORMAT_STR,
streq(subsystem, "block") ? 'b' : 'c',
- major(devnum), minor(devnum)) < 0)
+ DEVNUM_FORMAT_VAL(devnum)) < 0)
return -ENOMEM;
} else if (sd_device_get_ifindex(device, &ifindex) >= 0) {
/* use netdev ifindex — n3 */
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 1daa102071..e7c917cdee 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -197,7 +197,7 @@ static void session_save_devices(Session *s, FILE *f) {
if (!hashmap_isempty(s->devices)) {
fprintf(f, "DEVICES=");
HASHMAP_FOREACH(sd, s->devices)
- fprintf(f, "%u:%u ", major(sd->dev), minor(sd->dev));
+ fprintf(f, DEVNUM_FORMAT_STR " ", DEVNUM_FORMAT_VAL(sd->dev));
fprintf(f, "\n");
}
}
diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c
index ebd5a754c5..93e082d77e 100644
--- a/src/shutdown/umount.c
+++ b/src/shutdown/umount.c
@@ -26,6 +26,7 @@
#include "chase.h"
#include "constants.h"
#include "device-util.h"
+#include "devnum-util.h"
#include "dirent-util.h"
#include "escape.h"
#include "fd-util.h"
@@ -890,7 +891,7 @@ static int dm_points_list_detach(MountPoint **head, bool *changed, bool last_try
continue;
}
- log_info("Detaching DM %s (%u:%u).", m->path, major(m->devnum), minor(m->devnum));
+ log_info("Detaching DM %s (" DEVNUM_FORMAT_STR ").", m->path, DEVNUM_FORMAT_VAL(m->devnum));
r = delete_dm(m);
if (r < 0) {
log_full_errno(last_try ? LOG_ERR : LOG_INFO, r, "Could not detach DM %s: %m", m->path);
@@ -920,7 +921,7 @@ static int md_points_list_detach(MountPoint **head, bool *changed, bool last_try
continue;
}
- log_info("Stopping MD %s (%u:%u).", m->path, major(m->devnum), minor(m->devnum));
+ log_info("Stopping MD %s (" DEVNUM_FORMAT_STR ").", m->path, DEVNUM_FORMAT_VAL(m->devnum));
r = delete_md(m);
if (r < 0) {
log_full_errno(last_try ? LOG_ERR : LOG_INFO, r, "Could not stop MD %s: %m", m->path);