diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 9c247977215e..b6c09017272d 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #undef _KERNEL #include #include @@ -885,11 +886,12 @@ socktrans(struct socket *sock, int i) dev_t dev2udev(struct cdev *dev) { + struct cdev_priv priv; struct cdev si; - if (KVM_READ(dev, &si, sizeof si)) { - /* XXX: FIXME! */ - return 0; + if (KVM_READ(dev, &si, sizeof si) && + KVM_READ(si.si_priv, &priv, sizeof priv)) { + return ((dev_t)priv.cdp_inode); } else { dprintf(stderr, "can't convert cdev *%p to a dev_t\n", dev); return -1;