bin/88203: fstat(1) does not show correct device numbers
doug steinwand
dzs-pr at fx.org
Sat Oct 29 16:10:16 PDT 2005
>Number: 88203
>Category: bin
>Synopsis: fstat(1) does not show correct device numbers
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Oct 29 23:10:14 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: dzs
>Release: FreeBSD 6.0-RC1 amd64
>Organization:
>Environment:
System: FreeBSD paris.fx.org 6.0-RC1 FreeBSD 6.0-RC1 #0: Fri Oct 28 22:55:08 PDT 2005 root at paris.fx.org:/usr/obj/usr/src/sys/HAWK amd64
>Description:
fstat(1) doesn't report correct device number in "-n" output
>How-To-Repeat:
notice that the output of:
% fstat -n
is showing device numbers of 0,0 when something else like 0,112 is expected (like in FreeBSD 5.x).
>Fix:
See included patch. The dev2udev() function in fstat.c is broken
--- fstat_1.patch begins here ---
--- usr.bin/fstat/fstat.c-orig Sat Aug 6 15:26:51 2005
+++ usr.bin/fstat/fstat.c Sat Oct 29 15:32:51 2005
@@ -68,6 +68,7 @@
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
#include <fs/devfs/devfs.h>
+#include <fs/devfs/devfs_int.h>
#undef _KERNEL
#include <nfs/nfsproto.h>
#include <nfs/rpcv2.h>
@@ -886,10 +887,11 @@
dev2udev(struct cdev *dev)
{
struct cdev si;
+ struct cdev_priv priv;
- 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;
--- fstat_1.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list