Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Oct 2011 01:52:11 -0700
From:      Garrett Cooper <yanegomi@gmail.com>
To:        Dag-Erling Smorgrav <des@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r226157 - head/usr.bin/kdump
Message-ID:  <CAGH67wSzP4HWeRZL6fU0r%2B4ipbG36jhYNdV3xMHfDOQXjy4jBQ@mail.gmail.com>
In-Reply-To: <201110081247.p98Cl06s063337@svn.freebsd.org>
References:  <201110081247.p98Cl06s063337@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Sat, Oct 8, 2011 at 5:47 AM, Dag-Erling Smorgrav <des@freebsd.org> wrote:
> Author: des
> Date: Sat Oct  8 12:47:00 2011
> New Revision: 226157
> URL: http://svn.freebsd.org/changeset/base/226157
>
> Log:
>  Bring ioctlname() in line with all the other *name() functions, which
>  actually print the name (or the numeric value, if they can't figure out
>  the correct name) instead of just returning a pointer to it.  Also, since
>  ioctl numbers are not and probably never will be unique, drop support for
>  using a switch statement instead of an if/else chain.

This commit broke truss by changing the ioctlname API signature. Example:

$ truss camcontrol devlist
# ...
Segmentation fault: 11 (core dumped)

Reason being is that truss uses ioctlname via an extern, so the
compiler doesn't note the difference (I assume because NO_WERROR= is
set in the Makefile) things go down in flames when it tries to print
out the ioctl call (dereferences a bad pointer with strdup)

This patch fixes it (with some minor Makefile cleanup), at the cost of
duplicating the mkioctls guts between kdump and truss (truss depended
on the old API signature).

Note: I did an `svn copy ../kdump/mkioctls .' beforehand in order to
bootstrap the svn history; that will need to be done before committing
my attached patch.

Thanks!
-Garrett

[-- Attachment #2 --]
Index: usr.bin/truss/mkioctls
===================================================================
--- usr.bin/truss/mkioctls	(working copy)
+++ usr.bin/truss/mkioctls	(working copy)
@@ -58,12 +58,12 @@
 	print "#include <stdio.h>"
 	print "#include <cam/cam.h>"
 	print ""
-	print "void ioctlname(unsigned long val, int decimal);"
+	print "const char	*ioctlname(unsigned long val);"
 	print ""
 	print ioctl_includes
 	print ""
-	print "void"
-	print "ioctlname(unsigned long val, int decimal)"
+	print "const char*"
+	print "ioctlname(unsigned long val)"
 	print "{"
 	print "\tconst char *str = NULL;"
 	print ""
@@ -85,12 +85,7 @@
 }
 END {
 	print "\n"
-	print "\tif (str != NULL)\n"
-	print "\t\tprintf(\"%s\", str);\n"
-	print "\telse if (decimal)\n"
-	print "\t\tprintf(\"%lu\", val);\n"
-	print "\telse\n"
-	print "\t\tprintf(\"%#lx\", val);\n"
+	print "\treturn (str);\n"
 	print "}"
 }
 '
Index: usr.bin/truss/extern.h
===================================================================
--- usr.bin/truss/extern.h	(revision 226524)
+++ usr.bin/truss/extern.h	(working copy)
@@ -35,7 +35,7 @@
 extern int start_tracing(int);
 extern void restore_proc(int);
 extern void waitevent(struct trussinfo *);
-extern const char *ioctlname(register_t val);
+const char *ioctlname(unsigned long val);
 extern char *strsig(int sig);
 #ifdef __amd64__
 extern void amd64_syscall_entry(struct trussinfo *, int);
Index: usr.bin/truss/Makefile
===================================================================
--- usr.bin/truss/Makefile	(revision 226524)
+++ usr.bin/truss/Makefile	(working copy)
@@ -11,7 +11,7 @@
 .endif
 
 CFLAGS+= -I${.CURDIR} -I.
-CLEANFILES= syscalls.master syscalls.h ioctl.c
+CLEANFILES= syscalls.master
 
 .SUFFIXES: .master
 
@@ -22,8 +22,8 @@
 	/bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh syscalls.master \
 		${.CURDIR}/i386.conf
 
-ioctl.c: ${.CURDIR}/../kdump/mkioctls
-	sh ${.CURDIR}/../kdump/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
+ioctl.c: ${.CURDIR}/mkioctls
+	sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
 
 .if ${MACHINE_CPUARCH} == "i386"
 SRCS+=	i386-linux.c linux_syscalls.h

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGH67wSzP4HWeRZL6fU0r%2B4ipbG36jhYNdV3xMHfDOQXjy4jBQ>