libexplain  1.4.D001
Data Structures | Defines | Typedefs | Functions
libexplain/iocontrol.h File Reference

Go to the source code of this file.

Data Structures

struct  explain_iocontrol_t

Defines

#define NOT_A_POINTER   (unsigned)(-1)
#define VOID_STAR   (unsigned)(-2)
#define IOCONTROL_FLAG_SIZE_DOES_NOT_AGREE   0x0001
#define IOCONTROL_FLAG_NON_META   0x0002
#define IOCONTROL_FLAG_RW   0x0004
#define DISAMBIGUATE_USE   0
#define DISAMBIGUATE_DO_NOT_USE   -1

Typedefs

typedef struct explain_iocontrol_t explain_iocontrol_t
typedef void(* expain_iocontrol_print_func_t )(const explain_iocontrol_t *p, struct explain_string_buffer_t *sb, int errnum, int fildes, int request, const void *data)

Functions

const explain_iocontrol_texplain_iocontrol_find_by_number (int fildes, int request, const void *data)
const explain_iocontrol_texplain_iocontrol_request_by_name (const char *name)
void explain_iocontrol_print_name (const explain_iocontrol_t *p, struct explain_string_buffer_t *sb, int errnum, int fildes, int request, const void *data)
void explain_iocontrol_print_data (const explain_iocontrol_t *p, struct explain_string_buffer_t *sb, int errnum, int fildes, int request, const void *data)
void explain_iocontrol_print_explanation (const explain_iocontrol_t *p, struct explain_string_buffer_t *sb, int errnum, int fildes, int request, const void *data)
int explain_parse_ioctl_request_or_die (const char *text)
void explain_iocontrol_statistics (int *total, int *active)
void explain_iocontrol_check_conflicts (void)
int explain_iocontrol_disambiguate_true (int fildes, int request, const void *data)
int explain_iocontrol_disambiguate_false (int fildes, int request, const void *data)
int explain_iocontrol_disambiguate_is_a_socket (int fildes, int request, const void *data)
int explain_iocontrol_disambiguate_is_not_a_socket (int fildes, int request, const void *data)
int explain_iocontrol_disambiguate_is_if_eql (int fildes, int request, const void *data)
int explain_iocontrol_disambiguate_is_v4l2 (int fildes, int request, const void *data)
int explain_iocontrol_disambiguate_scc (int fildes, int request, const void *data)
int explain_iocontrol_disambiguate_net_dev_name (int fildes, const char *name)

Define Documentation

#define DISAMBIGUATE_DO_NOT_USE   -1

The DISAMBIGUATE_DO_NOT_USE symbol is used to indicate that a disambiguate function returns a negative result, the iocontrol entry shall not be used.

Definition at line 435 of file iocontrol.h.

#define DISAMBIGUATE_USE   0

The DISAMBIGUATE_USE symbol is used to indicate that a disambiguate function returns an OK result, the iocontrol entry can be used.

Definition at line 428 of file iocontrol.h.

#define IOCONTROL_FLAG_NON_META   0x0002

The IOCONTROL_FLAG_NON_META flag value indicates that the request is just a random number, and was not defined using the _IOC(a,b,c) macro, and thus it contains no useful meta-data for checking size and direction.

Definition at line 416 of file iocontrol.h.

#define IOCONTROL_FLAG_RW   0x0004

The IOCONTROL_FLAG_RW flag is used to indicate that _IOR() is actually _IORW() in behaviour.

Definition at line 422 of file iocontrol.h.

The IOCONTROL_FLAG_SIZE_DOES_NOT_AGREE flag value indicares the the size in the define from IOC(a,b,c) does not correspond to the actual data type used in the kernel.

Definition at line 408 of file iocontrol.h.

#define NOT_A_POINTER   (unsigned)(-1)

The NOT_A_POINTER value is assigned to an iocontrol::data_size member to indicate that a given ioctl does not take a pointer argument.

