mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
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 is contained in:
parent
ef9cbd91d0
commit
d09e66be12
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=226157
|
@ -100,7 +100,7 @@ void ktrsockaddr(struct sockaddr *);
|
|||
void ktrstat(struct stat *);
|
||||
void ktrstruct(char *, size_t);
|
||||
void usage(void);
|
||||
const char *ioctlname(u_long);
|
||||
void ioctlname(unsigned long, int);
|
||||
|
||||
int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata,
|
||||
resolv = 0, abiflag = 0;
|
||||
|
@ -504,14 +504,8 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags)
|
|||
case SYS_ioctl: {
|
||||
const char *cp;
|
||||
print_number(ip, narg, c);
|
||||
if ((cp = ioctlname(*ip)) != NULL)
|
||||
printf(",%s", cp);
|
||||
else {
|
||||
if (decimal)
|
||||
printf(",%jd", (intmax_t)*ip);
|
||||
else
|
||||
printf(",%#jx ", (intmax_t)*ip);
|
||||
}
|
||||
putchar(c);
|
||||
ioctlname(*ip, decimal);
|
||||
c = ',';
|
||||
ip++;
|
||||
narg--;
|
||||
|
|
|
@ -4,15 +4,8 @@
|
|||
|
||||
set -e
|
||||
|
||||
if [ "x$1" = "x-s" ]; then
|
||||
use_switch=1
|
||||
shift
|
||||
else
|
||||
use_switch=0
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "usage: sh $0 [-s] include-dir"
|
||||
echo "usage: sh $0 include-dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -30,7 +23,7 @@ ioctl_includes=`
|
|||
|
||||
awk -v x="$ioctl_includes" 'BEGIN {print x}' |
|
||||
gcc -E -I$1 -dM -DCOMPAT_43TTY - |
|
||||
awk -v ioctl_includes="$ioctl_includes" -v use_switch="$use_switch" '
|
||||
awk -v ioctl_includes="$ioctl_includes" '
|
||||
BEGIN {
|
||||
print "/* XXX obnoxious prerequisites. */"
|
||||
print "#define COMPAT_43"
|
||||
|
@ -55,16 +48,15 @@ BEGIN {
|
|||
print "#include <stdio.h>"
|
||||
print "#include <cam/cam.h>"
|
||||
print ""
|
||||
print "const char *ioctlname(u_long val);"
|
||||
print "void ioctlname(unsigned long val, int decimal);"
|
||||
print ""
|
||||
print ioctl_includes
|
||||
print ""
|
||||
print "const char *"
|
||||
print "ioctlname(u_long val)"
|
||||
print "void"
|
||||
print "ioctlname(unsigned long val, int decimal)"
|
||||
print "{"
|
||||
print "\tconst char *str = NULL;"
|
||||
print ""
|
||||
if (use_switch)
|
||||
print "\tswitch(val) {"
|
||||
}
|
||||
|
||||
/^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
|
||||
|
@ -75,16 +67,20 @@ BEGIN {
|
|||
break;
|
||||
++i;
|
||||
#
|
||||
if (use_switch)
|
||||
printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
|
||||
else
|
||||
printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
|
||||
|
||||
print("\t");
|
||||
if (n++ > 0)
|
||||
print("else ");
|
||||
printf("if (val == %s)\n", $i);
|
||||
printf("\t\tstr = \"%s\";\n", $i);
|
||||
}
|
||||
END {
|
||||
if (use_switch)
|
||||
print "\t}"
|
||||
print "\n\treturn(NULL);"
|
||||
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 "}"
|
||||
}
|
||||
'
|
||||
|
|
Loading…
Reference in a new issue