summaryrefslogtreecommitdiffstats
path: root/src/shared/loop-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-01-17 20:12:30 +0100
committerLennart Poettering <lennart@poettering.net>2023-01-18 10:10:57 +0100
commit65046b92dcdc017f34e170a0e0f46ffc80b1dcdc (patch)
tree670daa4a8cecb1097af20bd199eee8bf625f0b04 /src/shared/loop-util.c
parentMerge pull request #26044 from DaanDeMeyer/repart-sector-size (diff)
downloadsystemd-65046b92dcdc017f34e170a0e0f46ffc80b1dcdc.tar.xz
systemd-65046b92dcdc017f34e170a0e0f46ffc80b1dcdc.zip
blockdev-util: add simple wrapper around BLKSSZGET
Just adds some typesafety and generates an error if the field is not initialized in the block device yet.
Diffstat (limited to 'src/shared/loop-util.c')
-rw-r--r--src/shared/loop-util.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c
index 3224286186..4b63e0340b 100644
--- a/src/shared/loop-util.c
+++ b/src/shared/loop-util.c
@@ -125,14 +125,14 @@ static int loop_configure_verify(int fd, const struct loop_config *c) {
assert(c);
if (c->block_size != 0) {
- int z;
+ uint32_t ssz;
- if (ioctl(fd, BLKSSZGET, &z) < 0)
- return -errno;
+ r = blockdev_get_sector_size(fd, &ssz);
+ if (r < 0)
+ return r;
- assert(z >= 0);
- if ((uint32_t) z != c->block_size)
- log_debug("LOOP_CONFIGURE didn't honour requested block size %u, got %i instead. Ignoring.", c->block_size, z);
+ if (ssz != c->block_size)
+ log_debug("LOOP_CONFIGURE didn't honour requested block size %" PRIu32 ", got %" PRIu32 " instead. Ignoring.", c->block_size, ssz);
}
if (c->info.lo_sizelimit != 0) {