Definition at line 399 of file iocontrol.h.

#define VOID_STAR   (unsigned)(-2)

Definition at line 401 of file iocontrol.h.


Typedef Documentation

typedef void(* expain_iocontrol_print_func_t)(const explain_iocontrol_t *p, struct explain_string_buffer_t *sb, int errnum, int fildes, int request, const void *data)

The expain_iocontrol_print_func_t type is used to represent a pointer to a function that prints somethign related to an ioctl request.

Parameters:
pPointer to the explain_iocontrol_t instance, rather like "this" in C++ code.
sbThe string buffer to print into.
errnumThe error number that caused all this, obtained from the global errno variable, possibly indirectly.
fildesThe original fildes, exactly as passed to the ioctl(2) system call.
requestThe original request, exactly as passed to the ioctl(2) system call.
dataThe original data, exactly as passed to the ioctl(2) system call.

Definition at line 46 of file iocontrol.h.

Definition at line 24 of file iocontrol.h.


Function Documentation

The explain_iocontrol_check_conflicts function is sued to verify that there are no un-expected ioctl request number conflicts. (Expected conflicts have disambiguate functions defined.)

Definition at line 64 of file check_conflicts.c.

int explain_iocontrol_disambiguate_false ( int  fildes,
int  request,
const void *  data 
)

For use by individual ioctl handlers, a disambiguation that always reports failure (-1). See explain_iocontrol.disambiguate, above.

Definition at line 25 of file false.c.

int explain_iocontrol_disambiguate_is_a_socket ( int  fildes,
int  request,
const void *  data 
)

For use by individual ioctl handlers, a disambiguation that reports success (0) for sockets, and failure (-1) otherwise.

Definition at line 27 of file is_a_socket.c.

int explain_iocontrol_disambiguate_is_if_eql ( int  fildes,
int  request,
const void *  data 
)

For use by individual ioctl handlers, a disambiguation that reports failure (-1) for almost everything, and success (0) for "eql" network devices.

Definition at line 26 of file if_eql.c.

int explain_iocontrol_disambiguate_is_not_a_socket ( int  fildes,
int  request,
const void *  data 
)

For use by individual ioctl handlers, a disambiguation that reports failure (-1) for sockets, and success (0) otherwise.

Definition at line 27 of file is_not_a_socket.c.

int explain_iocontrol_disambiguate_is_v4l2 ( int  fildes,
int  request,
const void *  data 
)

For use by individual ioctl handlers, a disambiguation that reports failure (-1) for almost everything, and success (0) for "eql" network devices.

Definition at line 27 of file is_v4l2.c.

int explain_iocontrol_disambiguate_net_dev_name ( int  fildes,
const char *  name 
)

The explain_iocontrol_disambiguate_net_dev_name helper function is used to decide whether or not a file descriptor is associated with a network device of the given name.

Parameters:
fildesThe file descriptor if interest
nameThe name of the network device of interest. The actual network device could also have an optional trailing number (e.g. name="eth" will also match "eth0").
Returns:
DISAMBIGUATE_USE if the name matches, or DISAMBIGUATE_DO_NOT_USE if the name does not match.

Definition at line 30 of file net_dev_name.c.

int explain_iocontrol_disambiguate_scc ( int  fildes,
int  request,
const void *  data 
)

The explain_iocontrol_disambiguate_scc function is used to test for a Z8530 SCC device, i.e. "scc" network devices.

Parameters:
fildesThe file descriptor to test,
requestprobably not relevant
dataprobably not relevant
Returns:
0 if is a Z8530 device, -1 if anything else.

Definition at line 24 of file scc.c.

int explain_iocontrol_disambiguate_true ( int  fildes,
int  request,
const void *  data 
)

For use by individual ioctl handlers, a disambiguation that always reports success (0). See explain_iocontrol.disambiguate, above.

Definition at line 25 of file true.c.

