[OpenAFS-devel] getting kdump working on linux 2.4.x

Nathan Neulinger nneul@umr.edu
Thu, 9 Aug 2001 08:58:15 -0500


--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Attached is a patch that gets kdump working on linux 2.4.x. Note - this is 
ugly cause it's mixed in with my other patch for Makefile cleanup, however
if you want to try this out or extract useful stuff from it, it will stand
on it's own if you apply it (i.e. it doesn't need the rest of my makefiles
patch).

Derrick, don't apply this one yet, I'll clean it up after you've got the
big one committed, cause I haven't done much work on this file yet.

Also, note - I have not checked to make sure this still works with 2.2, or
any other systypes for that matter, but someone more familiar with kdump 
might want to look this over and come up with a better patch.

The important changes:
	get right kernel include path in makefile
	in kdump, include correct strings header only, and insure that
		kernel-only data types get included from asm/types (this
		takes care of the u8 issue in ncp_fs.h)
	don't redefine timeval (why is this being done?) on 24

Also, it appears that some stuff doesn't work, I see alot of weird read errors
while running a full kdump, but some of the other standard stuff like 
kdump -users works just fine.

-- Nathan

------------------------------------------------------------
Nathan Neulinger                       EMail:  nneul@umr.edu
University of Missouri - Rolla         Phone: (573) 341-4841
Computing Services                       Fax: (573) 341-4216

--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kdump.diff"

? AFS_component_version_number.c
? Makefile
? cmdebug
? fs
? fstrace
? gcpags
? kdump-2.4.7-ac3
? up
? test/Makefile
? test/fulltest
? test/getinitparams
? test/idtest
? test/owntest
Index: Makefile.in
===================================================================
RCS file: /cvs/openafs/src/venus/Makefile.in,v
retrieving revision 1.2
diff -u -r1.2 Makefile.in
--- Makefile.in	2001/08/07 16:14:08	1.2
+++ Makefile.in	2001/08/09 13:52:31
@@ -12,48 +12,50 @@
 
 SHELL = /bin/sh
 
-LINUX_VERS=dummy
+LINUX_KERNEL_PATH=@LINUX_KERNEL_PATH@
+LINUX_VERSION=@LINUX_VERSION@
+
 include ../config/Makefile.${SYS_NAME}
 
 INSTALLex = ${INSTALL} -m 755
 CCXPG2= /usr/xpg2bin/cc
 
-CFLAGS = ${OPTMZ} -I${DESTDIR}include -I${TOP_SRCDIR}/config -I${SRCDIR}include ${XCFLAGS}
+CFLAGS = ${OPTMZ} -I${DESTDIR}/include -I${TOP_SRCDIR}/config -I${SRCDIR}/include ${XCFLAGS}
 
-INCLS = ${DESTDIR}include/afs/afsint.h \
-	${DESTDIR}include/afs/cmd.h \
-	${DESTDIR}include/afs/afsutil.h
+INCLS = ${DESTDIR}/include/afs/afsint.h \
+	${DESTDIR}/include/afs/cmd.h \
+	${DESTDIR}/include/afs/afsutil.h
 
-VLIB = ${DESTDIR}lib/afs/
+VLIB = ${DESTDIR}/lib/afs/
 
-LIB = ${DESTDIR}lib/
+LIB = ${DESTDIR}/lib/
 
-FSLIBS = ${VLIB}libsys.a \
-	 ${VLIB}libvldb.a \
-	 ${LIB}libubik.a \
+FSLIBS = ${VLIB}/libsys.a \
+	 ${VLIB}/libvldb.a \
+	 ${LIB}/libubik.a \
 	 ${VLIB}vlib.a \
-	 ${VLIB}libauth.a \
-	 ${DESTDIR}lib/librxkad.a \
-	 ${VLIB}libcom_err.a \
-	 ${VLIB}libcmd.a \
-	 ${VLIB}libkauth.a \
-	 ${DESTDIR}lib/libdes.a \
-	 ${LIB}librx.a \
-	 ${VLIB}libsys.a \
+	 ${VLIB}/libauth.a \
+	 ${DESTDIR}/lib/librxkad.a \
+	 ${VLIB}/libcom_err.a \
+	 ${VLIB}/libcmd.a \
+	 ${VLIB}/libkauth.a \
+	 ${DESTDIR}/lib/libdes.a \
+	 ${LIB}/librx.a \
+	 ${VLIB}/libsys.a \
 	 $(VLIB)util.a \
-	 ${LIB}liblwp.a \
-	 ${VLIB}libaudit.a
+	 ${LIB}/liblwp.a \
+	 ${VLIB}/libaudit.a
 
-CMLIBS = ${VLIB}libsys.a \
-	 ${VLIB}libafsint.a \
-	 ${DESTDIR}lib/librxkad.a \
-	 ${VLIB}libauth.a \
-	 ${VLIB}libcom_err.a \
-	 ${VLIB}libcmd.a \
-	 ${LIB}librx.a \
-	 ${VLIB}libsys.a \
+CMLIBS = ${VLIB}/libsys.a \
+	 ${VLIB}/libafsint.a \
+	 ${DESTDIR}/lib/librxkad.a \
+	 ${VLIB}/libauth.a \
+	 ${VLIB}/libcom_err.a \
+	 ${VLIB}/libcmd.a \
+	 ${LIB}/librx.a \
+	 ${VLIB}/libsys.a \
 	 $(VLIB)util.a \
-	 ${LIB}liblwp.a 
+	 ${LIB}/liblwp.a 
 
 LIBS = ${FSLIBS} 
 
@@ -66,44 +68,42 @@
 
 all: fs up cmdebug fstrace kdump gcpags kdump64
 
-${DESTDIR}bin/fs ${DESTDIR}root.server/usr/afs/bin/fs: fs
+${DESTDIR}/bin/fs ${DESTDIR}root.server/usr/afs/bin/fs: fs
 	${INSTALL} -s $? $@
 
-${DESTDIR}bin/up: up
+${DESTDIR}/bin/up: up
 	${INSTALL} -s $? $@
 
-${DESTDIR}etc/fstrace: fstrace
+${DESTDIR}/etc/fstrace: fstrace
 	${INSTALL} -s $? $@
 
-${DESTDIR}bin/cmdebug: cmdebug
+${DESTDIR}/bin/cmdebug: cmdebug
 	${INSTALL} -s $? $@
 
-${DESTDIR}etc/kdump: kdump
+${DESTDIR}/etc/kdump: kdump
 	-set -x; \
 	case ${SYS_NAME} in \
 	sgi_6? ) \
 		${INSTALLex} -f kdump.sh.sgi_ipnos $@; \
-		ln -fs kdump ${DESTDIR}etc/kdump32; \
-		ln -fs kdump.IP20 ${DESTDIR}etc/kdump.IP22; \
-		ln -fs kdump.IP20 ${DESTDIR}etc/kdump.IP32; \
+		ln -fs kdump ${DESTDIR}/etc/kdump32; \
+		ln -fs kdump.IP20 ${DESTDIR}/etc/kdump.IP22; \
+		ln -fs kdump.IP20 ${DESTDIR}/etc/kdump.IP32; \
 		for f in kdump.IP??; \
-		do ${INSTALL} -s $$f ${DESTDIR}etc/$$f || exit $$? ; \
+		do ${INSTALL} -s $$f ${DESTDIR}/etc/$$f || exit $$? ; \
 		done ;; \
 	sun4x_5[78] ) \
 		${INSTALLex} -f kdump.sh.solaris7 $@; \
-		${INSTALL} -s -f $? ${DESTDIR}etc/kdump32;; \
+		${INSTALL} -s -f $? ${DESTDIR}/etc/kdump32;; \
 	*linux* ) \
-		for lv in ${LINUX_VERS}; do \
-			${INSTALL} -s kdump-$$lv ${DESTDIR}etc/kdump-$$lv ; \
-		done ;; \
+		${INSTALL} -s kdump-${LINUX_VERSION} ${DESTDIR}/etc/kdump-${LINUX_VERSION} ;; \
 	hp_ux11* ) \
 		${INSTALLex} -f kdump.sh.hp_ux11 $@; \
-		${INSTALL} -s -f $? ${DESTDIR}etc/kdump32;; \
+		${INSTALL} -s -f $? ${DESTDIR}/etc/kdump32;; \
 	*) \
 		${INSTALL} -s $? $@ ;; \
 	esac
 
