From owner-freebsd-bugs Sat Jun 10 12:50: 8 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 65CDF37BFD5 for ; Sat, 10 Jun 2000 12:50:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id MAA40571; Sat, 10 Jun 2000 12:50:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from teapot.egroups.net (teapot.egroups.net [63.204.207.250]) by hub.freebsd.org (Postfix) with SMTP id 6933D37BEFE for ; Sat, 10 Jun 2000 12:46:10 -0700 (PDT) (envelope-from kbyanc@teapot.egroups.com) Received: (qmail 11822 invoked from network); 10 Jun 2000 19:46:17 -0000 Received: (QMFILT: 1.0); 10 Jun 2000 20:46:17 -0000 Received: from dhcp147.corp.onelist.com (HELO kbyanc.corp.ONElist.com) (192.168.10.147) by teapot.egroups.net with SMTP; 10 Jun 2000 19:46:16 -0000 Received: (from kbyanc@localhost) by kbyanc.corp.ONElist.com (8.9.3/8.9.3) id MAA90958; Sat, 10 Jun 2000 12:46:09 -0700 (PDT) (envelope-from kbyanc@teapot.egroups.com) Message-Id: <200006101946.MAA90958@kbyanc.corp.ONElist.com> Date: Sat, 10 Jun 2000 12:46:09 -0700 (PDT) From: kbyanc@posi.net Reply-To: kbyanc@posi.net To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/19179: patch to fix display of dev_t's in sysctl(8) Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 19179 >Category: bin >Synopsis: patch to fix display of dev_t's in sysctl(8) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jun 10 12:50:01 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Kelly Yancey >Release: FreeBSD 4.0-STABLE i386 >Organization: eGroups.com -- http://www.eGroups.com/ >Environment: FreeBSD backroom.corp.ONElist.com 5.0-CURRENT FreeBSD 5.0-CURRENT #3: Sat Jun 10 12:08:26 PDT 2000 kbyanc@backroom.corp.ONElist.com:/usr/src/sys/compile/BACKROOM i386 >Description: Sysctl(8) attempts to display devices in human-readable format using major/minor numbers. However, the kernel uses all ones to indicate 'no device' (i.e. kern.dumpdev if no dump device is configured for crash dumps). Currently sysctl has no knowledge of this and displays a nonsensicle device number. Similarly, sysctl uses the minor() macro to get the minor device number from a dev_t. However, minor returns a 'cookie' that may have it's high bit set. In which case, sysctl currently displays a negative value for the minor number. This patch fixes sysctl to display the major/minor numbers the same way they are in ls(1), switching to hexidecimal when the minor cookie looks more like a cookie than a recognizable minor number. It also teaches sysctl(8) about the special case where dev_t is all ones. Note to committer: while you are reviewing this, please also review PR kern/15251 (assuming it is still not closed). It adds comprehensive unsigned sysctl support to the kernel and teaches sysctl(8) how to display unsigned sysctl values. Thanks. -Kelly kbyanc@posi.net >How-To-Repeat: sysctl -a | grep dev >Fix: --- sysctl.c.orig Sat Jun 10 12:33:57 2000 +++ sysctl.c Sat Jun 10 12:37:51 2000 @@ -270,8 +270,14 @@ dev_t *d = (dev_t *)p; if (l2 != sizeof *d) err(1, "T_dev_T %d != %d", l2, sizeof *d); - printf("{ major = %d, minor = %d }", - major(*d), minor(*d)); + if ((int)(*d) != -1) { + if (minor(*d) > 255 || minor(*d) < 0) + printf("{ major = %d, minor = 0x%x }", + major(*d), minor(*d)); + else + printf("{ major = %d, minor = %d }", + major(*d), minor(*d)); + } return (0); } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message