Changeset dbae3b6 in mainline
- Timestamp:
- 2024-08-23T19:57:52Z (4 months ago)
- Branches:
- master
- Children:
- e82b37e
- Parents:
- 4af6fb1
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/init.c
r4af6fb1 rdbae3b6 488 488 srv_start("/srv/klog"); 489 489 srv_start("/srv/fs/locfs"); 490 srv_start("/srv/taskmon");491 490 492 491 if (!mount_locfs()) { … … 503 502 srv_start("/srv/bd/vbd"); 504 503 srv_start("/srv/volsrv"); 504 505 init_sysvol(); 506 507 srv_start("/srv/taskmon"); 505 508 506 509 srv_start("/srv/net/loopip"); … … 519 522 srv_start("/srv/hid/output", HID_OUTPUT); 520 523 srv_start("/srv/audio/hound"); 521 522 init_sysvol();523 524 524 525 #ifdef CONFIG_WINSYS -
uspace/srv/hid/display/display.c
r4af6fb1 rdbae3b6 237 237 } 238 238 239 /** Save seat to SIF node.239 /** Save display configuration to SIF file. 240 240 * 241 241 * @param display Display -
uspace/srv/taskmon/meson.build
r4af6fb1 rdbae3b6 1 1 # 2 # Copyright (c) 202 3Jiri Svoboda2 # Copyright (c) 2024 Jiri Svoboda 3 3 # All rights reserved. 4 4 # … … 27 27 # 28 28 29 deps = [ 'corecfg' ]29 deps = [ 'corecfg', 'sif' ] 30 30 src = files('taskmon.c') -
uspace/srv/taskmon/taskmon.c
r4af6fb1 rdbae3b6 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 35 35 */ 36 36 37 #include <stdio.h>38 37 #include <async.h> 38 #include <errno.h> 39 #include <macros.h> 39 40 #include <ipc/services.h> 40 #include <task.h>41 41 #include <ipc/corecfg.h> 42 42 #include <loc.h> 43 #include <macros.h> 44 #include <errno.h> 43 #include <sif.h> 44 #include <stdio.h> 45 #include <str.h> 45 46 #include <str_error.h> 47 #include <task.h> 46 48 47 49 #define NAME "taskmon" 48 50 51 static const char *taskmon_cfg_path = "/w/cfg/taskmon.sif"; 52 49 53 static bool write_core_files; 50 54 55 static errno_t taskmon_load_cfg(const char *); 56 static errno_t taskmon_save_cfg(const char *); 51 57 static void corecfg_client_conn(ipc_call_t *, void *); 52 58 … … 103 109 write_core_files = ipc_get_arg1(icall); 104 110 async_answer_0(icall, EOK); 111 (void) taskmon_save_cfg(taskmon_cfg_path); 105 112 } 106 113 … … 134 141 } 135 142 143 /** Load task monitor configuration from SIF file. 144 * 145 * @param cfgpath Configuration file path 146 * 147 * @return EOK on success or an error code 148 */ 149 static errno_t taskmon_load_cfg(const char *cfgpath) 150 { 151 sif_doc_t *doc = NULL; 152 sif_node_t *rnode; 153 sif_node_t *ncorefiles; 154 const char *ntype; 155 const char *swrite; 156 errno_t rc; 157 158 rc = sif_load(cfgpath, &doc); 159 if (rc != EOK) 160 goto error; 161 162 rnode = sif_get_root(doc); 163 ncorefiles = sif_node_first_child(rnode); 164 ntype = sif_node_get_type(ncorefiles); 165 if (str_cmp(ntype, "corefiles") != 0) { 166 rc = EIO; 167 goto error; 168 } 169 170 swrite = sif_node_get_attr(ncorefiles, "write"); 171 if (swrite == NULL) { 172 rc = EIO; 173 goto error; 174 } 175 176 if (str_cmp(swrite, "y") == 0) { 177 write_core_files = true; 178 } else if (str_cmp(swrite, "n") == 0) { 179 write_core_files = false; 180 } else { 181 rc = EIO; 182 goto error; 183 } 184 185 sif_delete(doc); 186 return EOK; 187 error: 188 if (doc != NULL) 189 sif_delete(doc); 190 return rc; 191 } 192 193 /** Save task monitor configuration to SIF file. 194 * 195 * @param cfgpath Configuration file path 196 * 197 * @return EOK on success or an error code 198 */ 199 static errno_t taskmon_save_cfg(const char *cfgpath) 200 { 201 sif_doc_t *doc = NULL; 202 sif_node_t *rnode; 203 sif_node_t *ncorefiles; 204 errno_t rc; 205 206 rc = sif_new(&doc); 207 if (rc != EOK) 208 goto error; 209 210 rnode = sif_get_root(doc); 211 rc = sif_node_append_child(rnode, "corefiles", &ncorefiles); 212 if (rc != EOK) 213 goto error; 214 215 rc = sif_node_set_attr(ncorefiles, "write", 216 write_core_files ? "y" : "n"); 217 if (rc != EOK) 218 goto error; 219 220 rc = sif_save(doc, cfgpath); 221 if (rc != EOK) 222 goto error; 223 224 sif_delete(doc); 225 return EOK; 226 error: 227 if (doc != NULL) 228 sif_delete(doc); 229 return rc; 230 } 231 136 232 int main(int argc, char *argv[]) 137 233 { … … 145 241 write_core_files = false; 146 242 #endif 243 (void) taskmon_load_cfg(taskmon_cfg_path); 244 147 245 if (async_event_subscribe(EVENT_FAULT, fault_event, NULL) != EOK) { 148 246 printf("%s: Error registering fault notifications.\n", NAME);
Note:
See TracChangeset
for help on using the changeset viewer.