testcdev.c revision 41681
141681Sdfr/* 08 Nov 1998*/
241681Sdfr/*
341681Sdfr * testmisc.c
441681Sdfr *
541681Sdfr * Test program to call the sample loaded kld device driver.
641681Sdfr *
741681Sdfr * 05 Jun 93	Rajesh Vaidheeswarran		Original
841681Sdfr *
941681Sdfr *
1041681Sdfr * Copyright (c) 1993 Rajesh Vaidheeswarran.
1141681Sdfr * All rights reserved.
1241681Sdfr *
1341681Sdfr * Redistribution and use in source and binary forms, with or without
1441681Sdfr * modification, are permitted provided that the following conditions
1541681Sdfr * are met:
1641681Sdfr * 1. Redistributions of source code must retain the above copyright
1741681Sdfr *    notice, this list of conditions and the following disclaimer.
1841681Sdfr * 2. Redistributions in binary form must reproduce the above copyright
1941681Sdfr *    notice, this list of conditions and the following disclaimer in the
2041681Sdfr *    documentation and/or other materials provided with the distribution.
2141681Sdfr * 3. All advertising materials mentioning features or use of this software
2241681Sdfr *    must display the following acknowledgement:
2341681Sdfr *      This product includes software developed by Rajesh Vaidheeswarran.
2441681Sdfr * 4. The name Rajesh Vaidheeswarran may not be used to endorse or promote
2541681Sdfr *    products derived from this software without specific prior written
2641681Sdfr *    permission.
2741681Sdfr *
2841681Sdfr * THIS SOFTWARE IS PROVIDED BY RAJESH VAIDHEESWARRAN ``AS IS'' AND ANY
2941681Sdfr * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3041681Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3141681Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE RAJESH VAIDHEESWARRAN BE LIABLE
3241681Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3341681Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3441681Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3541681Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3641681Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3741681Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3841681Sdfr * SUCH DAMAGE.
3941681Sdfr *
4041681Sdfr * Copyright (c) 1993 Terrence R. Lambert.
4141681Sdfr * All rights reserved.
4241681Sdfr *
4341681Sdfr * Redistribution and use in source and binary forms, with or without
4441681Sdfr * modification, are permitted provided that the following conditions
4541681Sdfr * are met:
4641681Sdfr * 1. Redistributions of source code must retain the above copyright
4741681Sdfr *    notice, this list of conditions and the following disclaimer.
4841681Sdfr * 2. Redistributions in binary form must reproduce the above copyright
4941681Sdfr *    notice, this list of conditions and the following disclaimer in the
5041681Sdfr *    documentation and/or other materials provided with the distribution.
5141681Sdfr * 3. All advertising materials mentioning features or use of this software
5241681Sdfr *    must display the following acknowledgement:
5341681Sdfr *      This product includes software developed by Terrence R. Lambert.
5441681Sdfr * 4. The name Terrence R. Lambert may not be used to endorse or promote
5541681Sdfr *    products derived from this software without specific prior written
5641681Sdfr *    permission.
5741681Sdfr *
5841681Sdfr * THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``AS IS'' AND ANY
5941681Sdfr * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6041681Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6141681Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE TERRENCE R. LAMBERT BE LIABLE
6241681Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6341681Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6441681Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6541681Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6641681Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6741681Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6841681Sdfr * SUCH DAMAGE.
6941681Sdfr *
7041681Sdfr */
7141681Sdfr#include <stdio.h>
7241681Sdfr#include <fcntl.h>
7341681Sdfr#include <sys/ioccom.h>
7441681Sdfr
7541681Sdfr#define CDEV_IOCTL1     _IOR('C', 1, u_int)
7641681Sdfr#define CDEV_DEVICE	"cdev"
7741681Sdfrint
7841681Sdfrmain()
7941681Sdfr{
8041681Sdfr    int kernel_fd;
8141681Sdfr    int one;
8241681Sdfr
8341681Sdfr    if ((kernel_fd = open("/dev/" CDEV_DEVICE, O_RDONLY)) == -1) {
8441681Sdfr	perror("/dev/" CDEV_DEVICE);
8541681Sdfr	exit(1);
8641681Sdfr    }
8741681Sdfr
8841681Sdfr    /* Send ioctl */
8941681Sdfr    if (ioctl(kernel_fd, CDEV_IOCTL1, &one) == -1) {
9041681Sdfr	perror("CDEV_IOCTL1");
9141681Sdfr    } else {
9241681Sdfr	printf( "Sent ioctl CDEV_IOCTL1 to device /dev/" CDEV_DEVICE "\n");
9341681Sdfr    }
9441681Sdfr    exit(0);
9541681Sdfr}
96