2003-07-17 15:24:51 +07:00
|
|
|
/*
|
2005-07-22 23:35:58 +07:00
|
|
|
* Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
|
2008-09-10 07:40:42 +07:00
|
|
|
* Copyright (C) 2004-2008 Kay Sievers <kay.sievers@vrfy.org>
|
2003-07-17 15:24:51 +07:00
|
|
|
*
|
2008-09-10 07:40:42 +07: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, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2003-07-17 15:24:51 +07:00
|
|
|
*
|
2008-09-10 07:40:42 +07:00
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
2003-07-17 15:24:51 +07:00
|
|
|
*/
|
|
|
|
|
2005-03-13 13:14:49 +07:00
|
|
|
#ifndef UDEV_RULES_H
|
|
|
|
#define UDEV_RULES_H
|
2003-07-17 15:24:51 +07:00
|
|
|
|
2003-08-06 13:57:23 +07:00
|
|
|
#include "udev.h"
|
2003-07-24 05:56:56 +07:00
|
|
|
|
2005-07-05 20:24:41 +07:00
|
|
|
#define PAIRS_MAX 5
|
2004-02-24 10:31:14 +07:00
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
enum key_operation {
|
2005-03-28 17:20:05 +07:00
|
|
|
KEY_OP_UNSET,
|
2005-03-13 11:46:31 +07:00
|
|
|
KEY_OP_MATCH,
|
|
|
|
KEY_OP_NOMATCH,
|
|
|
|
KEY_OP_ADD,
|
|
|
|
KEY_OP_ASSIGN,
|
2005-06-05 09:57:03 +07:00
|
|
|
KEY_OP_ASSIGN_FINAL,
|
2005-03-13 11:46:31 +07:00
|
|
|
};
|
|
|
|
|
2005-07-05 20:24:41 +07:00
|
|
|
struct key {
|
2005-03-13 11:46:31 +07:00
|
|
|
enum key_operation operation;
|
2005-07-05 20:24:41 +07: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 13:31:35 +07:00
|
|
|
};
|
2003-07-24 05:56:56 +07:00
|
|
|
|
2005-07-12 19:46:36 +07:00
|
|
|
enum import_type {
|
|
|
|
IMPORT_UNSET,
|
|
|
|
IMPORT_PROGRAM,
|
|
|
|
IMPORT_FILE,
|
|
|
|
IMPORT_PARENT,
|
|
|
|
};
|
|
|
|
|
2007-06-22 06:27:02 +07:00
|
|
|
enum escape_type {
|
|
|
|
ESCAPE_UNSET,
|
|
|
|
ESCAPE_NONE,
|
|
|
|
ESCAPE_REPLACE,
|
|
|
|
};
|
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
struct udev_rule {
|
2005-07-05 20:24:41 +07:00
|
|
|
struct key action;
|
|
|
|
struct key devpath;
|
2006-08-19 21:06:25 +07:00
|
|
|
struct key kernel;
|
|
|
|
struct key subsystem;
|
2005-07-05 20:24:41 +07:00
|
|
|
struct key driver;
|
2006-08-19 21:06:25 +07:00
|
|
|
struct key_pairs attr;
|
|
|
|
|
|
|
|
struct key kernels;
|
|
|
|
struct key subsystems;
|
|
|
|
struct key drivers;
|
|
|
|
struct key_pairs attrs;
|
|
|
|
|
|
|
|
struct key_pairs env;
|
2005-07-05 20:24:41 +07:00
|
|
|
struct key program;
|
|
|
|
struct key result;
|
|
|
|
struct key import;
|
2005-07-12 19:46:36 +07:00
|
|
|
enum import_type import_type;
|
2007-06-03 05:01:46 +07:00
|
|
|
struct key test;
|
|
|
|
mode_t test_mode_mask;
|
2006-08-19 21:06:25 +07:00
|
|
|
struct key run;
|
2008-05-20 20:02:17 +07:00
|
|
|
struct key wait_for;
|
2006-08-19 21:06:25 +07:00
|
|
|
struct key label;
|
|
|
|
struct key goto_label;
|
2008-09-28 18:02:44 +07:00
|
|
|
size_t goto_rule_off;
|
2005-07-05 20:24:41 +07:00
|
|
|
|
|
|
|
struct key name;
|
|
|
|
struct key symlink;
|
2007-07-16 18:29:28 +07:00
|
|
|
struct key symlink_match;
|
2005-07-05 20:24:41 +07:00
|
|
|
struct key owner;
|
|
|
|
struct key group;
|
2008-04-19 02:07:29 +07:00
|
|
|
struct key mode;
|
2007-06-22 06:27:02 +07:00
|
|
|
enum escape_type string_escape;
|
2005-07-05 20:24:41 +07:00
|
|
|
|
2007-03-16 21:16:08 +07:00
|
|
|
unsigned int link_priority;
|
2008-04-22 00:00:54 +07:00
|
|
|
int event_timeout;
|
2005-07-05 20:24:41 +07:00
|
|
|
unsigned int partitions;
|
|
|
|
unsigned int last_rule:1,
|
2007-07-15 01:43:01 +07:00
|
|
|
run_ignore_error:1,
|
2005-07-05 20:24:41 +07:00
|
|
|
ignore_device:1,
|
2005-07-12 19:46:36 +07:00
|
|
|
ignore_remove:1;
|
2005-02-14 12:03:06 +07:00
|
|
|
|
2005-07-05 20:24:41 +07:00
|
|
|
size_t bufsize;
|
|
|
|
char buf[];
|
|
|
|
};
|
2005-02-14 12:03:06 +07:00
|
|
|
|
2005-07-05 20:24:41 +07:00
|
|
|
struct udev_rules {
|
2008-09-06 20:45:31 +07:00
|
|
|
struct udev *udev;
|
2005-07-05 20:24:41 +07:00
|
|
|
char *buf;
|
|
|
|
size_t bufsize;
|
|
|
|
int resolve_names;
|
2003-12-04 09:33:58 +07:00
|
|
|
};
|
|
|
|
|
2008-09-09 05:09:49 +07:00
|
|
|
struct udev_rules_iter {
|
|
|
|
struct udev_rules *rules;
|
|
|
|
size_t current;
|
|
|
|
};
|
|
|
|
|
2008-09-06 20:45:31 +07:00
|
|
|
extern int udev_rules_init(struct udev *udev, struct udev_rules *rules, int resolve_names);
|
2006-01-10 03:18:00 +07:00
|
|
|
extern void udev_rules_cleanup(struct udev_rules *rules);
|
2005-06-24 23:05:32 +07:00
|
|
|
|
2008-09-09 05:09:49 +07:00
|
|
|
extern void udev_rules_iter_init(struct udev_rules_iter *iter, struct udev_rules *rules);
|
|
|
|
extern struct udev_rule *udev_rules_iter_next(struct udev_rules_iter *iter);
|
2008-09-28 18:02:44 +07:00
|
|
|
extern struct udev_rule *udev_rules_iter_goto(struct udev_rules_iter *iter, size_t rule_off);
|
2005-06-24 23:05:32 +07:00
|
|
|
|
2006-01-10 03:18:00 +07:00
|
|
|
extern int udev_rules_get_name(struct udev_rules *rules, struct udevice *udev);
|
|
|
|
extern int udev_rules_get_run(struct udev_rules *rules, struct udevice *udev);
|
2007-07-15 01:44:19 +07:00
|
|
|
extern int udev_rules_run(struct udevice *udev);
|
2003-12-03 09:38:30 +07:00
|
|
|
|
2006-01-25 07:28:31 +07:00
|
|
|
extern void udev_rules_apply_format(struct udevice *udev, char *string, size_t maxsize);
|
|
|
|
|
2003-07-17 15:24:51 +07:00
|
|
|
#endif
|