2003-07-17 12:24:51 +04:00
/*
2005-03-13 00:36:32 +03:00
* udev_rules . h
2003-07-17 12:24:51 +04:00
*
* Userspace devfs
*
2004-01-27 06:21:58 +03:00
* Copyright ( C ) 2003 , 2004 Greg Kroah - Hartman < greg @ kroah . com >
2003-07-17 12:24:51 +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 version 2 of the License .
*
* 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 , write to the Free Software Foundation , Inc . ,
* 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*
*/
2005-03-13 09:14:49 +03:00
# ifndef UDEV_RULES_H
# define UDEV_RULES_H
2003-07-17 12:24:51 +04:00
2005-03-13 00:36:32 +03:00
# include "libsysfs/sysfs/libsysfs.h"
2003-08-06 10:57:23 +04:00
# include "udev.h"
2003-07-24 02:56:56 +04:00
# include "list.h"
2005-07-05 17:24:41 +04:00
# define PAIRS_MAX 5
2004-03-27 12:21:46 +03:00
# define RULEFILE_SUFFIX ".rules"
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 ,
} ;
2005-03-13 00:36:32 +03:00
struct udev_rule {
2005-07-05 17:24:41 +04:00
struct key kernel_name ;
struct key subsystem ;
struct key action ;
struct key devpath ;
struct key bus ;
struct key id ;
struct key driver ;
struct key program ;
struct key result ;
struct key modalias ;
struct key import ;
2005-07-12 16:46:36 +04:00
enum import_type import_type ;
2005-07-07 22:05:51 +04:00
struct key wait_for_sysfs ;
2005-07-05 17:24:41 +04:00
struct key_pairs sysfs ;
struct key_pairs env ;
struct key name ;
struct key symlink ;
struct key run ;
struct key owner ;
struct key group ;
2005-06-05 06:57:03 +04:00
enum key_operation mode_operation ;
2005-07-05 17:24:41 +04:00
mode_t mode ;
unsigned int partitions ;
unsigned int last_rule : 1 ,
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 {
char * buf ;
size_t bufsize ;
size_t current ;
int mapped ;
int resolve_names ;
2003-12-04 05:33:58 +03:00
} ;
2005-07-05 17:24:41 +04:00
extern int udev_rules_init ( struct udev_rules * rules , int resolve_names ) ;
extern void udev_rules_close ( struct udev_rules * rules ) ;
2005-06-24 20:05:32 +04:00
2005-07-05 17:24:41 +04:00
extern void udev_rules_iter_init ( struct udev_rules * rules ) ;
extern struct udev_rule * udev_rules_iter_next ( struct udev_rules * rules ) ;
2005-06-24 20:05:32 +04:00
2005-07-05 17:24:41 +04:00
extern int udev_rules_get_name ( struct udev_rules * rules , struct udevice * udev , struct sysfs_class_device * class_dev ) ;
extern int udev_rules_get_run ( struct udev_rules * rules , struct udevice * udev , struct sysfs_device * sysfs_device ) ;
2003-12-03 05:38:30 +03:00
2003-07-17 12:24:51 +04:00
# endif