chiark / gitweb /
fix a debug text typo in udev_rules.c
[elogind.git] / udev_rules.h
index fb77509cce541e32f1b1a0b10d24aae45cdc0740..be13378e4e1e58b3c749216fc0598b3e648277db 100644 (file)
@@ -1,9 +1,8 @@
 /*
  * udev_rules.h
  *
- * Userspace devfs
- *
- * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
  *
  *     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
@@ -27,9 +26,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 +38,85 @@ 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];
+};
+
+enum import_type {
+       IMPORT_UNSET,
+       IMPORT_PROGRAM,
+       IMPORT_FILE,
+       IMPORT_PARENT,
 };
 
 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 label;
+       struct key goto_label;
+       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;
+       enum import_type import_type;
+       struct key wait_for_sysfs;
+       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;
 
-       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 read_compiled, int resolve_names);
+extern void udev_rules_close(struct udev_rules *rules);
+
+extern void udev_apply_format(struct udevice *udev, char *string, size_t maxsize,
+                             struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device);
 
-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 struct udev_rule *udev_rules_iter_label(struct udev_rules *rules, const char *label);
 
-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_class_device *class_dev, struct sysfs_device *sysfs_dev);
 
 #endif