Technical article 103679

I want to link a simple driver to cause panics on my OpenServer system.

OpenServer 5.0.0OpenServer 5.0.4OpenServer 5.0.6

Written · Last revised

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
installscript

The 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 install
This 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/panic

The 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/pml

CC = cc CFLAGS = -c -K -Zp4 -DINKERNEL -M3

Driver.o: Driver.c
         $(CC) $(CFLAGS) Driver.c
         chmod +x ./installscript
install: 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/pml
CC = cc
CFLAGS = -c -DINKERNEL
Driver.o: Driver.c
         $(CC) $(CFLAGS) Driver.c
         chmod +x ./installscript
install: Driver.o
         -mkdir $(TARGETDIR)
         cp Driver.o $(TARGETDIR)
         ./installscript
#### end of file makefile for OpenServer 5 ####
#### save as file installscript  ####
:
cd /etc/conf/cf.d
REMOVE=`./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 pmlioctl
if [ -c /dev/panic ]
then
         rm -rf /dev/panic
fi
echo /etc/mknod         /dev/panic c $MAJOR 0
/etc/mknod         /dev/panic c $MAJOR 0
echo ./link_unix
./link_unix
#### end of file installscript ####

From the Xinuos technical article database, record 103679. Reproduced with permission. The original is at www.sco.com/ta/103679, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.