From dzs@paris.fx.org  Sat Oct 29 23:00:55 2005
Return-Path: <dzs@paris.fx.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A4E5016A42A
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 29 Oct 2005 23:00:55 +0000 (GMT)
	(envelope-from dzs@paris.fx.org)
Received: from paris.fx.org (dsl081-037-111.lax1.dsl.speakeasy.net [64.81.37.111])
	by mx1.FreeBSD.org (Postfix) with SMTP id 8A2ED43D58
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 29 Oct 2005 23:00:54 +0000 (GMT)
	(envelope-from dzs@paris.fx.org)
Received: (qmail 11566 invoked by uid 1001); 29 Oct 2005 16:00:53 -0700
Message-Id: <20051029230053.11565.qmail@paris.fx.org>
Date: 29 Oct 2005 16:00:53 -0700
From: doug steinwand <dzs-pr@fx.org>
Reply-To: doug steinwand <dzs-pr@fx.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: fstat(1) does not show correct device numbers
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         88203
>Category:       bin
>Synopsis:       [patch] fstat(1) does not show correct device numbers
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    csjp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 29 23:10:14 GMT 2005
>Closed-Date:    Wed Nov 30 02:33:32 GMT 2005
>Last-Modified:  Wed Nov 30 02:33:32 GMT 2005
>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@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:
Responsible-Changed-From-To: freebsd-bugs->csjp 
Responsible-Changed-By: csjp 
Responsible-Changed-When: Sat Nov 5 23:43:18 GMT 2005 
Responsible-Changed-Why:  
I'll take ownership of this PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=88203 
State-Changed-From-To: open->patched 
State-Changed-By: csjp 
State-Changed-When: Sat Nov 5 23:43:57 GMT 2005 
State-Changed-Why:  
Patched, thanks! 


http://www.freebsd.org/cgi/query-pr.cgi?pr=88203 
State-Changed-From-To: patched->closed 
State-Changed-By: csjp 
State-Changed-When: Wed Nov 30 02:33:01 GMT 2005 
State-Changed-Why:  
This has been fixed and merged into all the relevant 
-STABLE branches 

http://www.freebsd.org/cgi/query-pr.cgi?pr=88203 
>Unformatted:
