mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
tree-wide: convert more cases do DEVNUM_FORMAT_STR()/DEVNUM_FORMAT_VAL()
Let's use our nice macros a bit more. (Not comprehensive)
This commit is contained in:
parent
21453b8b4b
commit
67458536af
@ -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();
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user