Date: Sat, 23 Oct 2010 19:56:05 -0700 From: Garrett Cooper <gcooper@FreeBSD.org> To: Alexander Best <arundel@freebsd.org> Cc: freebsd-hackers@freebsd.org Subject: Re: fix pnpinfo on arch=amd64 Message-ID: <AANLkTinzn1r3qn3d7MoVhZPNOo6OHDfF-0KVrLN%2BC516@mail.gmail.com> In-Reply-To: <20101024002248.GA73346@freebsd.org> References: <20101024002248.GA73346@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Sat, Oct 23, 2010 at 5:22 PM, Alexander Best <arundel@freebsd.org> wrote:
> this tiny patch will fix pnpinfo so it doesn't core dump (bus error) any
> longer on arch=amd64.
1. I had to modify the Makefile to get it to work.
2. FWIW, I don't there's really much point in adding a check for only
x86 architectures, if the tool is capable of more than that.
3. Might as well close the file descriptor after opening it.
SIGBUS occurs because it doesn't have permission to write via outb.
It's a shame that there isn't a more proper way to catch this SIGBUS
fault minus adding a SIGBUS handler (but that might have other
undesired side effects).
Thanks,
-Garrett
[-- Attachment #2 --]
Index: contrib/pnpinfo/pnpinfo.c
===================================================================
--- contrib/pnpinfo/pnpinfo.c (revision 214169)
+++ contrib/pnpinfo/pnpinfo.c (working copy)
@@ -506,7 +506,7 @@
} else {
/* Handle large resouce data types */
u_char buf[2];
- if (!get_resource_info((char *)buf, 2))
+ if (!get_resource_info(buf, 2))
break;
large_len = (buf[1] << 8) + buf[0];
@@ -586,13 +586,13 @@
int
main(int argc, char **argv)
{
+ int fd;
int num_pnp_devs;
-#ifdef __i386__
/* Hey what about a i386_iopl() call :) */
- if (open("/dev/io", O_RDONLY) < 0)
- errx(1, "can't get I/O privilege");
-#endif
+ if ((fd = open("/dev/io", O_RDONLY)) < 0)
+ err(1, "can't get I/O privileges");
+ (void) close(fd);
printf("Checking for Plug-n-Play devices...\n");
Index: contrib/pnpinfo/Makefile
===================================================================
--- contrib/pnpinfo/Makefile (revision 214169)
+++ contrib/pnpinfo/Makefile (working copy)
@@ -2,6 +2,6 @@
PROG= pnpinfo
MAN8= pnpinfo.8
-CFLAGS= -Wall
+CFLAGS= -Wall -I${.CURDIR}/../../sys
.include <bsd.prog.mk>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinzn1r3qn3d7MoVhZPNOo6OHDfF-0KVrLN%2BC516>
