On Sun, Feb 3, 2019 at 11:56 PM Stefan Hajnoczi <stefanha(a)redhat.com> wrote:
How can userspace applications query the size of devdax character
stat(1) doesn't know how large the device is:
# stat /dev/dax0.0
Size: 0 Blocks: 0 IO Block: 4096 character special file
Device: 6h/6d Inode: 56764 Links: 1 Device type: fa,d
ndctl(1) finds out by digging in /sys:
# ndctl list
I'm not sure how to do it without enumerating all nvdimms in /sys. Is
there a mapping from devdax major/minor number to a /sys path?
The use case I have in mind is that QEMU currently takes the size as a
command-line parameter. The failure mode is ugly when users get this
value wrong: the guest gets a softlockup and there is no error message
on the host side.
I'd like QEMU to detect the size or at least reject size values that are
too large. In order to do that userspace needs a convenient way of
querying the size. Any ideas?
You're looking for /sys/dev/char. That will wake you from major:minor
to sysfs. Perhaps borrow fio's implementation for the same: