aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/kdump
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2011-10-12 21:45:12 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2011-10-12 21:45:12 +0000
commit81a31394221ea696e1602cec805fc34bf79bc803 (patch)
tree86652f3659e8237a0b70a537367850606fc00d80 /usr.bin/kdump
parent3cd6db794cc353b63465c278cd4bbe7f2b5e2381 (diff)
downloadsrc-81a31394221ea696e1602cec805fc34bf79bc803.tar.gz
src-81a31394221ea696e1602cec805fc34bf79bc803.zip
Notes
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r--usr.bin/kdump/Makefile4
-rw-r--r--usr.bin/kdump/kdump.c57
-rw-r--r--usr.bin/kdump/mkioctls11
3 files changed, 44 insertions, 28 deletions
diff --git a/usr.bin/kdump/Makefile b/usr.bin/kdump/Makefile
index e64aaa4587fb..ea2a604b196e 100644
--- a/usr.bin/kdump/Makefile
+++ b/usr.bin/kdump/Makefile
@@ -16,9 +16,9 @@ CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -I.
SRCS+= linux_syscalls.c
.endif
-WARNS?= 0
+NO_WERROR?= YES
-CLEANFILES= ioctl.c kdump_subr.c linux_syscalls.c
+CLEANFILES= ioctl.c kdump_subr.c kdump_subr.h linux_syscalls.c
ioctl.c: mkioctls
sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 8f2f4db73f08..45893df05eaa 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -95,6 +95,8 @@ void visdump(char *, int, int);
void ktrgenio(struct ktr_genio *, int);
void ktrpsig(struct ktr_psig *);
void ktrcsw(struct ktr_csw *);
+void ktruser_malloc(unsigned char *);
+void ktruser_rtld(int, unsigned char *);
void ktruser(int, unsigned char *);
void ktrsockaddr(struct sockaddr *);
void ktrstat(struct stat *);
@@ -508,7 +510,6 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags)
(flags == 0 || (flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) {
switch (ktr->ktr_code) {
case SYS_ioctl: {
- const char *cp;
print_number(ip, narg, c);
putchar(c);
ioctlname(*ip, decimal);
@@ -1334,7 +1335,7 @@ struct utrace_malloc {
};
void
-ktruser_malloc(int len, unsigned char *p)
+ktruser_malloc(unsigned char *p)
{
struct utrace_malloc *ut = (struct utrace_malloc *)p;
@@ -1358,7 +1359,7 @@ ktruser(int len, unsigned char *p)
}
if (len == sizeof(struct utrace_malloc)) {
- ktruser_malloc(len, p);
+ ktruser_malloc(p);
return;
}
@@ -1393,61 +1394,67 @@ ktrsockaddr(struct sockaddr *sa)
printf(", ");
#define check_sockaddr_len(n) \
- if (sa_##n->s##n##_len < sizeof(struct sockaddr_##n)) { \
+ if (sa_##n.s##n##_len < sizeof(struct sockaddr_##n)) { \
printf("invalid"); \
break; \
}
switch(sa->sa_family) {
case AF_INET: {
- struct sockaddr_in *sa_in;
+ struct sockaddr_in sa_in;
- sa_in = (struct sockaddr_in *)sa;
+ memset(&sa_in, 0, sizeof(sa_in));
+ memcpy(&sa_in, sa, sizeof(sa));
check_sockaddr_len(in);
- inet_ntop(AF_INET, &sa_in->sin_addr, addr, sizeof addr);
- printf("%s:%u", addr, ntohs(sa_in->sin_port));
+ inet_ntop(AF_INET, &sa_in.sin_addr, addr, sizeof addr);
+ printf("%s:%u", addr, ntohs(sa_in.sin_port));
break;
}
#ifdef NETATALK
case AF_APPLETALK: {
- struct sockaddr_at *sa_at;
+ struct sockaddr_at sa_at;
struct netrange *nr;
- sa_at = (struct sockaddr_at *)sa;
+ memset(&sa_at, 0, sizeof(sa_at));
+ memcpy(&sa_at, sa, sizeof(sa));
check_sockaddr_len(at);
- nr = &sa_at->sat_range.r_netrange;
- printf("%d.%d, %d-%d, %d", ntohs(sa_at->sat_addr.s_net),
- sa_at->sat_addr.s_node, ntohs(nr->nr_firstnet),
+ nr = &sa_at.sat_range.r_netrange;
+ printf("%d.%d, %d-%d, %d", ntohs(sa_at.sat_addr.s_net),
+ sa_at.sat_addr.s_node, ntohs(nr->nr_firstnet),
ntohs(nr->nr_lastnet), nr->nr_phase);
break;
}
#endif
case AF_INET6: {
- struct sockaddr_in6 *sa_in6;
+ struct sockaddr_in6 sa_in6;
- sa_in6 = (struct sockaddr_in6 *)sa;
+ memset(&sa_in6, 0, sizeof(sa_in6));
+ memcpy(&sa_in6, sa, sizeof(sa));
check_sockaddr_len(in6);
- inet_ntop(AF_INET6, &sa_in6->sin6_addr, addr, sizeof addr);
- printf("[%s]:%u", addr, htons(sa_in6->sin6_port));
+ inet_ntop(AF_INET6, &sa_in6.sin6_addr, addr, sizeof addr);
+ printf("[%s]:%u", addr, htons(sa_in6.sin6_port));
break;
}
#ifdef IPX
case AF_IPX: {
- struct sockaddr_ipx *sa_ipx;
+ struct sockaddr_ipx sa_ipx;
- sa_ipx = (struct sockaddr_ipx *)sa;
+ memset(&sa_ipx, 0, sizeof(sa_ipx));
+ memcpy(&sa_ipx, sa, sizeof(sa));
check_sockaddr_len(ipx);
/* XXX wish we had ipx_ntop */
- printf("%s", ipx_ntoa(sa_ipx->sipx_addr));
+ printf("%s", ipx_ntoa(sa_ipx.sipx_addr));
+ free(sa_ipx);
break;
}
#endif
case AF_UNIX: {
- struct sockaddr_un *sa_un;
+ struct sockaddr_un sa_un;
- sa_un = (struct sockaddr_un *)sa;
+ memset(&sa_un, 0, sizeof(sa_un));
+ memcpy(&sa_un, sa, sizeof(sa));
check_sockaddr_len(un);
- printf("%.*s", (int)sizeof(sa_un->sun_path), sa_un->sun_path);
+ printf("%.*s", (int)sizeof(sa_un.sun_path), sa_un.sun_path);
break;
}
default:
@@ -1558,8 +1565,8 @@ ktrstruct(char *buf, size_t buflen)
if (datalen == 0)
goto invalid;
/* sanity check */
- for (i = 0; i < namelen; ++i)
- if (!isalpha((unsigned char)name[i]))
+ for (i = 0; i < (int)namelen; ++i)
+ if (!isalpha(name[i]))
goto invalid;
if (strcmp(name, "stat") == 0) {
if (datalen != sizeof(struct stat))
diff --git a/usr.bin/kdump/mkioctls b/usr.bin/kdump/mkioctls
index a9c7d069f4cb..33107dfe711e 100644
--- a/usr.bin/kdump/mkioctls
+++ b/usr.bin/kdump/mkioctls
@@ -15,12 +15,21 @@ LC_ALL=C; export LC_ALL
# XXX should we use an ANSI cpp?
ioctl_includes=`
cd $1
- find -H -s * -name '*.h' |
+ find -H -s * -name '*.h' | grep -v '.*disk.*\.h' | \
xargs egrep -l \
'^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
awk '{printf("#include <%s>\\\\n", $1)}'
`
+case "`uname -m`" in
+*pc98*)
+ ioctl_includes="$ioctl_includes#include <sys/diskpc98.h>\\n"
+ ;;
+*)
+ ioctl_includes="$ioctl_includes#include <sys/diskmbr.h>\\n"
+ ;;
+esac
+
awk -v x="$ioctl_includes" 'BEGIN {print x}' |
gcc -E -I$1 -dM -DCOMPAT_43TTY - |
awk -v ioctl_includes="$ioctl_includes" '