libudev.h | libudev.h | |||
---|---|---|---|---|
/* | /* | |||
* libudev - interface to udev device information | * libudev - interface to udev device information | |||
* | * | |||
* Copyright (C) 2008 Kay Sievers <kay.sievers@vrfy.org> | * Copyright (C) 2008-2009 Kay Sievers <kay.sievers@vrfy.org> | |||
* | * | |||
* This library is free software; you can redistribute it and/or | * This library is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | * modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | * License as published by the Free Software Foundation; either | |||
* version 2.1 of the License, or (at your option) any later version. | * version 2.1 of the License, or (at your option) any later version. | |||
*/ | */ | |||
#ifndef _LIBUDEV_H_ | #ifndef _LIBUDEV_H_ | |||
#define _LIBUDEV_H_ | #define _LIBUDEV_H_ | |||
#include <stdarg.h> | #include <stdarg.h> | |||
#include <sys/types.h> | #include <sys/types.h> | |||
#include <sys/stat.h> | #include <sys/stat.h> | |||
/* this will stay as long as the DeviceKit integration of udev is work in p | /* | |||
rogress */ | * udev - library context | |||
#if !defined _LIBUDEV_COMPILATION && !defined LIBUDEV_I_KNOW_THE_API_IS_SUB | * | |||
JECT_TO_CHANGE | * reads the udev config and system environment | |||
#error "#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE is needed to us | * allows custom logging | |||
e this experimental library version" | */ | |||
#endif | ||||
/* library context */ | ||||
struct udev; | struct udev; | |||
struct udev *udev_new(void); | ||||
struct udev *udev_ref(struct udev *udev); | struct udev *udev_ref(struct udev *udev); | |||
void udev_unref(struct udev *udev); | void udev_unref(struct udev *udev); | |||
struct udev *udev_new(void); | ||||
void udev_set_log_fn(struct udev *udev, | void udev_set_log_fn(struct udev *udev, | |||
void (*log_fn)(struct udev *udev, | void (*log_fn)(struct udev *udev, | |||
int priority, const char *file, i nt line, const char *fn, | int priority, const char *file, i nt line, const char *fn, | |||
const char *format, va_list args) ); | const char *format, va_list args) ); | |||
int udev_get_log_priority(struct udev *udev); | int udev_get_log_priority(struct udev *udev); | |||
void udev_set_log_priority(struct udev *udev, int priority); | void udev_set_log_priority(struct udev *udev, int priority); | |||
const char *udev_get_sys_path(struct udev *udev); | const char *udev_get_sys_path(struct udev *udev); | |||
const char *udev_get_dev_path(struct udev *udev); | const char *udev_get_dev_path(struct udev *udev); | |||
void *udev_get_userdata(struct udev *udev); | void *udev_get_userdata(struct udev *udev); | |||
void udev_set_userdata(struct udev *udev, void *userdata); | void udev_set_userdata(struct udev *udev, void *userdata); | |||
/* list iteration */ | /* | |||
* udev_list | ||||
* | ||||
* access to libudev generated lists | ||||
*/ | ||||
struct udev_list_entry; | struct udev_list_entry; | |||
struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *li st_entry); | struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *li st_entry); | |||
struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name); | struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name); | |||
const char *udev_list_entry_get_name(struct udev_list_entry *list_entry); | const char *udev_list_entry_get_name(struct udev_list_entry *list_entry); | |||
const char *udev_list_entry_get_value(struct udev_list_entry *list_entry); | const char *udev_list_entry_get_value(struct udev_list_entry *list_entry); | |||
#define udev_list_entry_foreach(entry, first) \ | /** | |||
for (entry = first; \ | * udev_list_entry_foreach: | |||
entry != NULL; \ | * @list_entry: entry to store the current position | |||
entry = udev_list_entry_get_next(entry)) | * @first_entry: first entry to start with | |||
* | ||||
* Helper to iterate over all entries of a list. | ||||
*/ | ||||
#define udev_list_entry_foreach(list_entry, first_entry) \ | ||||
for (list_entry = first_entry; \ | ||||
list_entry != NULL; \ | ||||
list_entry = udev_list_entry_get_next(list_entry)) | ||||
/* sys devices */ | /* | |||
* udev_device | ||||
* | ||||
* access to sysfs/kernel devices | ||||
*/ | ||||
struct udev_device; | struct udev_device; | |||
struct udev_device *udev_device_ref(struct udev_device *udev_device); | ||||
void udev_device_unref(struct udev_device *udev_device); | ||||
struct udev *udev_device_get_udev(struct udev_device *udev_device); | ||||
struct udev_device *udev_device_new_from_syspath(struct udev *udev, const c har *syspath); | struct udev_device *udev_device_new_from_syspath(struct udev *udev, const c har *syspath); | |||
struct udev_device *udev_device_new_from_devnum(struct udev *udev, char typ e, dev_t devnum); | struct udev_device *udev_device_new_from_devnum(struct udev *udev, char typ e, dev_t devnum); | |||
struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *ude v, const char *subsystem, const char *sysname); | struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *ude v, const char *subsystem, const char *sysname); | |||
/* udev_device_get_parent_*() does not take a reference on the returned dev ice, it is automatically unref'd with the parent */ | ||||
struct udev_device *udev_device_get_parent(struct udev_device *udev_device) ; | struct udev_device *udev_device_get_parent(struct udev_device *udev_device) ; | |||
struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct ud | struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct ud | |||
ev_device *udev_device, const char *subsystem, const char *devtype); | ev_device *udev_device, | |||
struct udev_device *udev_device_ref(struct udev_device *udev_device); | const char | |||
void udev_device_unref(struct udev_device *udev_device); | *subsystem, const char *devtype); | |||
struct udev *udev_device_get_udev(struct udev_device *udev_device); | /* retrieve device properties */ | |||
const char *udev_device_get_devpath(struct udev_device *udev_device); | const char *udev_device_get_devpath(struct udev_device *udev_device); | |||
const char *udev_device_get_subsystem(struct udev_device *udev_device); | const char *udev_device_get_subsystem(struct udev_device *udev_device); | |||
const char *udev_device_get_devtype(struct udev_device *udev_device); | const char *udev_device_get_devtype(struct udev_device *udev_device); | |||
const char *udev_device_get_syspath(struct udev_device *udev_device); | const char *udev_device_get_syspath(struct udev_device *udev_device); | |||
const char *udev_device_get_sysname(struct udev_device *udev_device); | const char *udev_device_get_sysname(struct udev_device *udev_device); | |||
const char *udev_device_get_sysnum(struct udev_device *udev_device); | const char *udev_device_get_sysnum(struct udev_device *udev_device); | |||
const char *udev_device_get_devnode(struct udev_device *udev_device); | const char *udev_device_get_devnode(struct udev_device *udev_device); | |||
struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_dev ice *udev_device); | struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_dev ice *udev_device); | |||
struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_d evice *udev_device); | struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_d evice *udev_device); | |||
const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key); | const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key); | |||
const char *udev_device_get_driver(struct udev_device *udev_device); | const char *udev_device_get_driver(struct udev_device *udev_device); | |||
dev_t udev_device_get_devnum(struct udev_device *udev_device); | dev_t udev_device_get_devnum(struct udev_device *udev_device); | |||
const char *udev_device_get_action(struct udev_device *udev_device); | const char *udev_device_get_action(struct udev_device *udev_device); | |||
unsigned long long int udev_device_get_seqnum(struct udev_device *udev_devi ce); | unsigned long long int udev_device_get_seqnum(struct udev_device *udev_devi ce); | |||
const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr); | const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr); | |||
/* udev and kernel device events */ | /* | |||
* udev_monitor | ||||
* | ||||
* access to kernel uevents and udev events | ||||
*/ | ||||
struct udev_monitor; | struct udev_monitor; | |||
struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const | ||||
char *socket_path); | ||||
struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const | ||||
char *name); | ||||
int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor); | ||||
struct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor); | struct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor); | |||
void udev_monitor_unref(struct udev_monitor *udev_monitor); | void udev_monitor_unref(struct udev_monitor *udev_monitor); | |||
struct udev *udev_monitor_get_udev(struct udev_monitor *udev_monitor); | struct udev *udev_monitor_get_udev(struct udev_monitor *udev_monitor); | |||
/* kernel and udev generated events over netlink */ | ||||
struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const | ||||
char *name); | ||||
/* custom socket (use netlink and filters instead) */ | ||||
struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const | ||||
char *socket_path); | ||||
/* bind socket */ | ||||
int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor); | ||||
int udev_monitor_get_fd(struct udev_monitor *udev_monitor); | int udev_monitor_get_fd(struct udev_monitor *udev_monitor); | |||
struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_m onitor); | struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_m onitor); | |||
int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *ud | /* in-kernel socket filters to select messages that get delivered to a list | |||
ev_monitor, const char *subsystem, const char *devtype); | ener */ | |||
int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *ud | ||||
ev_monitor, | ||||
const char *subsystem, c | ||||
onst char *devtype); | ||||
int udev_monitor_filter_update(struct udev_monitor *udev_monitor); | int udev_monitor_filter_update(struct udev_monitor *udev_monitor); | |||
int udev_monitor_filter_remove(struct udev_monitor *udev_monitor); | int udev_monitor_filter_remove(struct udev_monitor *udev_monitor); | |||
/* sys enumeration */ | /* | |||
* udev_enumerate | ||||
* | ||||
* search sysfs for specific devices and provide a sorted list | ||||
*/ | ||||
struct udev_enumerate; | struct udev_enumerate; | |||
struct udev_enumerate *udev_enumerate_new(struct udev *udev); | ||||
struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enume rate); | struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enume rate); | |||
void udev_enumerate_unref(struct udev_enumerate *udev_enumerate); | void udev_enumerate_unref(struct udev_enumerate *udev_enumerate); | |||
struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate) ; | struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate) ; | |||
struct udev_enumerate *udev_enumerate_new(struct udev *udev); | ||||
/* device properties filter */ | ||||
int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerat e, const char *subsystem); | int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerat e, const char *subsystem); | |||
int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumer ate, const char *subsystem); | int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumer ate, const char *subsystem); | |||
int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value); | int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value); | |||
int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerat e, const char *sysattr, const char *value); | int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerat e, const char *sysattr, const char *value); | |||
int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate , const char *property, const char *value); | int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate , const char *property, const char *value); | |||
int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath); | int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath); | |||
/* run enumeration with active filters */ | ||||
int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate); | int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate); | |||
int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate); | int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate); | |||
/* return device list */ | ||||
struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate); | struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate); | |||
/* event queue */ | /* | |||
* udev_queue | ||||
* | ||||
* access to the currently running udev events | ||||
*/ | ||||
struct udev_queue; | struct udev_queue; | |||
struct udev_queue *udev_queue_new(struct udev *udev); | ||||
struct udev_queue *udev_queue_ref(struct udev_queue *udev_queue); | struct udev_queue *udev_queue_ref(struct udev_queue *udev_queue); | |||
void udev_queue_unref(struct udev_queue *udev_queue); | void udev_queue_unref(struct udev_queue *udev_queue); | |||
struct udev *udev_queue_get_udev(struct udev_queue *udev_queue); | struct udev *udev_queue_get_udev(struct udev_queue *udev_queue); | |||
struct udev_queue *udev_queue_new(struct udev *udev); | ||||
unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev _queue); | unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev _queue); | |||
unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_q ueue); | unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_q ueue); | |||
int udev_queue_get_udev_is_active(struct udev_queue *udev_queue); | int udev_queue_get_udev_is_active(struct udev_queue *udev_queue); | |||
int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue); | int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue); | |||
int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsign ed long long int seqnum); | int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsign ed long long int seqnum); | |||
int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_queu | ||||
e, | ||||
unsigned long long int start, | ||||
unsigned long long int end); | ||||
struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue); | struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue); | |||
struct udev_list_entry *udev_queue_get_failed_list_entry(struct udev_queue *udev_queue); | struct udev_list_entry *udev_queue_get_failed_list_entry(struct udev_queue *udev_queue); | |||
#endif | #endif | |||
End of changes. 23 change blocks. | ||||
34 lines changed or deleted | 76 lines changed or added | |||