-${DESTDIR}etc/kdump64: kdump64
+${DESTDIR}/etc/kdump64: kdump64
 	-set -x; \
 	case ${SYS_NAME} in \
 	sun4x_5[78] | hp_ux11* ) \
@@ -113,9 +113,9 @@
 	esac
 
 
-install: all ${DESTDIR}bin/fs ${DESTDIR}root.server/usr/afs/bin/fs \
-	${DESTDIR}bin/up ${DESTDIR}etc/fstrace ${DESTDIR}bin/cmdebug \
-	${DESTDIR}etc/kdump ${DESTDIR}etc/kdump64
+install: all ${DESTDIR}/bin/fs ${DESTDIR}root.server/usr/afs/bin/fs \
+	${DESTDIR}/bin/up ${DESTDIR}/etc/fstrace ${DESTDIR}/bin/cmdebug \
+	${DESTDIR}/etc/kdump ${DESTDIR}/etc/kdump64
 
 system: install
 
@@ -127,7 +127,7 @@
 fs.o: fs.c ${INCLS} AFS_component_version_number.c
 
 fs: fs.o $(LIBS)
-	${CC} ${CFLAGS} -g -o fs fs.o ${DESTDIR}lib/afs/libprot.a $(LIBS) ${XLIBS}
+	${CC} ${CFLAGS} -g -o fs fs.o ${DESTDIR}/lib/afs/libprot.a $(LIBS) ${XLIBS}
 
 twiddle: twiddle.c $(LIBS)
 	${CC} -g -o twiddle $(CFLAGS) twiddle.c $(LIBS) ${XLIBS}
@@ -143,21 +143,21 @@
 fstrace.o: fstrace.c AFS_component_version_number.c
 	case ${SYS_NAME} in \
 		sun4_411 | sun4c_411 | sun4m_412 ) \
-			${CCXPG2} -g -I${TOP_SRCDIR}/config -I${DESTDIR}include -I${SRCDIR}include -c fstrace.c ;; \
+			${CCXPG2} -g -I${TOP_SRCDIR}/config -I${DESTDIR}/include -I${SRCDIR}/include -c fstrace.c ;; \
 		* ) \
-			${CC} ${CFLAGS} -g -I${TOP_SRCDIR}/config -I${DESTDIR}include -I${SRCDIR}include -c fstrace.c ;; \
+			${CC} ${CFLAGS} -g -I${TOP_SRCDIR}/config -I${DESTDIR}/include -I${SRCDIR}/include -c fstrace.c ;; \
 	esac
 
 fstrace: fstrace.o
 	case ${SYS_NAME} in \
 		pmax_ul43 | pmax_ul43a ) \
-			${CC} ${CFLAGS} -o fstrace fstrace.o ${VLIB}/libsys.a ${VLIB}libcmd.a ${VLIB}util.a /usr/lib/libi.a ;; \
+			${CC} ${CFLAGS} -o fstrace fstrace.o ${VLIB}/libsys.a ${VLIB}/libcmd.a ${VLIB}util.a /usr/lib/libi.a ;; \
 		sun4_411 | sun4c_411 | sun4m_412 ) \
-			${CCXPG2} ${CFLAGS} -g -o fstrace fstrace.o ${VLIB}/libsys.a ${VLIB}libcmd.a ${VLIB}util.a ;; \
+			${CCXPG2} ${CFLAGS} -g -o fstrace fstrace.o ${VLIB}/libsys.a ${VLIB}/libcmd.a ${VLIB}util.a ;; \
 		hp700_ux100 | hp800_ux100 | hp?00_ux10? | hp_ux10? | hp_ux11?) \
-			${CC} -I${TOP_SRCDIR}/config  -o fstrace fstrace.o ${VLIB}/libsys.a ${VLIB}libcmd.a ${VLIB}util.a ;; \
+			${CC} -I${TOP_SRCDIR}/config  -o fstrace fstrace.o ${VLIB}/libsys.a ${VLIB}/libcmd.a ${VLIB}util.a ;; \
 		* ) \
