Changeset af92309 in mainline
- Timestamp:
- 2019-08-07T09:33:04Z (5 years ago)
- Children:
- 9532981
- Parents:
- 918ac9b
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-11-02 22:12:18)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-07 09:33:04)
- Location:
- uspace/srv/sysman
- Files:
-
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/Makefile
r918ac9b raf92309 38 38 39 39 SYSMAN_SOURCES = \ 40 configuration.c \41 40 connection_broker.c \ 42 41 connection_ctl.c \ … … 44 43 job.c \ 45 44 log.c \ 45 repo.c \ 46 sm_task.c \ 46 47 sysman.c \ 47 48 unit.c \ 48 49 units/unit_cfg.c \ 49 50 units/unit_mnt.c \ 51 units/unit_svc.c \ 50 52 units/unit_tgt.c \ 51 units/unit_svc.c \52 sm_task.c \53 53 util.c 54 54 -
uspace/srv/sysman/connection_broker.c
r918ac9b raf92309 31 31 #include <stdlib.h> 32 32 33 #include " configuration.h"33 #include "repo.h" 34 34 #include "connection_broker.h" 35 35 #include "log.h" … … 67 67 } 68 68 69 unit_t *unit = configuration_find_unit_by_name(unit_name);69 unit_t *unit = repo_find_unit_by_name(unit_name); 70 70 if (unit == NULL) { 71 71 //sysman_log(LVL_NOTE, "Unit '%s' not found.", unit_name); -
uspace/srv/sysman/connection_ctl.c
r918ac9b raf92309 33 33 #include <str.h> 34 34 35 #include " configuration.h"35 #include "repo.h" 36 36 #include "connection_ctl.h" 37 37 #include "job.h" … … 79 79 80 80 // TODO this is connection fibril, UNSYNCHRONIZED access to units! 81 unit_t *unit = configuration_find_unit_by_name(unit_name);81 unit_t *unit = repo_find_unit_by_name(unit_name); 82 82 if (unit == NULL) { 83 83 sysman_log(LVL_NOTE, "Unit '%s' not found.", unit_name); … … 180 180 181 181 // TODO UNSYNCHRONIZED access to units! 182 unit_t *u = configuration_find_unit_by_handle(IPC_GET_ARG1(*icall));182 unit_t *u = repo_find_unit_by_handle(IPC_GET_ARG1(*icall)); 183 183 if (u == NULL) { 184 184 async_answer_0(callid, ENOENT); … … 196 196 { 197 197 // TODO UNSYNCHRONIZED access to units! 198 unit_t *u = configuration_find_unit_by_handle(IPC_GET_ARG1(*icall));198 unit_t *u = repo_find_unit_by_handle(IPC_GET_ARG1(*icall)); 199 199 if (u == NULL) { 200 200 async_answer_0(iid, ENOENT); -
uspace/srv/sysman/job.c
r918ac9b raf92309 32 32 #include <stdlib.h> 33 33 34 #include " configuration.h"34 #include "repo.h" 35 35 #include "dep.h" 36 36 #include "job.h" -
uspace/srv/sysman/main.c
r918ac9b raf92309 37 37 #include <str.h> 38 38 39 #include " configuration.h"39 #include "repo.h" 40 40 #include "connection_broker.h" 41 41 #include "connection_ctl.h" … … 131 131 * Add units to configuration and start the default target. 132 132 */ 133 configuration_start_update();134 135 configuration_add_unit(mnt_initrd);136 configuration_add_unit(cfg_init);137 configuration_add_unit(tgt_init);133 repo_begin_update(); 134 135 repo_add_unit(mnt_initrd); 136 repo_add_unit(cfg_init); 137 repo_add_unit(tgt_init); 138 138 139 139 rc = dep_add_dependency(tgt_init, cfg_init); … … 147 147 } 148 148 149 configuration_commit();149 repo_commit(); 150 150 151 151 return EOK; … … 158 158 159 159 rollback: 160 configuration_rollback();160 repo_rollback(); 161 161 return rc; 162 162 } … … 186 186 187 187 /* Previous targets should have loaded new units */ 188 unit_t *tgt = configuration_find_unit_by_name(target_name);188 unit_t *tgt = repo_find_unit_by_name(target_name); 189 189 if (tgt == NULL) { 190 190 sysman_log(LVL_ERROR, … … 210 210 */ 211 211 // TODO check return values and abort start 212 configuration_init();212 repo_init(); 213 213 sysman_events_init(); 214 214 job_queue_init(); -
uspace/srv/sysman/repo.c
r918ac9b raf92309 34 34 #include <fibril_synch.h> 35 35 36 #include " configuration.h"36 #include "repo.h" 37 37 #include "dep.h" 38 38 #include "log.h" … … 113 113 }; 114 114 115 /* Configurationfunctions */116 117 void configuration_init(void)115 /* Repository functions */ 116 117 void repo_init(void) 118 118 { 119 119 hash_table_create(&units_by_name, 0, 0, &units_by_name_ht_ops); … … 121 121 } 122 122 123 int configuration_add_unit(unit_t *unit)123 int repo_add_unit(unit_t *unit) 124 124 { 125 125 assert(unit); … … 141 141 } 142 142 143 void configuration_start_update(void) {144 sysman_log(LVL_DEBUG2, "%s", __func__); 145 } 146 147 static bool configuration_commit_unit(ht_link_t *ht_link, void *arg)143 void repo_begin_update(void) { 144 sysman_log(LVL_DEBUG2, "%s", __func__); 145 } 146 147 static bool repo_commit_unit(ht_link_t *ht_link, void *arg) 148 148 { 149 149 unit_t *unit = hash_table_get_inst(ht_link, unit_t, units_by_name); … … 162 162 163 163 /** Marks newly added units_by_name as usable (via state change) */ 164 void configuration_commit(void)164 void repo_commit(void) 165 165 { 166 166 sysman_log(LVL_DEBUG2, "%s", __func__); … … 170 170 * deps, thus eventually commiting all embryo deps as well. 171 171 */ 172 hash_table_apply(&units_by_name, & configuration_commit_unit, NULL);173 } 174 175 static bool configuration_rollback_unit(ht_link_t *ht_link, void *arg)172 hash_table_apply(&units_by_name, &repo_commit_unit, NULL); 173 } 174 175 static bool repo_rollback_unit(ht_link_t *ht_link, void *arg) 176 176 { 177 177 unit_t *unit = hash_table_get_inst(ht_link, unit_t, units_by_name); … … 198 198 * Memory used by removed object is released. 199 199 */ 200 void configuration_rollback(void)201 { 202 sysman_log(LVL_DEBUG2, "%s", __func__); 203 204 hash_table_apply(&units_by_name, & configuration_rollback_unit, NULL);205 } 206 207 static bool configuration_resolve_unit(ht_link_t *ht_link, void *arg)200 void repo_rollback(void) 201 { 202 sysman_log(LVL_DEBUG2, "%s", __func__); 203 204 hash_table_apply(&units_by_name, &repo_rollback_unit, NULL); 205 } 206 207 static bool repo_resolve_unit(ht_link_t *ht_link, void *arg) 208 208 { 209 209 bool *has_error_ptr = arg; … … 218 218 219 219 unit_t *dependency = 220 configuration_find_unit_by_name(dep->dependency_name);220 repo_find_unit_by_name(dep->dependency_name); 221 221 if (dependency == NULL) { 222 222 sysman_log(LVL_ERROR, … … 238 238 * @return ENOENT when one or more resolution fails, information is logged 239 239 */ 240 int configuration_resolve_dependecies(void)240 int repo_resolve_dependecies(void) 241 241 { 242 242 sysman_log(LVL_DEBUG2, "%s", __func__); 243 243 244 244 bool has_error = false; 245 hash_table_apply(&units_by_name, & configuration_resolve_unit, &has_error);245 hash_table_apply(&units_by_name, &repo_resolve_unit, &has_error); 246 246 247 247 return has_error ? ENOENT : EOK; 248 248 } 249 249 250 unit_t * configuration_find_unit_by_name(const char *name)250 unit_t *repo_find_unit_by_name(const char *name) 251 251 { 252 252 ht_link_t *ht_link = hash_table_find(&units_by_name, (void *)name); … … 258 258 } 259 259 260 unit_t * configuration_find_unit_by_handle(unit_handle_t handle)260 unit_t *repo_find_unit_by_handle(unit_handle_t handle) 261 261 { 262 262 ht_link_t *ht_link = hash_table_find(&units_by_handle, &handle); -
uspace/srv/sysman/repo.h
r918ac9b raf92309 27 27 */ 28 28 29 #ifndef SYSMAN_ CONFIGURATION_H30 #define SYSMAN_ CONFIGURATION_H29 #ifndef SYSMAN_REPO_H 30 #define SYSMAN_REPO_H 31 31 32 32 #include <adt/list.h> … … 37 37 extern list_t units; 38 38 39 extern void configuration_init(void);39 extern void repo_init(void); 40 40 41 extern int configuration_add_unit(unit_t *);41 extern int repo_add_unit(unit_t *); 42 42 43 extern void configuration_start_update(void);43 extern void repo_begin_update(void); 44 44 45 extern void configuration_commit(void);45 extern void repo_commit(void); 46 46 47 extern void configuration_rollback(void);47 extern void repo_rollback(void); 48 48 49 extern int configuration_resolve_dependecies(void);49 extern int repo_resolve_dependecies(void); 50 50 51 extern unit_t * configuration_find_unit_by_name(const char *);52 extern unit_t * configuration_find_unit_by_handle(unit_handle_t);51 extern unit_t *repo_find_unit_by_name(const char *); 52 extern unit_t *repo_find_unit_by_handle(unit_handle_t); 53 53 54 54 -
uspace/srv/sysman/sm_task.c
r918ac9b raf92309 31 31 #include <task.h> 32 32 33 #include " configuration.h"33 #include "repo.h" 34 34 #include "log.h" 35 35 #include "sysman.h" -
uspace/srv/sysman/units/unit_cfg.c
r918ac9b raf92309 38 38 #include <sysman/unit.h> 39 39 40 #include " configuration.h"40 #include "repo.h" 41 41 #include "log.h" 42 42 #include "unit.h" … … 82 82 } 83 83 84 unit_t *u = configuration_find_unit_by_name(unit_name);84 unit_t *u = repo_find_unit_by_name(unit_name); 85 85 if (u != NULL) { 86 86 // TODO allow updating configuration of existing unit … … 162 162 } 163 163 164 configuration_start_update();164 repo_begin_update(); 165 165 166 166 while ((de = readdir(dir))) { … … 178 178 179 179 assert(unit->state == STATE_EMBRYO); 180 configuration_add_unit(unit);180 repo_add_unit(unit); 181 181 } 182 182 closedir(dir); 183 183 184 int rc = configuration_resolve_dependecies();184 int rc = repo_resolve_dependecies(); 185 185 if (rc != EOK) { 186 configuration_rollback();186 repo_rollback(); 187 187 return rc; 188 188 } 189 189 190 configuration_commit();190 repo_commit(); 191 191 return EOK; 192 192 }
Note:
See TracChangeset
for help on using the changeset viewer.