diff options
author | Kay Sievers <kay.sievers@suse.de> | 2005-07-05 15:24:41 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@suse.de> | 2005-07-05 15:24:41 +0200 |
commit | 8bd41f36f793f7fc208ef6beb4b2b84e35a5e728 (patch) | |
tree | d2a8d9f3ad291cf9f341cc87d87be80f435cfc30 /udev_rules.h | |
parent | 6369839195d7572151d986ddc2050162e6879585 (diff) |
pack parsed rules list
This cuts down our 600 rules file to 98 kb instead of 1.9 Mb memory
or file-size with precompiled rules.
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Diffstat (limited to 'udev_rules.h')
-rw-r--r-- | udev_rules.h | 113 |
1 files changed, 54 insertions, 59 deletions
diff --git a/udev_rules.h b/udev_rules.h index fb77509cce..4ecada1c03 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 |