-			${CC} ${CFLAGS} -o fstrace fstrace.o ${VLIB}/libsys.a ${VLIB}libcmd.a ${VLIB}util.a ;; \
+			${CC} ${CFLAGS} -o fstrace fstrace.o ${VLIB}/libsys.a ${VLIB}/libcmd.a ${VLIB}util.a ;; \
 	esac
 
 cmdebug.o: cmdebug.c ${INCLS} AFS_component_version_number.c
@@ -169,13 +169,11 @@
 	-set -x; \
 	case ${SYS_NAME} in \
 		alpha_linux* ) \
-			for lv in ${LINUX_VERS}; do \
-				${CC} -g -I${LINUX_SRCDIR}$$lv/include -I${DESTDIR}include -I${TOP_SRCDIR}/config -I${SRCDIR}include ${XCFLAGS} -mno-fp-regs -ffixed-8 -o kdump-$$lv.o -c kdump.c ; \
+			for lv in ${LINUX_VERSION}; do \
+				${CC} -g -I${LINUX_SRCDIR}$$lv/include -I${DESTDIR}/include -I${TOP_SRCDIR}/config -I${SRCDIR}/include ${XCFLAGS} -mno-fp-regs -ffixed-8 -o kdump-$$lv.o -c kdump.c ; \
 				done ;; \
 		*linux* ) \
-			for lv in ${LINUX_VERS}; do \
-				${CC} -g -I${LINUX_SRCDIR}$$lv/include -I${DESTDIR}include -I${TOP_SRCDIR}/config -I${SRCDIR}include ${XCFLAGS} -o kdump-$$lv.o -c kdump.c ; \
-			done ;; \
+			${CC} -g -I${LINUX_KERNEL_PATH}/include -I${DESTDIR}/include -I${TOP_SRCDIR}/config -I${SRCDIR}/include ${XCFLAGS} -o kdump-${LINUX_VERSION}.o -c kdump.c ;; \
 		alpha_osf1 | alpha_osf20 |  alpha_osf30 | alpha_osf32 | alpha_osf32c| alpha_dux?? ) \
 			${CC} -g ${CFLAGS} -I/usr/sys/include -I/usr/sys/BINARY -I/usr/sys/AFS -DDEBUGGER -c kdump.c ;;\
 		sgi_6? ) \
@@ -186,14 +184,14 @@
 				echo CPU_KDEFS = $$CPU_KDEFS; \
 				case $$CPU_KDEFS in \
 				*-64*)	${CC} -D_KMEMUSER -woff 1178 \
-						-g -I${DESTDIR}include \
+						-g -I${DESTDIR}/include \
 						-I${TOP_SRCDIR}/config \
 						$$CPU_KDEFS \
 						${XCFLAGS64} \
 						-c kdump.c -o kdump.$$IP.o \
 					;; \
 				*)	${CC} -D_KMEMUSER -woff 1178 \
-						-g -I${DESTDIR}include \
+						-g -I${DESTDIR}/include \
 						-I${TOP_SRCDIR}/config \
 						$$CPU_KDEFS \
 						${XCFLAGS} -DAFS_32BIT_KERNEL_ENV \
@@ -203,23 +201,23 @@
 			done \
 			;; \
 		*) \
-			${CC} -g -I${DESTDIR}include -I${TOP_SRCDIR}/config -I${SRCDIR}include ${XCFLAGS} -c kdump.c ;; \
+			${CC} -g -I${DESTDIR}/include -I${TOP_SRCDIR}/config -I${SRCDIR}/include ${XCFLAGS} -c kdump.c ;; \
 	esac ;
 
 kdump64.o : kdump.c ${INCLS} AFS_component_version_number.c
 	-set -x; \
 	case ${SYS_NAME} in \
 	sun4x_5[78] | hp_ux11* ) \
-		${CC} -g -I${DESTDIR}include -I${TOP_SRCDIR}/config -I${SRCDIR}include ${XCFLAGS64} -o kdump64.o -c kdump.c ;; \
+		${CC} -g -I${DESTDIR}/include -I${TOP_SRCDIR}/config -I${SRCDIR}/include ${XCFLAGS64} -o kdump64.o -c kdump.c ;; \
 	esac
 
 kdump:  kdump.o
 	-set -x; \
 	case ${SYS_NAME} in \
 	sun4c_51 | sun4c_52 | sun4m_51 | sun4m_52 | sun4c_53 | sun4m_53 | sun4_53 | sun4_54 | sun4c_54 | sun4m_54 | sunx86_54) \
