2012-11-12 20:50:33 +04:00
/***
This file is part of systemd .
Copyright 2008 - 2012 Kay Sievers < kay @ vrfy . org >
systemd is free software ; you can redistribute it and / or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation ; either version 2.1 of the License , or
( at your option ) any later version .
systemd is distributed in the hope that it will be useful , but
WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
Lesser General Public License for more details .
You should have received a copy of the GNU Lesser General Public License
along with systemd ; If not , see < http : //www.gnu.org/licenses/>.
* * */
2008-08-27 19:11:58 +04:00
# ifndef _LIBUDEV_H_
# define _LIBUDEV_H_
2008-09-06 17:45:31 +04:00
# include <stdarg.h>
2008-12-16 16:48:33 +03:00
# include <sys/types.h>
2008-09-06 17:45:31 +04:00
2009-12-14 23:15:20 +03:00
# ifdef __cplusplus
extern " C " {
# endif
2009-06-08 21:31:07 +04:00
/*
* udev - library context
2012-01-06 01:41:45 +04:00
*
2009-06-08 21:31:07 +04:00
* reads the udev config and system environment
* allows custom logging
*/
2008-09-28 03:34:55 +04:00
struct udev ;
2009-04-26 15:59:39 +04:00
struct udev * udev_ref ( struct udev * udev ) ;
2012-05-16 00:57:58 +04:00
struct udev * udev_unref ( struct udev * udev ) ;
2009-06-08 21:31:07 +04:00
struct udev * udev_new ( void ) ;
2009-04-26 15:59:39 +04:00
void udev_set_log_fn ( struct udev * udev ,
2012-01-10 04:34:15 +04:00
void ( * log_fn ) ( struct udev * udev ,
int priority , const char * file , int line , const char * fn ,
2014-11-13 15:11:04 +03:00
const char * format , va_list args ) ) __attribute__ ( ( deprecated ) ) ;
int udev_get_log_priority ( struct udev * udev ) __attribute__ ( ( deprecated ) ) ;
void udev_set_log_priority ( struct udev * udev , int priority ) __attribute__ ( ( deprecated ) ) ;
2009-04-26 15:59:39 +04:00
void * udev_get_userdata ( struct udev * udev ) ;
void udev_set_userdata ( struct udev * udev , void * userdata ) ;
2008-09-25 08:39:29 +04:00
2009-06-08 21:31:07 +04:00
/*
* udev_list
*
* access to libudev generated lists
*/
2008-09-28 03:34:55 +04:00
struct udev_list_entry ;
2009-04-26 15:59:39 +04:00
struct udev_list_entry * udev_list_entry_get_next ( struct udev_list_entry * list_entry ) ;
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_value ( struct udev_list_entry * list_entry ) ;
2009-06-15 15:22:38 +04:00
/**
* udev_list_entry_foreach :
* @ list_entry : entry to store the current position
* @ 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) \
2012-01-10 04:34:15 +04:00
for ( list_entry = first_entry ; \
list_entry ! = NULL ; \
list_entry = udev_list_entry_get_next ( list_entry ) )
2008-09-25 15:20:27 +04:00
2009-06-08 21:31:07 +04:00
/*
* udev_device
*
* access to sysfs / kernel devices
*/
2008-09-28 03:34:55 +04:00
struct udev_device ;
2009-06-08 21:31:07 +04:00
struct udev_device * udev_device_ref ( struct udev_device * udev_device ) ;
2012-05-16 00:57:58 +04:00
struct udev_device * udev_device_unref ( struct udev_device * udev_device ) ;
2009-06-08 21:31:07 +04:00
struct udev * udev_device_get_udev ( struct udev_device * udev_device ) ;
2009-04-26 15:59:39 +04:00
struct udev_device * udev_device_new_from_syspath ( struct udev * udev , const char * syspath ) ;
struct udev_device * udev_device_new_from_devnum ( struct udev * udev , char type , dev_t devnum ) ;
struct udev_device * udev_device_new_from_subsystem_sysname ( struct udev * udev , const char * subsystem , const char * sysname ) ;
2013-07-02 00:34:43 +04:00
struct udev_device * udev_device_new_from_device_id ( struct udev * udev , const char * id ) ;
2010-03-17 19:42:35 +03:00
struct udev_device * udev_device_new_from_environment ( struct udev * udev ) ;
2009-06-08 21:31:07 +04:00
/* udev_device_get_parent_*() does not take a reference on the returned device, it is automatically unref'd with the parent */
2009-04-26 15:59:39 +04:00
struct udev_device * udev_device_get_parent ( struct udev_device * udev_device ) ;
2009-06-08 21:31:07 +04:00
struct udev_device * udev_device_get_parent_with_subsystem_devtype ( struct udev_device * udev_device ,
2012-01-10 04:34:15 +04:00
const char * subsystem , const char * devtype ) ;
2009-06-08 21:31:07 +04:00
/* retrieve device properties */
2009-04-26 15:59:39 +04:00
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_devtype ( 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_sysnum ( struct udev_device * udev_device ) ;
const char * udev_device_get_devnode ( struct udev_device * udev_device ) ;
2010-12-14 16:18:32 +03:00
int udev_device_get_is_initialized ( struct udev_device * udev_device ) ;
2009-04-26 15:59:39 +04:00
struct udev_list_entry * udev_device_get_devlinks_list_entry ( struct udev_device * udev_device ) ;
struct udev_list_entry * udev_device_get_properties_list_entry ( struct udev_device * udev_device ) ;
2010-04-23 18:05:38 +04:00
struct udev_list_entry * udev_device_get_tags_list_entry ( struct udev_device * udev_device ) ;
2011-03-04 19:06:41 +03:00
struct udev_list_entry * udev_device_get_sysattr_list_entry ( struct udev_device * udev_device ) ;
2009-04-26 15:59:39 +04:00
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 ) ;
dev_t udev_device_get_devnum ( 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_device ) ;
2010-12-15 10:57:46 +03:00
unsigned long long int udev_device_get_usec_since_initialized ( struct udev_device * udev_device ) ;
2009-04-26 15:59:39 +04:00
const char * udev_device_get_sysattr_value ( struct udev_device * udev_device , const char * sysattr ) ;
2013-03-11 15:49:27 +04:00
int udev_device_set_sysattr_value ( struct udev_device * udev_device , const char * sysattr , char * value ) ;
2011-07-07 23:31:50 +04:00
int udev_device_has_tag ( struct udev_device * udev_device , const char * tag ) ;
2008-08-27 19:11:58 +04:00
2009-06-08 21:31:07 +04:00
/*
* udev_monitor
*
* access to kernel uevents and udev events
*/
2008-09-28 03:34:55 +04:00
struct udev_monitor ;
2009-04-26 15:59:39 +04:00
struct udev_monitor * udev_monitor_ref ( struct udev_monitor * udev_monitor ) ;
2012-05-16 00:57:58 +04:00
struct udev_monitor * udev_monitor_unref ( struct udev_monitor * udev_monitor ) ;
2009-04-26 15:59:39 +04:00
struct udev * udev_monitor_get_udev ( struct udev_monitor * udev_monitor ) ;
2009-06-08 21:31:07 +04:00
/* kernel and udev generated events over netlink */
struct udev_monitor * udev_monitor_new_from_netlink ( struct udev * udev , const char * name ) ;
/* bind socket */
int udev_monitor_enable_receiving ( struct udev_monitor * udev_monitor ) ;
2010-02-17 18:26:00 +03:00
int udev_monitor_set_receive_buffer_size ( struct udev_monitor * udev_monitor , int size ) ;
2009-04-26 15:59:39 +04:00
int udev_monitor_get_fd ( struct udev_monitor * udev_monitor ) ;
struct udev_device * udev_monitor_receive_device ( struct udev_monitor * udev_monitor ) ;
2009-06-08 21:31:07 +04:00
/* in-kernel socket filters to select messages that get delivered to a listener */
int udev_monitor_filter_add_match_subsystem_devtype ( struct udev_monitor * udev_monitor ,
2012-01-10 04:34:15 +04:00
const char * subsystem , const char * devtype ) ;
2010-04-22 20:12:36 +04:00
int udev_monitor_filter_add_match_tag ( struct udev_monitor * udev_monitor , const char * tag ) ;
2009-04-26 15:59:39 +04:00
int udev_monitor_filter_update ( struct udev_monitor * udev_monitor ) ;
int udev_monitor_filter_remove ( struct udev_monitor * udev_monitor ) ;
2008-08-29 01:05:01 +04:00
2009-06-08 21:31:07 +04:00
/*
* udev_enumerate
*
* search sysfs for specific devices and provide a sorted list
*/
2008-09-28 03:34:55 +04:00
struct udev_enumerate ;
2009-04-26 15:59:39 +04:00
struct udev_enumerate * udev_enumerate_ref ( struct udev_enumerate * udev_enumerate ) ;
2012-05-16 00:57:58 +04:00
struct udev_enumerate * udev_enumerate_unref ( struct udev_enumerate * udev_enumerate ) ;
2009-04-26 15:59:39 +04:00
struct udev * udev_enumerate_get_udev ( struct udev_enumerate * udev_enumerate ) ;
2009-06-08 21:31:07 +04:00
struct udev_enumerate * udev_enumerate_new ( struct udev * udev ) ;
/* device properties filter */
2009-04-26 15:59:39 +04:00
int udev_enumerate_add_match_subsystem ( struct udev_enumerate * udev_enumerate , const char * subsystem ) ;
int udev_enumerate_add_nomatch_subsystem ( struct udev_enumerate * udev_enumerate , const char * subsystem ) ;
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_enumerate , const char * sysattr , const char * value ) ;
int udev_enumerate_add_match_property ( struct udev_enumerate * udev_enumerate , const char * property , const char * value ) ;
2009-07-23 02:02:28 +04:00
int udev_enumerate_add_match_sysname ( struct udev_enumerate * udev_enumerate , const char * sysname ) ;
2010-04-22 20:12:36 +04:00
int udev_enumerate_add_match_tag ( struct udev_enumerate * udev_enumerate , const char * tag ) ;
2011-07-08 02:42:35 +04:00
int udev_enumerate_add_match_parent ( struct udev_enumerate * udev_enumerate , struct udev_device * parent ) ;
2010-12-14 16:18:32 +03:00
int udev_enumerate_add_match_is_initialized ( struct udev_enumerate * udev_enumerate ) ;
2009-04-26 15:59:39 +04:00
int udev_enumerate_add_syspath ( struct udev_enumerate * udev_enumerate , const char * syspath ) ;
2009-06-08 21:31:07 +04:00
/* run enumeration with active filters */
2009-04-26 15:59:39 +04:00
int udev_enumerate_scan_devices ( struct udev_enumerate * udev_enumerate ) ;
int udev_enumerate_scan_subsystems ( struct udev_enumerate * udev_enumerate ) ;
2009-06-08 21:31:07 +04:00
/* return device list */
2009-04-26 15:59:39 +04:00
struct udev_list_entry * udev_enumerate_get_list_entry ( struct udev_enumerate * udev_enumerate ) ;
2008-09-28 03:34:55 +04:00
2009-06-08 21:31:07 +04:00
/*
* udev_queue
*
* access to the currently running udev events
*/
2008-10-01 11:34:07 +04:00
struct udev_queue ;
2009-04-26 15:59:39 +04:00
struct udev_queue * udev_queue_ref ( struct udev_queue * udev_queue ) ;
2012-05-16 00:57:58 +04:00
struct udev_queue * udev_queue_unref ( struct udev_queue * udev_queue ) ;
2009-04-26 15:59:39 +04:00
struct udev * udev_queue_get_udev ( struct udev_queue * udev_queue ) ;
2009-06-08 21:31:07 +04:00
struct udev_queue * udev_queue_new ( struct udev * udev ) ;
2014-04-13 09:35:50 +04:00
unsigned long long int udev_queue_get_kernel_seqnum ( struct udev_queue * udev_queue ) __attribute__ ( ( deprecated ) ) ;
unsigned long long int udev_queue_get_udev_seqnum ( struct udev_queue * udev_queue ) __attribute__ ( ( deprecated ) ) ;
2009-04-26 15:59:39 +04:00
int udev_queue_get_udev_is_active ( struct udev_queue * udev_queue ) ;
int udev_queue_get_queue_is_empty ( struct udev_queue * udev_queue ) ;
2014-04-13 09:35:50 +04:00
int udev_queue_get_seqnum_is_finished ( struct udev_queue * udev_queue , unsigned long long int seqnum ) __attribute__ ( ( deprecated ) ) ;
2009-05-22 00:22:37 +04:00
int udev_queue_get_seqnum_sequence_is_finished ( struct udev_queue * udev_queue ,
2014-04-13 09:35:50 +04:00
unsigned long long int start , unsigned long long int end ) __attribute__ ( ( deprecated ) ) ;
2014-06-27 19:42:44 +04:00
int udev_queue_get_fd ( struct udev_queue * udev_queue ) ;
int udev_queue_flush ( struct udev_queue * udev_queue ) ;
2014-04-13 09:35:50 +04:00
struct udev_list_entry * udev_queue_get_queued_list_entry ( struct udev_queue * udev_queue ) __attribute__ ( ( deprecated ) ) ;
2009-12-14 23:15:20 +03:00
2012-10-27 22:59:01 +04:00
/*
* udev_hwdb
*
* access to the static hardware properties database
*/
struct udev_hwdb ;
struct udev_hwdb * udev_hwdb_new ( struct udev * udev ) ;
struct udev_hwdb * udev_hwdb_ref ( struct udev_hwdb * hwdb ) ;
struct udev_hwdb * udev_hwdb_unref ( struct udev_hwdb * hwdb ) ;
struct udev_list_entry * udev_hwdb_get_properties_list_entry ( struct udev_hwdb * hwdb , const char * modalias , unsigned int flags ) ;
2011-10-06 03:10:59 +04:00
/*
* udev_util
*
* udev specific utilities
*/
int udev_util_encode_string ( const char * str , char * str_enc , size_t len ) ;
2009-12-14 23:15:20 +03:00
# ifdef __cplusplus
} /* extern "C" */
# endif
2008-08-27 19:11:58 +04:00
# endif