Date: Sat, 10 Jun 2000 12:46:09 -0700 (PDT) From: kbyanc@posi.net To: FreeBSD-gnats-submit@freebsd.org Subject: bin/19179: patch to fix display of dev_t's in sysctl(8) Message-ID: <200006101946.MAA90958@kbyanc.corp.ONElist.com>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200006101946.MAA90958>