mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-23 15:35:18 +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
2cfd248ddf
commit
600d2dba6f
@ -289,6 +289,16 @@ u64 btrfs_device_size(int fd, struct stat *st)
|
|||||||
/*
|
/*
|
||||||
* Read partition size using the low-level ioctl
|
* 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 device_get_partition_size(const char *dev)
|
||||||
{
|
{
|
||||||
u64 result;
|
u64 result;
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
int device_discard_blocks(int fd, u64 start, u64 len);
|
int device_discard_blocks(int fd, u64 start, u64 len);
|
||||||
int device_zero_blocks(int fd, off_t start, size_t 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(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);
|
int device_get_queue_param(const char *file, const char *param, char *buf, size_t len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user