From 30c1cded77b8b0456c8793a7b3ce0ffe00a798ff Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 3 Jan 2024 05:07:40 +0900 Subject: [PATCH 1/2] storagetm: always hash stat.st_mode To make the hash function consistent with the compare function. --- src/storagetm/storagetm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/storagetm/storagetm.c b/src/storagetm/storagetm.c index b28924a8b4..c8948ec038 100644 --- a/src/storagetm/storagetm.c +++ b/src/storagetm/storagetm.c @@ -788,9 +788,10 @@ typedef struct Context { static void device_hash_func(const struct stat *q, struct siphash *state) { assert(q); + mode_t m = q->st_mode & S_IFMT; + siphash24_compress_typesafe(m, state); + if (S_ISBLK(q->st_mode) || S_ISCHR(q->st_mode)) { - mode_t m = q->st_mode & S_IFMT; - siphash24_compress_typesafe(m, state); siphash24_compress_typesafe(q->st_rdev, state); return; } From 69f4a87c8c015d356de419aea1bfe54232e15244 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 3 Jan 2024 05:19:00 +0900 Subject: [PATCH 2/2] storagetm: fix use of wrong stat element --- src/storagetm/storagetm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storagetm/storagetm.c b/src/storagetm/storagetm.c index c8948ec038..1ab2260ce0 100644 --- a/src/storagetm/storagetm.c +++ b/src/storagetm/storagetm.c @@ -381,7 +381,7 @@ static int nvme_subsystem_add(const char *node, int consumed_fd, sd_device *devi return log_error_errno(errno, "Failed to fstat '%s': %m", node); if (S_ISBLK(st.st_mode)) { if (!device) { - r = sd_device_new_from_devnum(&allocated_device, 'b', st.st_dev); + r = sd_device_new_from_devnum(&allocated_device, 'b', st.st_rdev); if (r < 0) return log_error_errno(r, "Failed to get device information for device '%s': %m", node);