mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-28 00:52:17 +00:00
btrfs-progs: use btrfs_device_size() instead of device_get_partition_size_fd()
device_get_partition_size_fd() fails if we pass a regular file. This can happen when trying to create an emulated zoned filesystem on a regular file. Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
7ce3ae3966
commit
585ac14d1a
@ -267,6 +267,7 @@ static int report_zones(int fd, const char *file,
|
||||
u64 zone_bytes = zone_size(file);
|
||||
size_t rep_size;
|
||||
u64 sector = 0;
|
||||
struct stat st;
|
||||
struct blk_zone_report *rep;
|
||||
struct blk_zone *zone;
|
||||
unsigned int i, n = 0;
|
||||
@ -291,11 +292,13 @@ static int report_zones(int fd, const char *file,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* No need to use btrfs_device_size() here, since it is ensured
|
||||
* that the file is block device.
|
||||
*/
|
||||
device_size = device_get_partition_size_fd(fd);
|
||||
ret = fstat(fd, &st);
|
||||
if (ret < 0) {
|
||||
error("error when reading zone info on %s: %m", file);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
device_size = btrfs_device_size(fd, &st);
|
||||
if (device_size == 0) {
|
||||
error("zoned: failed to read size of %s: %m", file);
|
||||
exit(1);
|
||||
|
Loading…
Reference in New Issue
Block a user