blockdev-util: add new helper blockdev_get_device_size()
This function is just a wrapper around the BLKGETSIZE64. Which is a pretty simple ioctl. The only reason to wrap it, is that the headers we need to call it are a bit messy (as "linux/fs.h" is incompatible with certain glibc headers). Hence add the simple helper that wraps it and allows us to do the header mess needed in one file only. It's also nicely symmetric to blockdev_get_sector_size().
This commit is contained in:
@@ -1759,8 +1759,9 @@ static int fs_grow(const char *node_path, int mount_fd, const char *mount_path)
|
||||
if (node_fd < 0)
|
||||
return log_debug_errno(errno, "Failed to open node device %s: %m", node_path);
|
||||
|
||||
if (ioctl(node_fd, BLKGETSIZE64, &size) != 0)
|
||||
return log_debug_errno(errno, "Failed to get block device size of %s: %m", node_path);
|
||||
r = blockdev_get_device_size(node_fd, &size);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to get block device size of %s: %m", node_path);
|
||||
|
||||
if (mount_fd < 0) {
|
||||
assert(mount_path);
|
||||
|
||||
Reference in New Issue
Block a user