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=fb77509cce541e32f1b1a0b10d24aae45cdc0740;hb=8bd41f36f793f7fc208ef6beb4b2b84e35a5e728;hpb=6369839195d7572151d986ddc2050162e6879585 diff --git a/udev_rules.h b/udev_rules.h index fb77509cc..4ecada1c0 100644 --- a/udev_rules.h +++ b/udev_rules.h @@ -27,9 +27,7 @@ #include "udev.h" #include "list.h" -#define KEY_SYSFS_PAIRS_MAX 5 -#define KEY_ENV_PAIRS_MAX 5 - +#define PAIRS_MAX 5 #define RULEFILE_SUFFIX ".rules" enum key_operation { @@ -41,72 +39,69 @@ enum key_operation { 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[NAME_SIZE]; - enum key_operation kernel_operation; - char subsystem[NAME_SIZE]; - enum key_operation subsystem_operation; - char action[NAME_SIZE]; - enum key_operation action_operation; - char devpath[PATH_SIZE]; - enum key_operation devpath_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 modalias[NAME_SIZE]; - enum key_operation modalias_operation; - char import[PATH_SIZE]; - enum key_operation import_operation; - int import_exec; - - char name[PATH_SIZE]; - enum key_operation name_operation; - char symlink[PATH_SIZE]; - enum key_operation symlink_operation; - char owner[USER_SIZE]; - enum key_operation owner_operation; - char group[USER_SIZE]; - enum key_operation group_operation; - mode_t mode; + 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; - char run[PATH_SIZE]; - enum key_operation run_operation; + mode_t mode; + + unsigned int partitions; + unsigned int last_rule:1, + ignore_device:1, + ignore_remove:1, + import_exec:1; - int last_rule; - int ignore_device; - int ignore_remove; - int partitions; + size_t bufsize; + char buf[]; +}; - char config_file[PATH_SIZE]; - int config_line; +struct udev_rules { + char *buf; + size_t bufsize; + size_t current; + int mapped; + int resolve_names; }; -extern int udev_rules_init(void); -extern void udev_rules_close(void); +extern int udev_rules_init(struct udev_rules *rules, int resolve_names); +extern void udev_rules_close(struct udev_rules *rules); -extern int udev_rules_iter_init(void); -extern struct udev_rule *udev_rules_iter_next(void); +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_get_name(struct udevice *udev, struct sysfs_class_device *class_dev); -extern int udev_rules_get_run(struct udevice *udev, struct sysfs_device *sysfs_device); +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