-		${CC} -g -o kdump kdump.o ${DESTDIR}lib/afs/libcmd.a  ${DESTDIR}lib/afs/util.a /usr/lib/libkvm.a -lelf ${XLIBS} ;; \
+		${CC} -g -o kdump kdump.o ${DESTDIR}/lib/afs/libcmd.a  ${DESTDIR}/lib/afs/util.a /usr/lib/libkvm.a -lelf ${XLIBS} ;; \
 	sun4x_5? ) \
-		${CC} -g -o kdump kdump.o ${DESTDIR}lib/afs/libcmd.a  ${DESTDIR}lib/afs/util.a  ${XLIBELFA}  ${XLIBKVM} ${XLIBS} ;; \
+		${CC} -g -o kdump kdump.o ${DESTDIR}/lib/afs/libcmd.a  ${DESTDIR}/lib/afs/util.a  ${XLIBELFA}  ${XLIBKVM} ${XLIBS} ;; \
 	sgi_6? ) \
 		for f in ../libafs/STATIC.IP*/CPU_KDEFS; \
 		do	IP=`expr "$$f" : '../libafs/STATIC.\(IP..\)'`; \
@@ -230,23 +228,21 @@
 			*-64*)	${CC} ${XCFLAGS64} -g \
 					$$CPU_KDEFS \
 					-o kdump.$$IP kdump.$$IP.o \
-					${DESTDIR}lib/afs/libcmd64.a -lelf \
+					${DESTDIR}/lib/afs/libcmd64.a -lelf \
 				;; \
 			*) 	${CC} ${XCFLAGS} -g \
 					$$CPU_KDEFS \
 					-o kdump.$$IP kdump.$$IP.o \
-					${DESTDIR}lib/afs/libcmd.a -lelf \
+					${DESTDIR}/lib/afs/libcmd.a -lelf \
 				;; \
 			esac || exit $$? ; \
 		done ;; \
 	*linux* ) \
-		for lv in ${LINUX_VERS}; do \
-			${CC} -g -o kdump-$$lv kdump-$$lv.o ${DESTDIR}lib/afs/libcmd.a  ${DESTDIR}lib/afs/util.a ${XLIBS} ; \
-		done ;; \
+		${CC} -g -o kdump-${LINUX_VERSION} kdump-${LINUX_VERSION}.o ${DESTDIR}/lib/afs/libcmd.a ${DESTDIR}/lib/afs/util.a ${XLIBS} ;; \
 	alpha_osf1 | alpha_osf20 |  alpha_osf30 | alpha_osf32 | alpha_osf32c | alpha_dux??) \
-		${CC} -g -o kdump kdump.o ${DESTDIR}lib/afs/libcmd.a  ${DESTDIR}lib/afs/util.a ${XLIBS} -ll -lmld;; \
-	ncrx86_* ) ${CC} -g -o kdump kdump.o ${DESTDIR}lib/afs/libcmd.a  ${DESTDIR}lib/afs/util.a -lelf ${XLIBS} ;; \
-	* )     ${CC} -g -o kdump kdump.o ${DESTDIR}lib/afs/libcmd.a  ${DESTDIR}lib/afs/util.a ${XLIBS} ;; \
+		${CC} -g -o kdump kdump.o ${DESTDIR}/lib/afs/libcmd.a  ${DESTDIR}/lib/afs/util.a ${XLIBS} -ll -lmld;; \
+	ncrx86_* ) ${CC} -g -o kdump kdump.o ${DESTDIR}/lib/afs/libcmd.a  ${DESTDIR}/lib/afs/util.a -lelf ${XLIBS} ;; \
+	* )     ${CC} -g -o kdump kdump.o ${DESTDIR}/lib/afs/libcmd.a  ${DESTDIR}/lib/afs/util.a ${XLIBS} ;; \
 	esac
 
 ## kdump to read from 64 bit kernel dumps
@@ -255,14 +251,11 @@
 	-set -x; \
 	case ${SYS_NAME} in \
 	sun4x_5[78] | hp_ux11* )  \
