• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  *   Copyright (c) International Business Machines  Corp., 2001
4  *
5  *   This program is free software;  you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation; either version 2 of the License, or
8  *   (at your option) any later version.
9  *
10  *   This program is distributed in the hope that it will be useful,
11  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13  *   the GNU General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License
16  *   along with this program;  if not, write to the Free Software
17  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19 
20  * This file will include user space functions that will drive
21  * the kernel module to test various functions and kernel
22  * calls. Each function will need to setup the tif structure
23  * so that the in parameters and out parameters are correctly
24  * initialized
25  *
26  * use tif structure for passing params between user
27  * space and kernel space, in some tests it is really not
28  * needed, and if nothing is needed to pass in utilize
29  * the ki_generic function below. the tif structure makes
30  * it easy to maintain all the tests if they have the same
31  * process in kernel space to read in params in the kernel
32  * module no matter what the test is
33  *
34  * author: Sean Ruyle
35  * date:   06/11/2003
36  *
37  * tmod_ki.c
38  */
39 
40 #include <stdlib.h>
41 #include <stdio.h>
42 #include <sys/ioctl.h>
43 #include "../tbase/tbase.h"
44 
ki_generic(int fd,int flag)45 int ki_generic(int fd, int flag)
46 {
47 	int rc;
48 	tmod_interface_t tif;
49 
50 	/*
51 	 * build interface structure
52 	 */
53 	tif.in_len = 0;
54 	tif.in_data = 0;
55 	tif.out_len = 0;
56 	tif.out_data = 0;
57 	tif.out_rc = 0;
58 
59 	/*
60 	 * ioctl call for flag
61 	 */
62 	rc = ioctl(fd, flag, &tif);
63 	if (rc) {
64 		printf("Ioctl error\n");
65 		return rc;
66 	}
67 	if (tif.out_rc)
68 		return tif.out_rc;
69 
70 	return rc;
71 }
72