2003-07-17 12:24:51 +04:00
/*
2005-07-22 20:35:58 +04:00
* Copyright ( C ) 2003 - 2004 Greg Kroah - Hartman < greg @ kroah . com >
2008-09-10 04:40:42 +04:00
* Copyright ( C ) 2004 - 2008 Kay Sievers < kay . sievers @ vrfy . org >
2003-07-17 12:24:51 +04:00
*
2008-09-10 04:40:42 +04:00
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 2 of the License , or
* ( at your option ) any later version .
2003-07-17 12:24:51 +04:00
*
2008-09-10 04:40:42 +04:00
* This program 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 General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-07-17 12:24:51 +04:00
*/
2005-03-13 09:14:49 +03:00
# ifndef UDEV_RULES_H
# define UDEV_RULES_H
2003-07-17 12:24:51 +04:00
2003-08-06 10:57:23 +04:00
# include "udev.h"
2003-07-24 02:56:56 +04:00
2005-07-05 17:24:41 +04:00
# define PAIRS_MAX 5
2004-02-24 06:31:14 +03:00
2005-03-13 07:46:31 +03:00
enum key_operation {
2005-03-28 14:20:05 +04:00
KEY_OP_UNSET ,
2005-03-13 07:46:31 +03:00
KEY_OP_MATCH ,
KEY_OP_NOMATCH ,
KEY_OP_ADD ,
KEY_OP_ASSIGN ,
2005-06-05 06:57:03 +04:00
KEY_OP_ASSIGN_FINAL ,
2005-03-13 07:46:31 +03:00
} ;
2005-07-05 17:24:41 +04:00
struct key {
2005-03-13 07:46:31 +03:00
enum key_operation operation ;
2005-07-05 17:24:41 +04:00
size_t val_off ;
} ;
struct key_pair {
struct key key ;
size_t key_name_off ;
} ;
struct key_pairs {
int count ;
struct key_pair keys [ PAIRS_MAX ] ;
2003-12-23 09:31:35 +03:00
} ;
2003-07-24 02:56:56 +04:00
2005-07-12 16:46:36 +04:00
enum import_type {
IMPORT_UNSET ,
IMPORT_PROGRAM ,
IMPORT_FILE ,
IMPORT_PARENT ,
} ;
2007-06-22 03:27:02 +04:00
enum escape_type {
ESCAPE_UNSET ,
ESCAPE_NONE ,
ESCAPE_REPLACE ,
} ;
2005-03-13 00:36:32 +03:00
struct udev_rule {
2005-07-05 17:24:41 +04:00
struct key action ;
struct key devpath ;
2006-08-19 18:06:25 +04:00
struct key kernel ;
struct key subsystem ;
2005-07-05 17:24:41 +04:00
struct key driver ;
2006-08-19 18:06:25 +04:00
struct key_pairs attr ;
struct key kernels ;
struct key subsystems ;
struct key drivers ;
struct key_pairs attrs ;
struct key_pairs env ;
2005-07-05 17:24:41 +04:00
struct key program ;
struct key result ;
struct key import ;
2005-07-12 16:46:36 +04:00
enum import_type import_type ;
2007-06-03 02:01:46 +04:00
struct key test ;
mode_t test_mode_mask ;
2006-08-19 18:06:25 +04:00
struct key run ;
2008-05-20 17:02:17 +04:00
struct key wait_for ;
2006-08-19 18:06:25 +04:00
struct key label ;
struct key goto_label ;
2005-07-05 17:24:41 +04:00
struct key name ;
struct key symlink ;
2007-07-16 15:29:28 +04:00
struct key symlink_match ;
2005-07-05 17:24:41 +04:00
struct key owner ;
struct key group ;
2008-04-18 23:07:29 +04:00
struct key mode ;
2007-06-22 03:27:02 +04:00
enum escape_type string_escape ;
2005-07-05 17:24:41 +04:00
2007-03-16 17:16:08 +03:00
unsigned int link_priority ;
2008-04-21 21:00:54 +04:00
int event_timeout ;
2005-07-05 17:24:41 +04:00
unsigned int partitions ;
unsigned int last_rule : 1 ,
2007-07-14 22:43:01 +04:00
run_ignore_error : 1 ,
2005-07-05 17:24:41 +04:00
ignore_device : 1 ,
2005-07-12 16:46:36 +04:00
ignore_remove : 1 ;
2005-02-14 08:03:06 +03:00
2005-07-05 17:24:41 +04:00
size_t bufsize ;
char buf [ ] ;
} ;
2005-02-14 08:03:06 +03:00
2005-07-05 17:24:41 +04:00
struct udev_rules {
2008-09-06 17:45:31 +04:00
struct udev * udev ;
2005-07-05 17:24:41 +04:00
char * buf ;
size_t bufsize ;
int resolve_names ;
2003-12-04 05:33:58 +03:00
} ;
2008-09-09 02:09:49 +04:00
struct udev_rules_iter {
struct udev_rules * rules ;
size_t current ;
} ;
2008-09-06 17:45:31 +04:00
extern int udev_rules_init ( struct udev * udev , struct udev_rules * rules , int resolve_names ) ;
2006-01-09 23:18:00 +03:00
extern void udev_rules_cleanup ( struct udev_rules * rules ) ;
2005-06-24 20:05:32 +04:00
2008-09-09 02:09:49 +04:00
extern void udev_rules_iter_init ( struct udev_rules_iter * iter , struct udev_rules * rules ) ;
extern struct udev_rule * udev_rules_iter_next ( struct udev_rules_iter * iter ) ;
extern struct udev_rule * udev_rules_iter_label ( struct udev_rules_iter * iter , const char * label ) ;
2005-06-24 20:05:32 +04:00
2006-01-09 23:18:00 +03:00
extern int udev_rules_get_name ( struct udev_rules * rules , struct udevice * udev ) ;
extern int udev_rules_get_run ( struct udev_rules * rules , struct udevice * udev ) ;
2007-07-14 22:44:19 +04:00
extern int udev_rules_run ( struct udevice * udev ) ;
2003-12-03 05:38:30 +03:00
2006-01-25 03:28:31 +03:00
extern void udev_rules_apply_format ( struct udevice * udev , char * string , size_t maxsize ) ;
2003-07-17 12:24:51 +04:00
# endif