-		${CC} -g ${XCFLAGS64} -o kdump64 kdump64.o ${DESTDIR}lib/afs/libcmd64.a ${XLIBELFA}  ${XLIBKVM} ${XLIBS} ;; \
+		${CC} -g ${XCFLAGS64} -o kdump64 kdump64.o ${DESTDIR}/lib/afs/libcmd64.a ${XLIBELFA}  ${XLIBKVM} ${XLIBS} ;; \
 	esac
 
 clean:
-	rm -f *.o *.a up fs core cmdebug AFS_component_version_number.c fstrace gcpags
-
-beancount:
-	wc -l *.c *.h
+	rm -f *.o *.a up fs kdump-* kdump kdump64 core cmdebug AFS_component_version_number.c fstrace gcpags
 
 test:
 	cd test; $(MAKE)
Index: kdump.c
===================================================================
RCS file: /cvs/openafs/src/venus/kdump.c,v
retrieving revision 1.13
diff -u -r1.13 kdump.c
--- kdump.c	2001/08/08 00:04:18	1.13
+++ kdump.c	2001/08/09 13:52:32
@@ -14,6 +14,13 @@
 
 #include <stdio.h>
 #include <stdlib.h>	/* for malloc() */
+
+#ifdef AFS_LINUX24_ENV
+#define __KERNEL__
+#include <linux/string.h>
+#define _STRING_H 1
+#endif
+
 #include <string.h>
 
 #ifdef __linux__
@@ -242,10 +249,12 @@
     int a,b;
 };
 #ifndef AFS_ALPHA_LINUX20_ENV
+#ifndef AFS_LINUX24_ENV
 typedef struct timeval {
     int tv_sec;
     int tv_usec;
 } timeval_t; /* Needed here since KERNEL defined. */
+#endif
 #endif /*AFS_ALPHA_LINUX20_ENV*/
 #if defined(AFSBIG_ENDIAN)
 #define _LINUX_BYTEORDER_BIG_ENDIAN_H
@@ -2462,9 +2471,15 @@
     printf("\ti_ino=%d, i_mode=%x, i_nlink=%d, i_uid=%d, i_gid=%d, i_size=%d\n",
 	   vep->i_ino, vep->i_mode, vep->i_nlink, vep->i_uid, vep->i_gid,
 	   vep->i_size);
+#ifndef AFS_LINUX24_ENV
     printf("\ti_atime=%u, i_mtime=%u, i_ctime=%u, i_version=%u, i_nrpages=%u\n",
 	   vep->i_atime, vep->i_mtime, vep->i_ctime, vep->i_version,
 	   vep->i_nrpages);
+#else
+    printf("\ti_atime=%u, i_mtime=%u, i_ctime=%u, i_version=%u\n",
+	   vep->i_atime, vep->i_mtime, vep->i_ctime, vep->i_version
+	   );
+#endif
     printf("\ti_op=0x%x, i_dev=0x%x, i_rdev=0x%x, i_sb=0x%x\n",
 	   vep->i_op, vep->i_dev, vep->i_rdev, vep->i_sb);
 #ifdef AFS_LINUX24_ENV
Index: test/Makefile.in
===================================================================
RCS file: /cvs/openafs/src/venus/test/Makefile.in,v
retrieving revision 1.1
diff -u -r1.1 Makefile.in
--- test/Makefile.in	2001/08/02 15:47:09	1.1
+++ test/Makefile.in	2001/08/09 13:52:32
@@ -16,8 +16,8 @@
 
 OPTIMIZE=-O
 
-INCDIRS= -I${TOP_SRCDIR}/config -I${DESTDIR}include -I..
-LDIRS= -L${DESTDIR}lib -L${DESTDIR}lib/afs -L..
+INCDIRS= -I${TOP_SRCDIR}/config -I${DESTDIR}/include -I..
+LDIRS= -L${DESTDIR}/lib -L${DESTDIR}/lib/afs -L..
 LIBS= -lsys -lubik -lvldb -lauth -lrxkad -ldes -lcom_err -lcmd -lrx -llwp -lafsutil
 
 CFLAGS = ${OPTIMIZE} ${INCDIRS} ${XCFLAGS}

--XsQoSWH+UP9D9v3l--