mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-13 16:17:08 +00:00
btrfs-progs: add fd version of device_get_partition_size
The helper wraps a raw ioctl but some users may already have the fd and not necessarily the path. Add a suitable helper for convenience. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
6a78c16e98
commit
f6c30640bc
@ -288,6 +288,16 @@ u64 btrfs_device_size(int fd, struct stat *st)
|
||||
/*
|
||||
* Read partition size using the low-level ioctl
|
||||
*/
|
||||
u64 device_get_partition_size_fd(int fd)
|
||||
{
|
||||
u64 result;
|
||||
|
||||
if (ioctl(fd, BLKGETSIZE64, &result) < 0)
|
||||
return 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
u64 device_get_partition_size(const char *dev)
|
||||
{
|
||||
u64 result;
|
||||
|
@ -34,6 +34,7 @@
|
||||
int device_discard_blocks(int fd, u64 start, u64 len);
|
||||
int device_zero_blocks(int fd, off_t start, size_t len);
|
||||
u64 device_get_partition_size(const char *dev);
|
||||
u64 device_get_partition_size_fd(int fd);
|
||||
int device_get_queue_param(const char *file, const char *param, char *buf, size_t len);
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user