File: ioctl.c

package info (click to toggle)
lsb-appchk3 3.2.2-1.1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 157,336 kB
  • ctags: 17,415
  • sloc: ansic: 528,541; cpp: 5,641; perl: 3,051; makefile: 801; xml: 702; python: 302; sh: 205; awk: 42
file content (47 lines) | stat: -rw-r--r-- 1,060 bytes parent folder | download | duplicates (4)
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
// Maintained by hand (Stuart Anderson, Matt Elder)

#include "../../tests/type_tests.h"
#include "../../misc/lsb_output.h"
#include <dlfcn.h>
#include <stdio.h>
#include <unistd.h>

static int(*funcptr)(int, unsigned long, ...) = 0;

/*
 * As long as an ioctl is hidden behind an LSB interface, it's OK for it
 * to be used. It's just an implementation detail.  However, it shouldn't
 * be called from outside an LSB interface.
 */

extern int __lsb_check_params;
extern int __lsb_output(int, char*, ...);
int ioctl(int fd, unsigned long request, ...)
{
	int reset_flag = __lsb_check_params;
	int ret_value;
	void *argp;
	
	va_list arg;
	va_start(arg, request);
	argp=va_arg(arg,void *);

	if(!funcptr)
		funcptr = dlsym(RTLD_NEXT, "ioctl");

	if(__lsb_check_params)
	{
	    __lsb_output(4, "ioctl()");
	    __lsb_check_params=0;
	    validate_filedescriptor(fd, "ioctl");
	    validate_ioctlreq(request, "ioctl");
	    validate_RWaddress(argp, "ioctl");
	}
	

	ret_value = funcptr(fd, request, argp);
	__lsb_check_params = reset_flag;
	return ret_value;
}