File: oops_test.c

package info (click to toggle)
sysklogd 1.4.1-17
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 464 kB
  • ctags: 303
  • sloc: ansic: 3,799; sh: 354; perl: 200; makefile: 184
file content (52 lines) | stat: -rw-r--r-- 773 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * This is a small test program for generating a kernel protection fault
 * using the oops loadable module.
 *
 * Fri Apr 26 12:52:43 CDT 1996:  Dr. Wettstein
 *	Initial version.
 */


/* Includes. */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>


/* Function prototypes. */
extern int main(int, char **);


extern int main(argc, argv)

     int argc;

     char *argv[];

{
	auto int fd;

	if ( argc != 2 )
	{
		fprintf(stderr, "No oops device specified.\n");
		return(1);
	}

	if ( (fd = open(argv[1], O_RDONLY)) < 0 )
	{
		fprintf(stderr, "Cannot open device: %s.\n", argv[1]);
		return(1);
	}

	if ( ioctl(fd, 1, 0) < 0 )
	{
		fprintf(stderr, "Failed on oops.\n");
		return(1);
	}

	printf("OOoops\n");

	close(fd);
	return(0);
}