X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_rules.h;h=4ecada1c039dba3632d5b32e779dc1af1857016d;hp=423a6f641ecb1f24632c4c5eeeecc595caf0e44a;hb=8bd41f36f793f7fc208ef6beb4b2b84e35a5e728;hpb=3e5958dee5f24283eb5c6a2d2d95e1a39428a3b8 diff --git a/udev_rules.h b/udev_rules.h index 423a6f641..4ecada1c0 100644 --- a/udev_rules.h +++ b/udev_rules.h @@ -27,88 +27,81 @@ #include "udev.h" #include "list.h" - -#define KEY_KERNEL "KERNEL" -#define KEY_SUBSYSTEM "SUBSYSTEM" -#define KEY_BUS "BUS" -#define KEY_ID "ID" -#define KEY_PROGRAM "PROGRAM" -#define KEY_RESULT "RESULT" -#define KEY_DRIVER "DRIVER" -#define KEY_SYSFS "SYSFS" -#define KEY_ENV "ENV" -#define KEY_NAME "NAME" -#define KEY_SYMLINK "SYMLINK" -#define KEY_OWNER "OWNER" -#define KEY_GROUP "GROUP" -#define KEY_MODE "MODE" -#define KEY_OPTIONS "OPTIONS" - -#define OPTION_LAST_RULE "last_rule" -#define OPTION_IGNORE_DEVICE "ignore_device" -#define OPTION_IGNORE_REMOVE "ignore_remove" -#define OPTION_PARTITIONS "all_partitions" - -#define KEY_SYSFS_PAIRS_MAX 5 -#define KEY_ENV_PAIRS_MAX 5 - +#define PAIRS_MAX 5 #define RULEFILE_SUFFIX ".rules" enum key_operation { - KEY_OP_UNKNOWN, + KEY_OP_UNSET, KEY_OP_MATCH, KEY_OP_NOMATCH, KEY_OP_ADD, KEY_OP_ASSIGN, + KEY_OP_ASSIGN_FINAL, }; -struct key_pair { - char name[NAME_SIZE]; - char value[VALUE_SIZE]; +struct key { enum key_operation operation; + 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]; }; struct udev_rule { - struct list_head node; - - char kernel[NAME_SIZE]; - enum key_operation kernel_operation; - char subsystem[NAME_SIZE]; - enum key_operation subsystem_operation; - char bus[NAME_SIZE]; - enum key_operation bus_operation; - char id[NAME_SIZE]; - enum key_operation id_operation; - char driver[NAME_SIZE]; - enum key_operation driver_operation; - char program[PATH_SIZE]; - enum key_operation program_operation; - char result[PATH_SIZE]; - enum key_operation result_operation; - struct key_pair sysfs_pair[KEY_SYSFS_PAIRS_MAX]; - int sysfs_pair_count; - struct key_pair env_pair[KEY_ENV_PAIRS_MAX]; - int env_pair_count; - - char name[PATH_SIZE]; - char symlink[PATH_SIZE]; - char owner[USER_SIZE]; - char group[USER_SIZE]; + 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; + struct key_pairs sysfs; + struct key_pairs env; + + struct key name; + struct key symlink; + struct key run; + struct key owner; + struct key group; + enum key_operation mode_operation; mode_t mode; - int last_rule; - int ignore_device; - int ignore_remove; - int partitions; + unsigned int partitions; + unsigned int last_rule:1, + ignore_device:1, + ignore_remove:1, + import_exec:1; - char config_file[PATH_SIZE]; - int config_line; + size_t bufsize; + char buf[]; }; -extern struct list_head udev_rule_list; +struct udev_rules { + char *buf; + size_t bufsize; + size_t current; + int mapped; + int resolve_names; +}; + +extern int udev_rules_init(struct udev_rules *rules, int resolve_names); +extern void udev_rules_close(struct udev_rules *rules); + +extern void udev_rules_iter_init(struct udev_rules *rules); +extern struct udev_rule *udev_rules_iter_next(struct udev_rules *rules); -extern int udev_rules_init(void); -extern int udev_rules_get_name(struct udevice *udev, struct sysfs_class_device *class_dev); -extern void udev_rules_close(void); +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); #endif