_register_ioctl_handler()
QNX SDP8.0C Library ReferenceAPIDeveloper
Register an I/O control handler
Synopsis:
#include <ioctl.h>
int _register_ioctl_handler( _ioctl_handler_fct *function,
int command_min,
int command_max );
Arguments:
- function
- An I/O control handler function of type _ioctl_handler_fct. Its prototype is described below.
- command_min
- Specifies the first command in a range of commands that the function handles. The specified range must be continuous. For commands that fall outside the range, register additional ranges as required.
- command_max
- Specifies the last command in a range of commands that the function handles.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The _register_ioctl_handler() function registers an I/O control command handler.
The handler function prototype is:
typedef int (*_ioctl_handler_fct)( int fd,
int request,
va_list arg );
The arguments are:
- fd
- An open file descriptor for the file or device that you want to manipulate.
- request
- The I/O control command. For a list of commands, see ioctl(), vioctl().
- arg
- A variable-argument list of the additional arguments, which you must have initialized with the va_start() macro.
Like ioctl(), this handler function returns a value based on the request, or -1 if an error occurs (errno is set).
Returns:
- EOK
- Success.
- ENOMEM
- Insufficient memory to allocate internal data structures.
Examples:
static int my_ioctl_handler(const int fd, const int cmd, va_list vl)
{
/* fill in details */
errno = ENOTSUP;
return -1;
}
/* Automatic registration of the ioctl handler with libc */
static void __attribute__ ((constructor)) my_ioctl_handler_init()
{
int ret = _register_ioctl_handler(my_ioctl_handler, CMD1, CMDX);
if (ret) {
fprintf(stderr, "failed to register my ioctl handler (%d)\n", ret);
abort();
}
}
/* Automatic unregistration of the ioctl handler with libc */
static void __attribute__ ((destructor)) my_ioctl_handler_uninit()
{
_unregister_ioctl_handler(my_ioctl_handler);
}
Classification:
Safety: | |
---|---|
Cancellation point | Yes |
Signal handler | Yes |
Thread | Yes |
Page updated: