Skip to content

bug: block device capacity defaults to amount of free space in /dev #1138

@lukenels

Description

@lukenels

When using a block device with FileDeviceBuilder, the capacity defaults to the amount of free space in the parent directory of the device (typically /dev) rather than the capacity of the device itself.

For example, I have a 950GB block device at /dev/nvme3n1:

$ blockdev --getsize64 /dev/nvme3n1
950000000000

But because of the logic to query the free space in the parent directory, the capacity defaults to ~3.3MB (the amount of free space in devtmpfs on this host):

let device = FileDeviceBuilder::new("/dev/nvme3n1").build().unwrap();
// Prints "capacity = 3354624"
println!("capacity = {}", device.capacity());

For block devices, the default device capacity could be computed instead via the file size (or, on Linux, using the BLKGETSIZE64 ioctl).


rustc 1.89.0
foyer 0.19.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions