diff options
author | Jan Janssen <medhefgo@web.de> | 2022-08-31 13:18:53 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-01 00:55:37 +0900 |
commit | 3a4e4ffacedf3ba5755547fd54b100b77bdec4a6 (patch) | |
tree | 3f680590462eb2b4c5b7bc33ff493300a1455faf | |
parent | 18f806b8d9597c6a7b590984e3c65d5fd9cb56b0 (diff) | |
download | systemd-3a4e4ffacedf3ba5755547fd54b100b77bdec4a6.tar.gz |
tree-wide: Use devnum helpers in a few more places
-rw-r--r-- | src/libudev/test-libudev.c | 3 | ||||
-rw-r--r-- | src/login/pam_systemd.c | 3 | ||||
-rw-r--r-- | src/shared/watchdog.c | 3 | ||||
-rw-r--r-- | src/udev/scsi_id/scsi_serial.c | 4 |
4 files changed, 8 insertions, 5 deletions
diff --git a/src/libudev/test-libudev.c b/src/libudev/test-libudev.c index b4526debf0..94d34b1ae2 100644 --- a/src/libudev/test-libudev.c +++ b/src/libudev/test-libudev.c @@ -6,6 +6,7 @@ #include <unistd.h> #include "alloc-util.h" +#include "devnum-util.h" #include "fd-util.h" #include "libudev-list-internal.h" #include "libudev-util.h" @@ -128,7 +129,7 @@ static void test_device_devnum(struct udev *udev) { dev_t devnum = makedev(1, 3); _cleanup_(udev_device_unrefp) struct udev_device *device; - log_info("/* %s, device %u:%u */", __func__, major(devnum), minor(devnum)); + log_info("/* %s, device " DEVNUM_FORMAT_STR " */", __func__, DEVNUM_FORMAT_VAL(devnum)); device = udev_device_new_from_devnum(udev, 'c', devnum); if (device) diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c index ba8ee51ff6..faaf6c9a69 100644 --- a/src/login/pam_systemd.c +++ b/src/login/pam_systemd.c @@ -22,6 +22,7 @@ #include "bus-internal.h" #include "bus-locator.h" #include "cgroup-setup.h" +#include "devnum-util.h" #include "errno-util.h" #include "fd-util.h" #include "fileio.h" @@ -278,7 +279,7 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_ if (r < 0) return r; - if (asprintf(&sys_path, "/sys/dev/char/%u:%u", major(display_ctty), minor(display_ctty)) < 0) + if (asprintf(&sys_path, "/sys/dev/char/" DEVNUM_FORMAT_STR, DEVNUM_FORMAT_VAL(display_ctty)) < 0) return -ENOMEM; r = readlink_value(sys_path, &tty); if (r < 0) diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c index 48186134aa..2a3c299ccb 100644 --- a/src/shared/watchdog.c +++ b/src/shared/watchdog.c @@ -7,6 +7,7 @@ #include <unistd.h> #include <linux/watchdog.h> +#include "devnum-util.h" #include "errno-util.h" #include "fd-util.h" #include "fileio.h" @@ -52,7 +53,7 @@ static int get_watchdog_sysfs_path(const char *filename, char **ret_path) { if (!S_ISCHR(st.st_mode)) return -EBADF; - if (asprintf(ret_path, "/sys/dev/char/%u:%u/%s", major(st.st_rdev), minor(st.st_rdev), filename) < 0) + if (asprintf(ret_path, "/sys/dev/char/"DEVNUM_FORMAT_STR"/%s", DEVNUM_FORMAT_VAL(st.st_rdev), filename) < 0) return -ENOMEM; return 0; diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c index 47c2a5cb4f..60e2b40c27 100644 --- a/src/udev/scsi_id/scsi_serial.c +++ b/src/udev/scsi_id/scsi_serial.c @@ -20,6 +20,7 @@ #include <time.h> #include <unistd.h> +#include "devnum-util.h" #include "memory-util.h" #include "random-util.h" #include "scsi.h" @@ -761,8 +762,7 @@ int scsi_std_inquiry(struct scsi_id_device *dev_scsi, const char *devname) { err = 2; goto out; } - sprintf(dev_scsi->kernel,"%u:%u", major(statbuf.st_rdev), - minor(statbuf.st_rdev)); + format_devnum(statbuf.st_rdev, dev_scsi->kernel); memzero(buf, SCSI_INQ_BUFF_LEN); err = scsi_inquiry(dev_scsi, fd, 0, 0, buf, SCSI_INQ_BUFF_LEN); |