Index: devel/linux_kdump/Makefile =================================================================== RCS file: /import/FreeBSD-CVS/ports/devel/linux_kdump/Makefile,v retrieving revision 1.31 diff -u -p -u -r1.31 Makefile --- devel/linux_kdump/Makefile 29 Dec 2009 10:25:49 -0000 1.31 +++ devel/linux_kdump/Makefile 22 Jan 2010 13:11:16 -0000 @@ -7,7 +7,7 @@ PORTNAME= linux_kdump PORTVERSION= 1.5 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= devel linux MASTER_SITES= ${MASTER_SITE_LOCAL} MASTER_SITE_SUBDIR= marcel @@ -15,8 +15,6 @@ MASTER_SITE_SUBDIR= marcel MAINTAINER= freebsd-emulation@FreeBSD.org COMMENT= Linux-compatability ktrace.out processor -BUILD_DEPENDS= ${LINUXBASE}/usr/bin/gcc:${PORTSDIR}/emulators/linux_base-gentoo-stage3 - ONLY_FOR_ARCHS= i386 amd64 NO_MANCOMPRESS= yes MAN1= linux_kdump.1.gz @@ -31,14 +29,14 @@ pre-everything:: @${ECHO_MSG} '===> Set SRCDIR to use an alternate source tree' .endif -.if !exists(${SRCDIR}/sys/i386/linux/syscalls.master) -IGNORE= requires kernel source present in ${SRCDIR}/sys -.endif -.if !exists(${SRCDIR}/usr.bin/ktrace/subr.c) -IGNORE= requires ktrace source present in ${SRCDIR}/usr.bin/ktrace -.endif -.if exists(${LINUXBASE}/etc/fedora-release) -IGNORE= does not build with the default linux base, use the package instead -.endif +#.if !exists(${SRCDIR}/sys/i386/linux/syscalls.master) +#IGNORE= requires kernel source present in ${SRCDIR}/sys +#.endif +#.if !exists(${SRCDIR}/usr.bin/ktrace/subr.c) +#IGNORE= requires ktrace source present in ${SRCDIR}/usr.bin/ktrace +#.endif + +post-extract: + @${CP} ${FILESDIR}/mksubr.linux ${WRKSRC}/ .include Index: devel/linux_kdump/files/mksubr.linux =================================================================== RCS file: devel/linux_kdump/files/mksubr.linux diff -N devel/linux_kdump/files/mksubr.linux --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ devel/linux_kdump/files/mksubr.linux 10 Aug 2006 12:55:27 -0000 @@ -0,0 +1,401 @@ +#!/bin/sh + +set -e + +# Generates kdump_subr.c +# mkioctls is a special-purpose script, and works fine as it is +# now, so it remains independent. The idea behind how it generates +# its list was heavily borrowed here. +# +# Some functions here are automatically generated. This can mean +# the user will see unusual kdump output or errors while building +# if the underlying .h files are changed significantly. +# +# Key: +# AUTO: Completely auto-generated with either the "or" or the "switch" +# method. +# AUTO - Special: Generated automatically, but with some extra commands +# that the auto_*_type() functions are inappropriate for. +# MANUAL: Manually entered and must therefore be manually updated. + +# $FreeBSD: src/usr.bin/kdump/mksubr,v 1.3 2006/07/12 12:42:47 kib Exp $ + +LC_ALL=C; export LC_ALL + +if [ -z "$1" ] +then + echo "usage: sh $0 include-dir" + exit 1 +fi +include_dir=$1 + +# +# Automatically generates a C function that will print out the +# numeric input as a pipe-delimited string of the appropriate +# #define keys. ex: +# S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH +# The XOR is necessary to prevent including the "0"-value in every +# line. +# +auto_or_type () { + local name grep file + name=$1 + grep=$2 + file=$3 + + cat <<_EOF_ +/* AUTO */ +void +$name (int arg) +{ + int or = 0; +_EOF_ + egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \ + $include_dir/$file | \ + awk '{ for (i = 1; i <= NF; i++) \ + if ($i ~ /define/) \ + break; \ + ++i; \ + printf "\tif(!((arg>0)^((%s)>0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }' +cat <<_EOF_ + if (or == 0) + (void)printf("%ld", (long)arg); +} + +_EOF_ +} + +# +# Automatically generates a C function used when the argument +# maps to a single, specific #definition +# +auto_switch_type () { + local name grep file + name=$1 + grep=$2 + file=$3 + + cat <<_EOF_ +/* AUTO */ +void +$name (int arg) +{ + switch (arg) { +_EOF_ + egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \ + $include_dir/$file | \ + awk '{ for (i = 1; i <= NF; i++) \ + if ($i ~ /define/) \ + break; \ + ++i; \ + printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i }' +cat <<_EOF_ + default: /* Should not reach */ + (void)printf("", (long)arg); + } +} + +_EOF_ +} + +# C start + +cat <<_EOF_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * These are simple support macros. print_or utilizes a variable + * defined in the calling function to track whether or not it should + * print a logical-OR character ('|') before a string. if_print_or + * simply handles the necessary "if" statement used in many lines + * of this file. + */ +#define print_or(str,orflag) do { \\ + if (orflag) putchar('|'); else orflag = 1; \\ + printf (str); } \\ + while (0) +#define if_print_or(i,flag,orflag) do { \\ + if ((i & flag) == flag) \\ + print_or(#flag,orflag); } \\ + while (0) + +/* MANUAL */ +extern char *signames[]; /* from kdump.c */ +void +signame (int sig) +{ + if (sig > 0 && sig < NSIG) + (void)printf("SIG%s",signames[sig]); + else + (void)printf("SIG %d", sig); +} + +/* MANUAL */ +void +semctlname (int cmd) +{ + switch (cmd) { + case GETNCNT: + (void)printf("GETNCNT"); + break; + case GETPID: + (void)printf("GETPID"); + break; + case GETVAL: + (void)printf("GETVAL"); + break; + case GETALL: + (void)printf("GETALL"); + break; + case GETZCNT: + (void)printf("GETZCNT"); + break; + case SETVAL: + (void)printf("SETVAL"); + break; + case SETALL: + (void)printf("SETALL"); + break; + case IPC_RMID: + (void)printf("IPC_RMID"); + break; + case IPC_SET: + (void)printf("IPC_SET"); + break; + case IPC_STAT: + (void)printf("IPC_STAT"); + break; + default: /* Should not reach */ + (void)printf("", (long)cmd); + } +} + +/* MANUAL */ +void +shmctlname (int cmd) { + switch (cmd) { + case IPC_RMID: + (void)printf("IPC_RMID"); + break; + case IPC_SET: + (void)printf("IPC_SET"); + break; + case IPC_STAT: + (void)printf("IPC_STAT"); + break; + default: /* Should not reach */ + (void)printf("", (long)cmd); + } +} + +/* MANUAL */ +void +semgetname (int flag) { + int or = 0; + if_print_or(flag, SEM_R, or); + if_print_or(flag, SEM_A, or); + if_print_or(flag, (SEM_R>>3), or); + if_print_or(flag, (SEM_A>>3), or); + if_print_or(flag, (SEM_R>>6), or); + if_print_or(flag, (SEM_A>>6), or); +} + +/* + * MANUAL + * + * Only used by SYS_open. Unless O_CREAT is set in flags, the + * mode argument is unused (and often bogus and misleading). + */ +void +flagsandmodename (int flags, int mode, int decimal) { + flagsname (flags); + (void)putchar(','); + if ((flags & O_CREAT) == O_CREAT) { + modename (mode); + } else { + if (decimal) { + (void)printf("%ld", (long)mode); + } else { + (void)printf("%#lx", (long)mode); + } + } +} + +/* + * MANUAL + * + * [g|s]etsockopt's level argument can either be SOL_SOCKET or a value + * referring to a line in /etc/protocols . It might be appropriate + * to use getprotoent(3) here. + */ +void +sockoptlevelname (int level, int decimal) +{ + if (level == SOL_SOCKET) { + (void)printf("SOL_SOCKET"); + } else { + if (decimal) { + (void)printf("%ld", (long)level); + } else { + (void)printf("%#lx", (long)level); + } + } +} + +_EOF_ + +auto_or_type "modename" "__S_[A-Z]+[[:space:]]+[0-6]{7}" "bits/stat.h" +auto_or_type "flagsname" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "bits/fcntl.h" +auto_or_type "accessmodename" "[A-Z]_OK[[:space:]]+0?x?[0-9A-Fa-f]+" "unistd.h" +auto_or_type "mmapprotname" "PROT_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "bits/mman.h" +auto_or_type "mmapflagsname" "MAP_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "bits/mman.h" +auto_or_type "wait4optname" "_*W[A-Z]+[[:space:]]+[0-9]+" "bits/waitflags.h" +auto_or_type "getfsstatflagsname" "MNT_[A-Z]+[[:space:]]+[1-9][0-9]*" "sys/mount.h" # not a define, it's an enum instead +auto_or_type "mountflagsname" "MNT_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mount.h" +auto_or_type "rebootoptname" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h" +auto_or_type "flockname" "LOCK_[A-Z]+[[:space:]]+0x[0-9]+" "bits/fcntl.h" +auto_or_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "asm/socket.h" +auto_or_type "sockdomainname" "PF_[A-Z]+[[:space:]]+" "bits/socket.h" +auto_or_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "bits/socket.h" # enum, not a define +auto_or_type "thrcreateflagsname" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h" # doesn't exist +auto_or_type "mlockallname" "MCL_[A-Z]+[[:space:]]+0x[0-9]+" "bits/mman.h" +auto_or_type "shmatname" "SHM_[A-Z]+[[:space:]]+[0-9]{6}+" "bits/shm.h" +auto_or_type "rforkname" "RF[A-Z]+[[:space:]]+\([0-9]+<<[0-9]+\)" "unistd.h" # nit available +auto_or_type "nfssvcname" "NFS4_SVC_[A-Z]+[[:space:]]+0x[0-9]+" "linux/nfsd/xdr4.h" # compile time value +auto_switch_type "whencename" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "unistd.h" +auto_switch_type "rlimitname" "RLIMIT_[A-Z]+[[:space:]]+[0-9]+" "bits/resource.h" # enum instead of define +auto_switch_type "shutdownhowname" "SHUT_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h" # enum instead of define +auto_switch_type "prioname" "PRIO_[A-Z]+[[:space:]]+[0-9]" "bits/resource.h" # enum and define +auto_switch_type "madvisebehavname" "MADV_[A-Z]+[[:space:]]+[0-9]+" "bits/mman.h" +auto_switch_type "msyncflagsname" "MS_[A-Z]+[[:space:]]+0x[0-9]+" "bits/mman.h" +auto_switch_type "schedpolicyname" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "bits/sched.h" +auto_switch_type "kldunloadfflagsname" "LINKER_UNLOAD_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h" # not available +auto_switch_type "ksethrcmdname" "KSE_INTR_[A-Z]+[[:space:]]+[0-9]+" "sys/kse.h" +auto_switch_type "extattrctlname" "EXTATTR_NAMESPACE_[A-Z]+[[:space:]]+0x[0-9]+" "sys/extattr.h" # not available +auto_switch_type "kldsymcmdname" "KLDSYM_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h" # not available +auto_switch_type "sendfileflagsname" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h" # not available +auto_switch_type "acltypename" "ACL_TYPE_[A-Z]+[[:space:]]+\(0x[0-9]+\)" "linux/posix_acl.h" +auto_switch_type "sigprocmaskhowname" "SIG_[A-Z]+[[:space:]]+[0-9]+" "asm/signal.h" +auto_switch_type "lio_listioname" "LIO_(NO)?WAIT[[:space:]]+[0-9]+" "aio.h" # enum instead of define +auto_switch_type "minheritname" "INHERIT_[A-Z]+[[:space:]]+[0-9]+" "bits/mman.h" # not there +auto_switch_type "quotactlname" "Q_[A-Z]+[[:space:]]+0x[0-9]+" "sys/quota.h" + +cat <<_EOF_ +/* + * AUTO - Special + * F_ is used to specify fcntl commands as well as arguments. Both sets are + * grouped in fcntl.h, and this awk script grabs the first group. + */ +void +fcntlcmdname (int cmd, int arg, int decimal) +{ + switch (cmd) { +_EOF_ +egrep "^#[[:space:]]*define[[:space:]]+F_[A-Z]+[[:space:]]+[0-9]+[[:space:]]*" \ + $include_dir/bits/fcntl.h | \ + awk 'BEGIN { o=0 } { for (i = 1; i <= NF; i++) \ + if ($i ~ /define/) \ + break; \ + ++i; \ + if (o <= $(i+1)) \ + printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i; \ + else \ + exit; \ + o = $(i+1) }' +cat <<_EOF_ + default: /* Should not reach */ + (void)printf("", (long)cmd); + } + (void)putchar(','); + if (cmd == F_GETFD || cmd == F_SETFD) { + if (arg == FD_CLOEXEC) + (void)printf("FD_CLOEXEC"); + else if (arg == 0) + (void)printf("0"); + else { + if (decimal) + (void)printf("%ld", (long)arg); + else + (void)printf("%#lx", (long)arg); + } + } else if (cmd == F_SETFL) { + flagsname(arg); + } else { + if (decimal) + (void)printf("%ld", (long)arg); + else + (void)printf("%#lx", (long)arg); + } +} + +/* + * AUTO - Special + * + * The only reason this is not fully automated is due to the + * grep -v RTP_PRIO statement. A better egrep line should + * make this capable of being a auto_switch_type() function. + */ +void +rtprioname (int func) +{ + switch (func) { +_EOF_ +# doesn't exists +egrep "^#[[:space:]]*define[[:space:]]+RTP_[A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*" \ + $include_dir/sys/rtprio.h | grep -v RTP_PRIO | \ + awk '{ for (i = 1; i <= NF; i++) \ + if ($i ~ /define/) \ + break; \ + ++i; \ + printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i }' +cat <<_EOF_ + default: /* Should not reach */ + (void)printf("", (long)func); + } +} + +/* + * AUTO - Special + * + * The send and recv functions have a flags argument which can be + * set to 0. There is no corresponding #define. The auto_ functions + * detect this as "invalid", which is incorrect here. + */ +void +sendrecvflagsname (int flags) +{ + int or = 0; + + if (flags == 0) { + (void)printf("0"); + return; + } +_EOF_ +# enum instead of a define +egrep "^[[:space:]]+MSG_[A-Z]+[[:space:]]+=+[[:space:]]+0x[0-9],*+[[:space:]]*" $include_dir/bits/socket.h | \ + awk '{ for (i = 1; i <= NF; i++) \ + ++i; \ + printf "\tif(!((flags>0)^((%s)>0)))\n\t\tif_print_or(flags, %s, or);\n", $i, $i }' +cat <<_EOF_ +} + +_EOF_ Index: devel/linux_kdump/files/patch-Makefile =================================================================== RCS file: /import/FreeBSD-CVS/ports/devel/linux_kdump/files/patch-Makefile,v retrieving revision 1.1 diff -u -p -u -r1.1 patch-Makefile --- devel/linux_kdump/files/patch-Makefile 19 Jul 2006 20:02:22 -0000 1.1 +++ devel/linux_kdump/files/patch-Makefile 10 Aug 2006 12:55:16 -0000 @@ -1,12 +1,12 @@ ---- Makefile.orig Wed Jul 19 21:27:48 2006 -+++ Makefile Wed Jul 19 21:43:08 2006 +--- Makefile.orig Sat Feb 14 08:05:13 2004 ++++ Makefile Thu Aug 10 14:55:00 2006 @@ -2,14 +2,19 @@ PROG= linux_kdump SRCS= kdump.c linux_ioctl.c subr.c syscallnames.c +.if exists(${SRCDIR}/usr.bin/kdump/kdump_subr.h) -+SRCS+= kdump_subr.c -+CLEANFILES+=kdump_subr.c ++SRCS+= linux_kdump_subr.c ++CLEANFILES+=linux_kdump_subr.c +.endif CLEANFILES+=linux_ioctl.c syscallnames.c @@ -21,14 +21,18 @@ .PATH: ${SRCDIR}/usr.bin/ktrace default: depend all -@@ -22,5 +27,10 @@ +@@ -22,5 +27,14 @@ linux_ioctl.c: mkioctls.linux /bin/sh ${.CURDIR}/mkioctls.linux + +.if exists(${SRCDIR}/usr.bin/kdump/kdump_subr.h) -+kdump_subr.c: ${SRCDIR}/usr.bin/kdump/mksubr -+ /bin/sh ${SRCDIR}/usr.bin/kdump/mksubr ${LINUXBASE}/usr/include > ${.TARGET} ++linux_kdump_subr.c: ++ @/bin/sh ${.CURDIR}/mksubr.linux ${LINUXBASE}/usr/include > ${.CURDIR}/tmp1.c ++ @echo '#include ' > ${.TARGET} ++ @echo '#include "kdump_subr.h"' >> ${.TARGET} ++ @${LINUXBASE}/usr/bin/gcc -E -D__builtin_va_list=int ${.CURDIR}/tmp1.c >> ${.TARGET} ++ @rm tmp1.c +.endif .include Index: devel/linux_kdump/files/patch-mkioctls.linux =================================================================== RCS file: /import/FreeBSD-CVS/ports/devel/linux_kdump/files/patch-mkioctls.linux,v retrieving revision 1.3 diff -u -p -u -r1.3 patch-mkioctls.linux --- devel/linux_kdump/files/patch-mkioctls.linux 2 Jan 2006 23:02:11 -0000 1.3 +++ devel/linux_kdump/files/patch-mkioctls.linux 9 Aug 2006 22:45:53 -0000 @@ -1,5 +1,5 @@ ---- mkioctls.linux.orig Sat Feb 21 15:35:48 2004 -+++ mkioctls.linux Sat Feb 21 15:34:41 2004 +--- mkioctls.linux.orig Sat Feb 14 08:05:13 2004 ++++ mkioctls.linux Thu Aug 10 00:45:35 2006 @@ -4,7 +4,7 @@ TMP2FILE=/tmp/$$b.c OUTFILE=linux_ioctl.c @@ -9,3 +9,12 @@ (echo "#include " echo "#include " +@@ -54,7 +54,7 @@ + } + ' > $TMP2FILE + +-$CPP $TMP2FILE > $OUTFILE ++$CPP $TMP2FILE > $OUTFILE || (rm $TMP1FILE $TMP2FILE; exit 1) + + rm $TMP1FILE + rm $TMP2FILE