Changeset aa0faeca in mainline
- Timestamp:
- 2020-03-08T16:47:18Z (5 years ago)
- Children:
- a73aaec1
- Parents:
- 13b4504
- git-author:
- Matthieu Riolo <matthieu.riolo@…> (2020-03-06 18:10:45)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2020-03-08 16:47:18)
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/cfg/sysman/default.tgt
r13b4504 raa0faeca 4 4 After = devman.svc 5 5 6 ; arm32 specific 7 ; After = s3c24xx_uart.svc 8 ; After = s3c24xx_ts.svc 6 After = s3c24xx_uart.svc 7 After = s3c24xx_ts.svc 9 8 10 9 After = klog.svc -
uspace/cfg/sysman/s3c24xx_ts.svc
r13b4504 raa0faeca 1 [Unit] 2 ConditionArchitecture = arm32 3 1 4 [Service] 2 5 ExecStart = /srv/hid/s3c24xx_ts -
uspace/cfg/sysman/s3c24xx_uart.svc
r13b4504 raa0faeca 1 [Unit] 2 ConditionArchitecture = arm32 3 1 4 [Service] 2 5 ExecStart = /srv/hid/s3c24xx_uart -
uspace/srv/sysman/repo.c
r13b4504 raa0faeca 278 278 } 279 279 280 static bool repo_clean_up_unit(ht_link_t *ht_link, void *arg) 281 { 282 unit_t *unit = hash_table_get_inst(ht_link, unit_t, units_by_name); 283 284 if (unit->conditions != UNIT_CONDITION_NONE) { 285 unit_log_condition(unit); 286 287 list_foreach_safe(unit->edges_in, current_link, iter) { 288 unit_edge_t *e = list_get_instance(current_link, unit_edge_t, edges_in); 289 edge_remove(&e); 290 } 291 292 list_foreach_safe(unit->edges_out, current_link, iter) { 293 unit_edge_t *e = list_get_instance(current_link, unit_edge_t, edges_out); 294 edge_remove(&e); 295 } 296 } 297 298 return true; 299 } 300 280 301 /** Resolve unresolved dependencies between any pair of units_by_name 281 302 * … … 289 310 bool has_error = false; 290 311 hash_table_apply(&units_by_name, &repo_resolve_unit, &has_error); 312 313 if (!has_error) { 314 //once all references have been built test if there are 315 //units which dont meet the conditions. If yes, remove the edges 316 hash_table_apply(&units_by_name, &repo_clean_up_unit, &has_error); 317 } 291 318 292 319 return has_error ? ENOENT : EOK; -
uspace/srv/sysman/unit.c
r13b4504 raa0faeca 56 56 static config_item_t unit_configuration[] = { 57 57 { "After", &unit_parse_unit_list, 0, "" }, 58 { "ConditionArchitecture", &unit_parse_condition_architecture, 0, "" }, 58 59 CONFIGURATION_ITEM_SENTINEL 59 60 }; … … 69 70 unit->state = STATE_STOPPED; 70 71 unit->repo_state = REPO_EMBRYO; 72 unit->conditions = UNIT_CONDITION_NONE; 71 73 72 74 link_initialize(&unit->units); … … 137 139 errno_t unit_start(unit_t *unit) 138 140 { 141 assert(unit->conditions == UNIT_CONDITION_NONE); 139 142 sysman_log(LVL_NOTE, "%s('%s')", __func__, unit_name(unit)); 140 143 return UNIT_VMT(unit)->start(unit); … … 147 150 errno_t unit_stop(unit_t *unit) 148 151 { 152 assert(unit->conditions == UNIT_CONDITION_NONE); 149 153 sysman_log(LVL_NOTE, "%s('%s')", __func__, unit_name(unit)); 150 154 return UNIT_VMT(unit)->stop(unit); … … 191 195 { 192 196 return unit->name ? unit->name : ""; 197 } 198 199 /** 200 * Logs a message for the failed conditions of a unit 201 */ 202 void unit_log_condition(unit_t *unit) 203 { 204 assert(unit->conditions != UNIT_CONDITION_NONE); 205 unit_condition_t conditions = unit->conditions; 206 while (conditions != UNIT_CONDITION_NONE) { 207 const char *type = NULL; 208 if (conditions & UNIT_CONDITION_ARCHITECTURE) { 209 conditions ^= UNIT_CONDITION_ARCHITECTURE; 210 type = "architecture"; 211 } else { 212 sysman_log( 213 LVL_NOTE, 214 "Condition restriction: unit '%s' does not meet the unkown condition '%d'", 215 unit_name(unit), 216 conditions); 217 return; 218 } 219 220 sysman_log( 221 LVL_NOTE, 222 "Condition restriction: unit '%s' does not meet the '%s' condition", 223 unit_name(unit), 224 type); 225 } 193 226 } 194 227 … … 221 254 return result; 222 255 } 256 257 bool unit_parse_condition_architecture(const char *string, void *dst, text_parse_t *parse, 258 size_t lineno) 259 { 260 unit_t *unit = dst; 261 bool result = true; 262 char *str = NULL; 263 264 if (str_length(string) == 0) { 265 goto finish; 266 } 267 268 str = str_dup(string); 269 if (str == NULL) { 270 result = false; 271 goto finish; 272 } 273 274 char *split = str; 275 char *tok; 276 bool conditions = false; 277 while ((tok = str_tok(split, " ", &split))) { 278 if (str_casecmp(tok, STRING(UARCH)) == 0) { 279 conditions = true; 280 break; 281 } 282 } 283 284 if (!conditions) { 285 unit->conditions |= UNIT_CONDITION_ARCHITECTURE; 286 } 287 288 finish: 289 free(str); 290 return result; 291 } -
uspace/srv/sysman/unit.h
r13b4504 raa0faeca 55 55 } repo_state_t; 56 56 57 typedef enum { 58 UNIT_CONDITION_NONE = 0, 59 UNIT_CONDITION_ARCHITECTURE = 1 60 } unit_condition_t; 61 57 62 typedef struct { 58 63 /** Link to name-to-unit hash table */ … … 92 97 list_t edges_in; 93 98 list_t edges_out; 99 100 /** 101 * flag for conditions which were not meet 102 * determines if the unit should be started 103 */ 104 unit_condition_t conditions; 94 105 } unit_t; 95 106 … … 161 172 162 173 extern const char *unit_name(const unit_t *); 174 extern void unit_log_condition(unit_t *unit); 163 175 164 176 extern bool unit_parse_unit_list(const char *, void *, text_parse_t *, size_t); 177 extern bool unit_parse_condition_architecture(const char *, void *, text_parse_t *, size_t); 165 178 166 179 #endif
Note:
See TracChangeset
for help on using the changeset viewer.