diff options
author | csjp <csjp@FreeBSD.org> | 2005-07-30 20:00:13 +0000 |
---|---|---|
committer | csjp <csjp@FreeBSD.org> | 2005-07-30 20:00:13 +0000 |
commit | b60aee4f022344be1ec074c95877240bd8b4f986 (patch) | |
tree | 130b6c8ef3be6ef9d9b0d0dfdad58ced0129525f /usr.bin | |
parent | 8f4d20c60fa641217d72f71d1059b1b8857dcdab (diff) | |
download | FreeBSD-src-b60aee4f022344be1ec074c95877240bd8b4f986.zip FreeBSD-src-b60aee4f022344be1ec074c95877240bd8b4f986.tar.gz |
Introduce kdevtoname, which when given the kernel address of a
cdev structure, returns the device name associated with it through
the __si_namebuf member. This un-breaks the processing of devices.
This is a RELENG_6 candidate.
Reviewed by: phk
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/fstat/fstat.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index b835a93..9c24797 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -154,7 +154,7 @@ void socktrans(struct socket *sock, int i); void getinetproto(int number); int getfname(const char *filename); void usage(void); - +char *kdevtoname(struct cdev *dev); int main(int argc, char **argv) @@ -472,6 +472,16 @@ dommap(struct kinfo_proc *kp) } } +char * +kdevtoname(struct cdev *dev) +{ + struct cdev si; + + if (!KVM_READ(dev, &si, sizeof si)) + return (NULL); + return (strdup(si.__si_namebuf)); +} + void vtrans(struct vnode *vp, int i, int flag) { @@ -555,11 +565,13 @@ vtrans(struct vnode *vp, int i, int flag) case VCHR: { char *name; - if (nflg || ((name = devname(fst.rdev, vn.v_type == VCHR ? - S_IFCHR : S_IFBLK)) == NULL)) + name = kdevtoname(vn.v_rdev); + if (nflg || !name) printf(" %2d,%-2d", major(fst.rdev), minor(fst.rdev)); - else + else { printf(" %6s", name); + free(name); + } break; } default: |