mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-31 12:13:10 +00:00
Parse the ! lines that will soon be coming from the kernel. These are
a generalized notification mechanism for subsystems wishing to report events. Revieded by: njl # The kernel side seems like it might be causing panics for me, but should # be forthcoming shortly.
This commit is contained in:
parent
4294fd5ce1
commit
842ccec57e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=121487
@ -67,6 +67,7 @@ using namespace std;
|
||||
extern FILE *yyin;
|
||||
extern int lineno;
|
||||
|
||||
static const char notify = '!';
|
||||
static const char nomatch = '?';
|
||||
static const char attach = '+';
|
||||
static const char detach = '-';
|
||||
@ -219,6 +220,7 @@ config::reset(void)
|
||||
delete_and_clear(_attach_list);
|
||||
delete_and_clear(_detach_list);
|
||||
delete_and_clear(_nomatch_list);
|
||||
delete_and_clear(_notify_list);
|
||||
}
|
||||
|
||||
void
|
||||
@ -282,6 +284,7 @@ config::parse(void)
|
||||
sort_vector(_attach_list);
|
||||
sort_vector(_detach_list);
|
||||
sort_vector(_nomatch_list);
|
||||
sort_vector(_notify_list);
|
||||
}
|
||||
|
||||
void
|
||||
@ -325,6 +328,13 @@ config::add_nomatch(int prio, event_proc *p)
|
||||
_nomatch_list.push_back(p);
|
||||
}
|
||||
|
||||
void
|
||||
config::add_notify(int prio, event_proc *p)
|
||||
{
|
||||
p->set_priority(prio);
|
||||
_notify_list.push_back(p);
|
||||
}
|
||||
|
||||
void
|
||||
config::set_pidfile(const char *fn)
|
||||
{
|
||||
@ -501,6 +511,10 @@ config::find_and_execute(char type)
|
||||
switch (type) {
|
||||
default:
|
||||
return;
|
||||
case notify:
|
||||
l = &_notify_list;
|
||||
s = "notify";
|
||||
break;
|
||||
case nomatch:
|
||||
l = &_nomatch_list;
|
||||
s = "nomatch";
|
||||
@ -539,7 +553,21 @@ process_event(char *buffer)
|
||||
cfg.push_var_table();
|
||||
// No match doesn't have a device, and the format is a little
|
||||
// different, so handle it separately.
|
||||
if (type != nomatch) {
|
||||
switch (type) {
|
||||
case notify:
|
||||
sp = cfg.set_vars(sp);
|
||||
break;
|
||||
case nomatch:
|
||||
//?vars at location on bus
|
||||
sp = cfg.set_vars(sp);
|
||||
if (strncmp(sp, "at ", 3) == 0)
|
||||
sp += 3;
|
||||
sp = cfg.set_vars(sp);
|
||||
if (strncmp(sp, "on ", 3) == 0)
|
||||
cfg.set_variable("bus", sp + 3);
|
||||
break;
|
||||
case attach: /*FALLTHROUGH*/
|
||||
case detach:
|
||||
sp = strchr(sp, ' ');
|
||||
if (sp == NULL)
|
||||
return; /* Can't happen? */
|
||||
@ -550,14 +578,7 @@ process_event(char *buffer)
|
||||
sp = cfg.set_vars(sp);
|
||||
if (strncmp(sp, "on ", 3) == 0)
|
||||
cfg.set_variable("bus", sp + 3);
|
||||
} else {
|
||||
//?vars at location on bus
|
||||
sp = cfg.set_vars(sp);
|
||||
if (strncmp(sp, "at ", 3) == 0)
|
||||
sp += 3;
|
||||
sp = cfg.set_vars(sp);
|
||||
if (strncmp(sp, "on ", 3) == 0)
|
||||
cfg.set_variable("bus", sp + 3);
|
||||
break;
|
||||
}
|
||||
|
||||
cfg.find_and_execute(type);
|
||||
@ -643,6 +664,12 @@ add_nomatch(int prio, event_proc *p)
|
||||
cfg.add_nomatch(prio, p);
|
||||
}
|
||||
|
||||
void
|
||||
add_notify(int prio, event_proc *p)
|
||||
{
|
||||
cfg.add_notify(prio, p);
|
||||
}
|
||||
|
||||
event_proc *
|
||||
add_to_event_proc(event_proc *ep, eps *eps)
|
||||
{
|
||||
|
@ -40,6 +40,7 @@ void add_attach(int, struct event_proc *);
|
||||
void add_detach(int, struct event_proc *);
|
||||
void add_directory(const char *);
|
||||
void add_nomatch(int, struct event_proc *);
|
||||
void add_notify(int, struct event_proc *);
|
||||
struct event_proc *add_to_event_proc(struct event_proc *, struct eps *);
|
||||
struct eps *new_match(const char *, const char *);
|
||||
struct eps *new_action(const char *);
|
||||
|
@ -133,6 +133,7 @@ public:
|
||||
void add_detach(int, event_proc *);
|
||||
void add_directory(const char *);
|
||||
void add_nomatch(int, event_proc *);
|
||||
void add_notify(int, event_proc *);
|
||||
void set_pidfile(const char *);
|
||||
void reset();
|
||||
void parse();
|
||||
@ -158,6 +159,7 @@ private:
|
||||
std::vector<event_proc *> _attach_list;
|
||||
std::vector<event_proc *> _detach_list;
|
||||
std::vector<event_proc *> _nomatch_list;
|
||||
std::vector<event_proc *> _notify_list;
|
||||
};
|
||||
|
||||
#endif /* DEVD_HH */
|
||||
|
@ -47,7 +47,7 @@
|
||||
%token <str> STRING
|
||||
%token <str> ID
|
||||
%token OPTIONS SET DIRECTORY PID_FILE DEVICE_NAME ACTION MATCH
|
||||
%token ATTACH DETACH NOMATCH
|
||||
%token ATTACH DETACH NOMATCH NOTIFY
|
||||
|
||||
%type <eventproc> match_or_action_list
|
||||
%type <eps> match_or_action match action
|
||||
@ -69,6 +69,7 @@ config
|
||||
| attach_block
|
||||
| detach_block
|
||||
| nomatch_block
|
||||
| notify_block
|
||||
;
|
||||
|
||||
option_block
|
||||
@ -115,6 +116,12 @@ nomatch_block
|
||||
| NOMATCH NUMBER BEGINBLOCK ENDBLOCK SEMICOLON
|
||||
;
|
||||
|
||||
notify_block
|
||||
: NOTIFY NUMBER BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON
|
||||
{ add_notify($2, $4); }
|
||||
| NOTIFY NUMBER BEGINBLOCK ENDBLOCK SEMICOLON
|
||||
;
|
||||
|
||||
match_or_action_list
|
||||
: match_or_action { $$ = add_to_event_proc( NULL, $1); }
|
||||
| match_or_action_list match_or_action
|
||||
|
@ -93,6 +93,7 @@ device-name { return DEVICE_NAME; }
|
||||
action { return ACTION; }
|
||||
match { return MATCH; }
|
||||
nomatch { return NOMATCH; }
|
||||
notify { return NOTIFY; }
|
||||
[A-Za-z][A-Za-z0-9_-]* {
|
||||
yylval.str = strdup(yytext);
|
||||
return ID;
|
||||
|
Loading…
Reference in New Issue
Block a user