const explain_iocontrol_t* explain_iocontrol_find_by_number ( int  fildes,
int  request,
const void *  data 
)

The explain_iocontrol_find_by_number function may be used to locate an ioctl by number. A few ioctl(2) calls are ambiguous, so the more information you can give the better.

Parameters:
fildesThe file descriptor the ioctl(2) call is made against
requestThe request passed to the ioctl(2) system call.
dataThe data passed to the ioctl(2) system call.
Returns:
a pointer to an iocontrol object, that may be used to describe the call the ioctl(2) system call.

Definition at line 26 of file request_by_number.c.

void explain_iocontrol_print_data ( const explain_iocontrol_t p,
struct explain_string_buffer_t sb,
int  errnum,
int  fildes,
int  request,
const void *  data 
)

The explain_iocontrol_print_data function is used to print a representation of the data argument passed to an ioctl(2) system call.

Parameters:
pPointer to the explain_iocontrol_t instance, rather like "this" in C++ code.
sbThe string buffer to print into.
errnumThe error number that caused all this, obtained from the global errno variable, possibly indirectly.
fildesThe original fildes, exactly as passed to the ioctl(2) system call.
requestThe original request, exactly as passed to the ioctl(2) system call.
dataThe original data, exactly as passed to the ioctl(2) system call.

Definition at line 28 of file print_data.c.

void explain_iocontrol_print_explanation ( const explain_iocontrol_t p,
struct explain_string_buffer_t sb,
int  errnum,
int  fildes,
int  request,
const void *  data 
)

The explain_iocontrol_print_explanation function is used to print an explanation for an error reported by an ioctl(2) system call.

Parameters:
pPointer to the explain_iocontrol_t instance, rather like "this" in C++ code.
sbThe string buffer to print into.
errnumThe error number that caused all this, obtained from the global errno variable, possibly indirectly.
fildesThe original fildes, exactly as passed to the ioctl(2) system call.
requestThe original request, exactly as passed to the ioctl(2) system call.
dataThe original data, exactly as passed to the ioctl(2) system call.

Definition at line 26 of file print_explanation.c.

void explain_iocontrol_print_name ( const explain_iocontrol_t p,
struct explain_string_buffer_t sb,
int  errnum,
int  fildes,
int  request,
const void *  data 
)

The explain_iocontrol_print_name function is used to print the name of a request argument passed to an ioctl(2) system call.

Parameters:
pPointer to the explain_iocontrol_t instance, rather like "this" in C++ code.
sbThe string buffer to print into.
errnumThe error number that caused all this, obtained from the global errno variable, possibly indirectly.
fildesThe original fildes, exactly as passed to the ioctl(2) system call.
requestThe original request, exactly as passed to the ioctl(2) system call.
dataThe original data, exactly as passed to the ioctl(2) system call.

Definition at line 28 of file print_name.c.

The explain_iocontrol_request_by_name function may be used to locate an ioctl by name.

Parameters:
nameThe name of the ioctl(2) request.
Returns:
a pointer to an iocontrol object, that may be used to describe the call the ioctl(2) system call; or NULL if not found.

Definition at line 27 of file request_by_name.c.

void explain_iocontrol_statistics ( int *  total,
int *  active 
)

The explain_iocontrol_statistics function is used to obtaion statistics about the ioctl commands supported by libexplain.

Parameters:
totalThe total number of ioctls understood by libexplain.
activeThe number of ioctls relevant to this system. assert(active <= total)

Definition at line 25 of file statistics.c.

int explain_parse_ioctl_request_or_die ( const char *  text)

The explain_parse_ioctl_request_or_die function is used to parse a text string to produce an ioctl(2) request value.

Parameters:
textThe text string to be parsed.
Returns:
On success, the ioctl(2) request value; on failure, this function does not return, but instead prints an error message and terminates via exit(2).

Definition at line 28 of file parse_request_or_die.c.