Problem
I want to be able to cause my SCO OpenServer 5 or UNIX 3.2v.2.0 system to panic, for example, to practice using the "crash" utility.
NOTE: the following has not been tested on UNIX 3.2v4.2-based operating systems; however, there is a high likelihood that the procedure outlined for UNIX 3.2v2.0-based operating systems will work on 3.2v4.2.
Solution
A sample driver is provided below. To produce and link the
driver, save the text into the following three files, in their
own directory:Driver.c
makefile
installscriptThe indented makefile lines are indented with tabs, not spaces.
NOTE: be sure to take note of the different makefiles for the UNIX 3.2.2/ODT 1.1 releases and the OpenServer 5 releases. These makefiles are written out explicitly below.
Take the system to single-user mode, change directory to that containing the three files and type:
make
make installThis will compile the driver and relink the kernel. The device
file "/dev/panic" will be created; any ioctl performed on this
file will cause a system panic, for example:stty < /dev/panicThe system must be rebooted from the new kernel for the driver to be active.
NOTE: For obvious reasons this driver must not be installed on any system which is used for any other purpose than production of system dumps.
This driver is not intended as an example of good programming style or practice, or as an example of how drivers should be installed.
For all releases, the appropriate SCO Development System
must be installed as appropriate. The Link kit must also be
fully installed prior to executing this procedure./* save into file Driver.c */
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <sys/cmn_err.h>pmlinit() { printcfg("pml", 0, 0, -1, -1, "%s", "Panic Driver"); }
pmlopen(dev_t dev, int flag, int id) { cmn_err(CE_NOTE, "pmlopen(%d,%d)", major(dev), minor(dev)); }
pmlclose(dev_t dev, int flag ) { cmn_err(CE_NOTE, "pmlclose(%d,%d)", major(dev), minor(dev)); }
pmlread(dev_t dev)
{
cmn_err(CE_NOTE, "pmlread(%d,%d)", major(dev), minor(dev));
}pmlwrite(dev_t dev)
{
cmn_err(CE_NOTE, "pmlwrite(%d,%d)", major(dev), minor(dev));
}pmlioctl(dev_t dev, int cmd, caddr_t arg, int mode) { cmn_err(CE_PANIC, "PANIC on device %d %d", major(dev), minor(dev)); }
/* end of file Driver.c */#### save into file makefile for UNIX 3.2.2/ODT 1.1 ####TARGETDIR = /etc/conf/pack.d/pmlCC = cc CFLAGS = -c -K -Zp4 -DINKERNEL -M3
Driver.o: Driver.c
$(CC) $(CFLAGS) Driver.c
chmod +x ./installscriptinstall: Driver.o
-mkdir $(TARGETDIR)
cp Driver.o $(TARGETDIR)
./installscript#### end of file makefile for Unix 3.2.2/ODT 1.1 ######## save into file makefile for OpenServer 5 ####TARGETDIR = /etc/conf/pack.d/pmlCC = cc
CFLAGS = -c -DINKERNELDriver.o: Driver.c
$(CC) $(CFLAGS) Driver.c
chmod +x ./installscriptinstall: Driver.o
-mkdir $(TARGETDIR)
cp Driver.o $(TARGETDIR)
./installscript#### end of file makefile for OpenServer 5 ######## save as file installscript ####
:
cd /etc/conf/cf.dREMOVE=`./configure -j pml`if [ "$REMOVE" != "No such device" ] then ./configure -m $REMOVE -d -c fi
MAJOR=`./configure -j NEXTMAJOR`echo ./configure -c -m $MAJOR -a pmlinit pmlopen pmlclose pmlwrite
pmlread pmlioctl
./configure -c -m $MAJOR -a pmlinit pmlopen pmlclose pmlwrite pmlread pmlioctlif [ -c /dev/panic ]
then
rm -rf /dev/panic
fi
echo /etc/mknod /dev/panic c $MAJOR 0
/etc/mknod /dev/panic c $MAJOR 0echo ./link_unix
./link_unix#### end of file installscript ####