Last change
on this file since 6efec7e3 was 6efec7e3, checked in by Matthieu Riolo <matthieu.riolo@…>, 6 years ago |
Unit polymorphism (simple mount), debug logging
|
-
Property mode
set to
100644
|
File size:
914 bytes
|
Line | |
---|
1 | #include <adt/list.h>
|
---|
2 | #include <assert.h>
|
---|
3 | #include <errno.h>
|
---|
4 | #include <fibril_synch.h>
|
---|
5 |
|
---|
6 | #include "configuration.h"
|
---|
7 | #include "log.h"
|
---|
8 |
|
---|
9 | static list_t units;
|
---|
10 | static fibril_mutex_t units_mtx;
|
---|
11 |
|
---|
12 | void configuration_init(void)
|
---|
13 | {
|
---|
14 | list_initialize(&units);
|
---|
15 | fibril_mutex_initialize(&units_mtx);
|
---|
16 | }
|
---|
17 |
|
---|
18 | int configuration_add_unit(unit_t *unit)
|
---|
19 | {
|
---|
20 | sysman_log(LVL_DEBUG2, "%s(%p)", __func__, unit);
|
---|
21 | assert(unit);
|
---|
22 | assert(unit->state == STATE_EMBRYO);
|
---|
23 |
|
---|
24 | fibril_mutex_lock(&units_mtx);
|
---|
25 | list_append(&unit->units, &units);
|
---|
26 |
|
---|
27 | // TODO check name uniqueness
|
---|
28 | fibril_mutex_unlock(&units_mtx);
|
---|
29 | return EOK;
|
---|
30 | }
|
---|
31 |
|
---|
32 | /** Marks newly added units as usable (via state change) */
|
---|
33 | int configuration_commit(void)
|
---|
34 | {
|
---|
35 | sysman_log(LVL_DEBUG2, "%s", __func__);
|
---|
36 |
|
---|
37 | fibril_mutex_lock(&units_mtx);
|
---|
38 | list_foreach(units, units, unit_t, u) {
|
---|
39 | if (u->state == STATE_EMBRYO) {
|
---|
40 | u->state = STATE_STOPPED;
|
---|
41 | }
|
---|
42 | }
|
---|
43 | fibril_mutex_unlock(&units_mtx);
|
---|
44 |
|
---|
45 | return EOK;
|
---|
46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.