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
@ -67,6 +67,7 @@ using namespace std;
|
|||||||
extern FILE *yyin;
|
extern FILE *yyin;
|
||||||
extern int lineno;
|
extern int lineno;
|
||||||
|
|
||||||
|
static const char notify = '!';
|
||||||
static const char nomatch = '?';
|
static const char nomatch = '?';
|
||||||
static const char attach = '+';
|
static const char attach = '+';
|
||||||
static const char detach = '-';
|
static const char detach = '-';
|
||||||
@ -219,6 +220,7 @@ config::reset(void)
|
|||||||
delete_and_clear(_attach_list);
|
delete_and_clear(_attach_list);
|
||||||
delete_and_clear(_detach_list);
|
delete_and_clear(_detach_list);
|
||||||
delete_and_clear(_nomatch_list);
|
delete_and_clear(_nomatch_list);
|
||||||
|
delete_and_clear(_notify_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -282,6 +284,7 @@ config::parse(void)
|
|||||||
sort_vector(_attach_list);
|
sort_vector(_attach_list);
|
||||||
sort_vector(_detach_list);
|
sort_vector(_detach_list);
|
||||||
sort_vector(_nomatch_list);
|
sort_vector(_nomatch_list);
|
||||||
|
sort_vector(_notify_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -325,6 +328,13 @@ config::add_nomatch(int prio, event_proc *p)
|
|||||||
_nomatch_list.push_back(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
|
void
|
||||||
config::set_pidfile(const char *fn)
|
config::set_pidfile(const char *fn)
|
||||||
{
|
{
|
||||||
@ -501,6 +511,10 @@ config::find_and_execute(char type)
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
case notify:
|
||||||
|
l = &_notify_list;
|
||||||
|
s = "notify";
|
||||||
|
break;
|
||||||
case nomatch:
|
case nomatch:
|
||||||
l = &_nomatch_list;
|
l = &_nomatch_list;
|
||||||
s = "nomatch";
|
s = "nomatch";
|
||||||
@ -539,7 +553,21 @@ process_event(char *buffer)
|
|||||||
cfg.push_var_table();
|
cfg.push_var_table();
|
||||||
// No match doesn't have a device, and the format is a little
|
// No match doesn't have a device, and the format is a little
|
||||||
// different, so handle it separately.
|
// 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, ' ');
|
sp = strchr(sp, ' ');
|
||||||
if (sp == NULL)
|
if (sp == NULL)
|
||||||
return; /* Can't happen? */
|
return; /* Can't happen? */
|
||||||
@ -550,14 +578,7 @@ process_event(char *buffer)
|
|||||||
sp = cfg.set_vars(sp);
|
sp = cfg.set_vars(sp);
|
||||||
if (strncmp(sp, "on ", 3) == 0)
|
if (strncmp(sp, "on ", 3) == 0)
|
||||||
cfg.set_variable("bus", sp + 3);
|
cfg.set_variable("bus", sp + 3);
|
||||||
} else {
|
break;
|
||||||
//?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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.find_and_execute(type);
|
cfg.find_and_execute(type);
|
||||||
@ -643,6 +664,12 @@ add_nomatch(int prio, event_proc *p)
|
|||||||
cfg.add_nomatch(prio, p);
|
cfg.add_nomatch(prio, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
add_notify(int prio, event_proc *p)
|
||||||
|
{
|
||||||
|
cfg.add_notify(prio, p);
|
||||||
|
}
|
||||||
|
|
||||||
event_proc *
|
event_proc *
|
||||||
add_to_event_proc(event_proc *ep, eps *eps)
|
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_detach(int, struct event_proc *);
|
||||||
void add_directory(const char *);
|
void add_directory(const char *);
|
||||||
void add_nomatch(int, struct event_proc *);
|
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 event_proc *add_to_event_proc(struct event_proc *, struct eps *);
|
||||||
struct eps *new_match(const char *, const char *);
|
struct eps *new_match(const char *, const char *);
|
||||||
struct eps *new_action(const char *);
|
struct eps *new_action(const char *);
|
||||||
|
@ -133,6 +133,7 @@ public:
|
|||||||
void add_detach(int, event_proc *);
|
void add_detach(int, event_proc *);
|
||||||
void add_directory(const char *);
|
void add_directory(const char *);
|
||||||
void add_nomatch(int, event_proc *);
|
void add_nomatch(int, event_proc *);
|
||||||
|
void add_notify(int, event_proc *);
|
||||||
void set_pidfile(const char *);
|
void set_pidfile(const char *);
|
||||||
void reset();
|
void reset();
|
||||||
void parse();
|
void parse();
|
||||||
@ -158,6 +159,7 @@ private:
|
|||||||
std::vector<event_proc *> _attach_list;
|
std::vector<event_proc *> _attach_list;
|
||||||
std::vector<event_proc *> _detach_list;
|
std::vector<event_proc *> _detach_list;
|
||||||
std::vector<event_proc *> _nomatch_list;
|
std::vector<event_proc *> _nomatch_list;
|
||||||
|
std::vector<event_proc *> _notify_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DEVD_HH */
|
#endif /* DEVD_HH */
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
%token <str> STRING
|
%token <str> STRING
|
||||||
%token <str> ID
|
%token <str> ID
|
||||||
%token OPTIONS SET DIRECTORY PID_FILE DEVICE_NAME ACTION MATCH
|
%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 <eventproc> match_or_action_list
|
||||||
%type <eps> match_or_action match action
|
%type <eps> match_or_action match action
|
||||||
@ -69,6 +69,7 @@ config
|
|||||||
| attach_block
|
| attach_block
|
||||||
| detach_block
|
| detach_block
|
||||||
| nomatch_block
|
| nomatch_block
|
||||||
|
| notify_block
|
||||||
;
|
;
|
||||||
|
|
||||||
option_block
|
option_block
|
||||||
@ -115,6 +116,12 @@ nomatch_block
|
|||||||
| NOMATCH NUMBER BEGINBLOCK ENDBLOCK SEMICOLON
|
| 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_list
|
||||||
: match_or_action { $$ = add_to_event_proc( NULL, $1); }
|
: match_or_action { $$ = add_to_event_proc( NULL, $1); }
|
||||||
| match_or_action_list match_or_action
|
| match_or_action_list match_or_action
|
||||||
|
@ -93,6 +93,7 @@ device-name { return DEVICE_NAME; }
|
|||||||
action { return ACTION; }
|
action { return ACTION; }
|
||||||
match { return MATCH; }
|
match { return MATCH; }
|
||||||
nomatch { return NOMATCH; }
|
nomatch { return NOMATCH; }
|
||||||
|
notify { return NOTIFY; }
|
||||||
[A-Za-z][A-Za-z0-9_-]* {
|
[A-Za-z][A-Za-z0-9_-]* {
|
||||||
yylval.str = strdup(yytext);
|
yylval.str = strdup(yytext);
|
||||||
return ID;
|
return ID;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user