Changeset 241f1985 in mainline for uspace/srv
- Timestamp:
- 2019-08-31T10:45:17Z (7 years ago)
- Children:
- 102f641
- Parents:
- f92b315
- git-author:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-23 22:04:34)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-31 10:45:17)
- Location:
- uspace/srv
- Files:
-
- 37 edited
-
devman/Makefile (modified) (1 diff)
-
devman/driver.c (modified) (1 diff)
-
devman/drv_conn.c (modified) (2 diffs)
-
hid/compositor/compositor.c (modified) (1 diff)
-
loader/main.c (modified) (2 diffs)
-
locsrv/Makefile (modified) (1 diff)
-
locsrv/locsrv.c (modified) (6 diffs)
-
ns/ns.c (modified) (2 diffs)
-
sysman/Makefile (modified) (1 diff)
-
sysman/connection_broker.c (modified) (4 diffs)
-
sysman/connection_broker.h (modified) (1 diff)
-
sysman/connection_ctl.c (modified) (12 diffs)
-
sysman/connection_ctl.h (modified) (1 diff)
-
sysman/edge.c (modified) (1 diff)
-
sysman/job.c (modified) (5 diffs)
-
sysman/job.h (modified) (2 diffs)
-
sysman/job_closure.c (modified) (1 diff)
-
sysman/log.h (modified) (1 diff)
-
sysman/main.c (modified) (5 diffs)
-
sysman/repo.c (modified) (6 diffs)
-
sysman/sm_task.c (modified) (1 diff)
-
sysman/sm_task.h (modified) (1 diff)
-
sysman/sysman.c (modified) (5 diffs)
-
sysman/sysman.h (modified) (1 diff)
-
sysman/test/job_closure.c (modified) (1 diff)
-
sysman/units/unit_cfg.c (modified) (9 diffs)
-
sysman/units/unit_mnt.c (modified) (6 diffs)
-
sysman/units/unit_svc.c (modified) (7 diffs)
-
taskman/event.c (modified) (15 diffs)
-
taskman/event.h (modified) (1 diff)
-
taskman/main.c (modified) (18 diffs)
-
taskman/task.c (modified) (3 diffs)
-
vfs/Makefile (modified) (1 diff)
-
vfs/vfs.c (modified) (1 diff)
-
vfs/vfs.h (modified) (1 diff)
-
vfs/vfs_ops.c (modified) (3 diffs)
-
vfs/vfs_register.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/Makefile
rf92b315 r241f1985 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBSYSMAN_PREFIX)/libsysman.a 32 EXTRA_CFLAGS += -I$(LIBSYSMAN_PREFIX)/include 31 LIBS = sysman 33 32 BINARY = devman 34 33 STATIC_NEEDED = y -
uspace/srv/devman/driver.c
rf92b315 r241f1985 34 34 #include <dirent.h> 35 35 #include <errno.h> 36 #include <fcntl.h>37 36 #include <io/log.h> 38 37 #include <vfs/vfs.h> 38 #include <dirent.h> 39 39 #include <loc.h> 40 40 #include <stdio.h> 41 41 #include <str_error.h> 42 #include <sys/stat.h>43 42 #include <sysman/ctl.h> 44 43 #include <task.h> -
uspace/srv/devman/drv_conn.c
rf92b315 r241f1985 41 41 #include <io/log.h> 42 42 #include <ipc/devman.h> 43 #include <ipc/driver.h>44 43 #include <ipc/services.h> 45 44 #include <loc.h> … … 111 110 if (rc != EOK) { 112 111 fibril_mutex_unlock(&driver->driver_mutex); 113 async_answer_0(call id, rc);112 async_answer_0(call, rc); 114 113 return NULL; 115 114 } 116 sysman_main_exposee_added(unit_name, call-> in_task_id);115 sysman_main_exposee_added(unit_name, call->task_id); 117 116 free(unit_name); 118 117 -
uspace/srv/hid/compositor/compositor.c
rf92b315 r241f1985 2304 2304 2305 2305 /* Finally, register compositor server. */ 2306 async_set_fallback_port_handler(client_connection );2306 async_set_fallback_port_handler(client_connection, NULL); 2307 2307 2308 2308 rc = loc_server_register(NAME); -
uspace/srv/loader/main.c
rf92b315 r241f1985 56 56 #include <entry_point.h> 57 57 #include <errno.h> 58 #include <fcntl.h>59 58 #include <fibril_synch.h> 60 59 #include <ipc/loader.h> … … 62 61 #include <ns.h> 63 62 #include <str.h> 64 #include <sys/types.h>65 63 #include <task.h> 66 64 #include <taskman.h> 67 #include <unistd.h>68 65 #include <vfs/vfs.h> 69 66 #include <vfs/inbox.h> -
uspace/srv/locsrv/Makefile
rf92b315 r241f1985 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBSYSMAN_PREFIX)/libsysman.a 32 EXTRA_CFLAGS += -I$(LIBSYSMAN_PREFIX)/include 31 LIBS = sysman 33 32 BINARY = locsrv 34 33 STATIC_NEEDED = y -
uspace/srv/locsrv/locsrv.c
rf92b315 r241f1985 584 584 free(service); 585 585 free(unit_name); 586 async_answer_0(i id, rc);586 async_answer_0(icall, rc); 587 587 return; 588 588 } … … 591 591 sysman_exposee_added(unit_name); 592 592 } else { 593 sysman_main_exposee_added(unit_name, icall-> in_task_id);593 sysman_main_exposee_added(unit_name, icall->task_id); 594 594 } 595 595 free(unit_name); … … 619 619 * 620 620 */ 621 static void loc_service_unregister(ipc_callid_t iid, ipc_call_t *icall, 622 loc_server_t *server) 621 static void loc_service_unregister(ipc_call_t *icall, loc_server_t *server) 623 622 { 624 623 loc_service_t *svc; … … 840 839 fibril_mutex_lock(&services_list_mutex); 841 840 const loc_service_t *svc; 842 int flags = ipc_get_arg1( *icall);841 int flags = ipc_get_arg1(icall); 843 842 bool start_requested = false; 844 843 … … 889 888 finish: 890 889 if (rc == EOK) { 891 async_answer_1(i id, EOK, svc->id);890 async_answer_1(icall, EOK, svc->id); 892 891 } else { 893 async_answer_0(i id, rc);892 async_answer_0(icall, rc); 894 893 } 895 894 … … 1669 1668 if (rc != EOK) { 1670 1669 printf("%s: Error while registering broker service: %s\n", NAME, str_error(rc)); 1670 return rc; 1671 } 1671 1672 1672 1673 /* Let sysman know we are broker */ -
uspace/srv/ns/ns.c
rf92b315 r241f1985 75 75 break; 76 76 77 task_id_t id;78 77 errno_t retval; 79 80 78 service_t service; 81 79 … … 108 106 } 109 107 110 (void) ns_task_disconnect(&call); 108 /* TODO: Ignore so far, in future we might unregister services */ 109 //(void) ns_task_disconnect(&call); 111 110 async_answer_0(&call, EOK); 112 111 } -
uspace/srv/sysman/Makefile
rf92b315 r241f1985 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBCONF_PREFIX)/libconf.a 32 EXTRA_CFLAGS += -I. \ 33 -I./units \ 34 -I$(LIBCONF_PREFIX)/include \ 35 -I$(LIBSYSMAN_PREFIX)/include 31 LIBS = conf sysman 32 EXTRA_CFLAGS = -I. -I./units 36 33 BINARY = sysman 37 34 STATIC_NEEDED = y -
uspace/srv/sysman/connection_broker.c
rf92b315 r241f1985 36 36 #include "sysman.h" 37 37 38 static void sysman_broker_register(ipc_call id_t iid, ipc_call_t *icall)38 static void sysman_broker_register(ipc_call_t *icall) 39 39 { 40 40 sysman_log(LVL_DEBUG2, "%s", __func__); 41 async_answer_0(i id, EOK);41 async_answer_0(icall, EOK); 42 42 /* 43 43 * What exactly do here? Similar behavior that has locsrv with … … 48 48 } 49 49 50 static void sysman_ipc_forwarded(ipc_call id_t iid, ipc_call_t *icall)50 static void sysman_ipc_forwarded(ipc_call_t *icall) 51 51 { 52 52 sysman_log(LVL_DEBUG2, "%s", __func__); 53 async_answer_0(i id, ENOTSUP);53 async_answer_0(icall, ENOTSUP); 54 54 // TODO implement 55 55 } 56 56 57 static void sysman_main_exposee_added(ipc_call id_t iid, ipc_call_t *icall)57 static void sysman_main_exposee_added(ipc_call_t *icall) 58 58 { 59 59 char *unit_name = NULL; … … 79 79 80 80 finish: 81 async_answer_0(i id, retval);81 async_answer_0(icall, retval); 82 82 free(unit_name); 83 83 } 84 84 85 static void sysman_exposee_added(ipc_call id_t iid, ipc_call_t *icall)85 static void sysman_exposee_added(ipc_call_t *icall) 86 86 { 87 87 char *exposee = NULL; … … 100 100 101 101 finish: 102 async_answer_0(i id, retval);102 async_answer_0(icall, retval); 103 103 free(exposee); 104 104 } 105 105 106 static void sysman_exposee_removed(ipc_call id_t iid, ipc_call_t *icall)106 static void sysman_exposee_removed(ipc_call_t *icall) 107 107 { 108 108 sysman_log(LVL_DEBUG2, "%s", __func__); 109 async_answer_0(i id, ENOTSUP);109 async_answer_0(icall, ENOTSUP); 110 110 // TODO implement 111 111 } 112 112 113 void sysman_connection_broker(ipc_call id_t iid, ipc_call_t *icall)113 void sysman_connection_broker(ipc_call_t *icall) 114 114 { 115 115 sysman_log(LVL_DEBUG2, "%s", __func__); 116 116 /* First, accept connection */ 117 async_answer_0(i id, EOK);117 async_answer_0(icall, EOK); 118 118 119 119 while (true) { 120 120 ipc_call_t call; 121 ipc_callid_t callid = async_get_call(&call); 122 123 if (!IPC_GET_IMETHOD(call)) { 121 122 if (!async_get_call(&call) || !ipc_get_imethod(&call)) { 124 123 /* Client disconnected */ 125 124 break; 126 125 } 127 126 128 switch ( IPC_GET_IMETHOD(call)) {127 switch (ipc_get_imethod(&call)) { 129 128 case SYSMAN_BROKER_REGISTER: 130 sysman_broker_register( callid,&call);129 sysman_broker_register(&call); 131 130 break; 132 131 case SYSMAN_BROKER_IPC_FWD: 133 sysman_ipc_forwarded( callid,&call);132 sysman_ipc_forwarded(&call); 134 133 break; 135 134 case SYSMAN_BROKER_MAIN_EXP_ADDED: 136 sysman_main_exposee_added( callid,&call);135 sysman_main_exposee_added(&call); 137 136 break; 138 137 case SYSMAN_BROKER_EXP_ADDED: 139 sysman_exposee_added( callid,&call);138 sysman_exposee_added(&call); 140 139 break; 141 140 case SYSMAN_BROKER_EXP_REMOVED: 142 sysman_exposee_removed( callid,&call);141 sysman_exposee_removed(&call); 143 142 break; 144 143 default: 145 async_answer_0( callid, ENOENT);144 async_answer_0(&call, ENOENT); 146 145 } 147 146 } -
uspace/srv/sysman/connection_broker.h
rf92b315 r241f1985 32 32 #include <async.h> 33 33 34 extern void sysman_connection_broker(ipc_call id_t, ipc_call_t *);34 extern void sysman_connection_broker(ipc_call_t *); 35 35 36 36 #endif -
uspace/srv/sysman/connection_ctl.c
rf92b315 r241f1985 43 43 44 44 // TODO possibly provide as type-safe function + macro in sysman.h for generic boxing 45 static ipc_call id_t *box_callid(ipc_callid_t iid)46 { 47 ipc_call id_t *result = malloc(sizeof(ipc_callid_t));48 if ( result) {49 *result = iid;50 } 51 return result;45 static ipc_call_t *box_callid(ipc_call_t *icall) 46 { 47 ipc_call_t *copy = malloc(sizeof(ipc_call_t)); 48 if (copy) { 49 memcpy(copy, icall, sizeof(ipc_call_t)); 50 } 51 return copy; 52 52 } 53 53 … … 58 58 assert(job->retval != JOB_UNDEFINED_); 59 59 60 ipc_call id_t *iid_ptr= arg;60 ipc_call_t *icall = arg; 61 61 // TODO use descriptive return value (probably refactor job retval) 62 62 sysarg_t retval = (job->retval == JOB_OK) ? EOK : EIO; 63 async_answer_0( *iid_ptr, retval);64 free(i id_ptr);63 async_answer_0(icall, retval); 64 free(icall); 65 65 job_del_ref(&job); 66 66 } 67 67 68 static void sysman_unit_handle(ipc_call id_t iid, ipc_call_t *icall)68 static void sysman_unit_handle(ipc_call_t *icall) 69 69 { 70 70 char *unit_name = NULL; … … 84 84 } 85 85 86 async_answer_1(i id, EOK, unit->handle);86 async_answer_1(icall, EOK, unit->handle); 87 87 goto finish; 88 88 89 89 fail: 90 async_answer_0(i id, retval);90 async_answer_0(icall, retval); 91 91 finish: 92 92 free(unit_name); 93 93 } 94 94 95 static void sysman_unit_start_by_name(ipc_call id_t iid, ipc_call_t *icall)95 static void sysman_unit_start_by_name(ipc_call_t *icall) 96 96 { 97 97 char *unit_name = NULL; … … 105 105 } 106 106 107 int flags = IPC_GET_ARG1(*icall);107 int flags = ipc_get_arg1(icall); 108 108 sysman_log(LVL_DEBUG2, "%s(%s, %x)", __func__, unit_name, flags); 109 109 … … 120 120 } 121 121 122 ipc_call id_t *iid_ptr = box_callid(iid);123 if (i id_ptr== NULL) {122 ipc_call_t *icall_copy = box_callid(icall); 123 if (icall_copy == NULL) { 124 124 retval = ENOMEM; 125 125 goto answer; 126 126 } 127 127 retval = sysman_run_job(unit, STATE_STARTED, 0, &answer_callback, 128 i id_ptr);128 icall_copy); 129 129 if (retval != EOK) { 130 130 goto answer; … … 135 135 136 136 answer: 137 async_answer_0(i id, retval);137 async_answer_0(icall, retval); 138 138 finish: 139 139 free(unit_name); 140 140 } 141 141 142 static void sysman_unit_operation(ipc_callid_t iid, ipc_call_t *icall, 143 unit_state_t state) 142 static void sysman_unit_operation(ipc_call_t *icall, unit_state_t state) 144 143 { 145 144 sysarg_t retval; 146 145 147 unit_handle_t handle = IPC_GET_ARG1(*icall);148 int flags = IPC_GET_ARG2(*icall);149 sysman_log(LVL_DEBUG2, "%s(% i, %x, %i)", __func__,handle, flags, state);146 unit_handle_t handle = ipc_get_arg1(icall); 147 sysarg_t flags = ipc_get_arg2(icall); 148 sysman_log(LVL_DEBUG2, "%s(%p, %lx, %i)", __func__, icall->cap_handle, flags, state); 150 149 151 150 unit_t *unit = repo_find_unit_by_handle(handle); … … 160 159 } 161 160 162 ipc_call id_t *iid_ptr = box_callid(iid);163 if (i id_ptr== NULL) {161 ipc_call_t *icall_copy = box_callid(icall); 162 if (icall_copy == NULL) { 164 163 retval = ENOMEM; 165 164 goto answer; 166 165 } 167 166 retval = sysman_run_job(unit, state, 0, &answer_callback, 168 i id_ptr);167 icall_copy); 169 168 if (retval != EOK) { 170 169 goto answer; … … 175 174 176 175 answer: 177 async_answer_0(i id, retval);178 } 179 180 static void sysman_unit_start(ipc_call id_t iid, ipc_call_t *icall)181 { 182 sysman_unit_operation(i id, icall, STATE_STARTED);183 } 184 185 static void sysman_unit_stop(ipc_call id_t iid, ipc_call_t *icall)186 { 187 sysman_unit_operation(i id, icall, STATE_STOPPED);176 async_answer_0(icall, retval); 177 } 178 179 static void sysman_unit_start(ipc_call_t *icall) 180 { 181 sysman_unit_operation(icall, STATE_STARTED); 182 } 183 184 static void sysman_unit_stop(ipc_call_t *icall) 185 { 186 sysman_unit_operation(icall, STATE_STOPPED); 188 187 } 189 188 … … 210 209 } 211 210 212 static void sysman_get_units(ipc_call id_t iid, ipc_call_t *icall)213 { 214 ipc_call id_t callid;211 static void sysman_get_units(ipc_call_t *icall) 212 { 213 ipc_call_t call; 215 214 size_t size; 216 215 size_t act_size; 217 216 int rc; 218 217 219 if (!async_data_read_receive(&call id, &size)) {220 async_answer_0( callid, EREFUSED);221 async_answer_0(i id, EREFUSED);218 if (!async_data_read_receive(&call, &size)) { 219 async_answer_0(&call, EREFUSED); 220 async_answer_0(icall, EREFUSED); 222 221 return; 223 222 } … … 226 225 unit_handle_t *handles = malloc(size); 227 226 if (handles == NULL && size > 0) { 228 async_answer_0( callid, ENOMEM);229 async_answer_0(i id, ENOMEM);227 async_answer_0(&call, ENOMEM); 228 async_answer_0(icall, ENOMEM); 230 229 return; 231 230 } … … 234 233 rc = fill_handles_buffer(handles, size, &act_size); 235 234 if (rc != EOK) { 236 async_answer_0( callid, rc);237 async_answer_0(i id, rc);235 async_answer_0(&call, rc); 236 async_answer_0(icall, rc); 238 237 return; 239 238 } 240 239 241 240 size_t real_size = min(act_size, size); 242 sysarg_t retval = async_data_read_finalize( callid, handles, real_size);241 sysarg_t retval = async_data_read_finalize(&call, handles, real_size); 243 242 free(handles); 244 243 245 async_answer_1(i id, retval, act_size);246 } 247 248 static void sysman_unit_get_name(ipc_call id_t iid, ipc_call_t *icall)249 { 250 ipc_call id_t callid;244 async_answer_1(icall, retval, act_size); 245 } 246 247 static void sysman_unit_get_name(ipc_call_t *icall) 248 { 249 ipc_call_t call; 251 250 size_t size; 252 251 253 if (!async_data_read_receive(&call id, &size)) {254 async_answer_0( callid, EREFUSED);255 async_answer_0(i id, EREFUSED);256 return; 257 } 258 259 unit_t *u = repo_find_unit_by_handle( IPC_GET_ARG1(*icall));252 if (!async_data_read_receive(&call, &size)) { 253 async_answer_0(&call, EREFUSED); 254 async_answer_0(icall, EREFUSED); 255 return; 256 } 257 258 unit_t *u = repo_find_unit_by_handle(ipc_get_arg1(icall)); 260 259 if (u == NULL) { 261 async_answer_0( callid, ENOENT);262 async_answer_0(i id, ENOENT);260 async_answer_0(&call, ENOENT); 261 async_answer_0(icall, ENOENT); 263 262 return; 264 263 } 265 264 266 265 size_t real_size = min(str_size(u->name) + 1, size); 267 sysarg_t retval = async_data_read_finalize( callid, u->name, real_size);268 269 async_answer_0(i id, retval);270 } 271 272 static void sysman_unit_get_state(ipc_call id_t iid, ipc_call_t *icall)273 { 274 unit_t *u = repo_find_unit_by_handle( IPC_GET_ARG1(*icall));266 sysarg_t retval = async_data_read_finalize(&call, u->name, real_size); 267 268 async_answer_0(icall, retval); 269 } 270 271 static void sysman_unit_get_state(ipc_call_t *icall) 272 { 273 unit_t *u = repo_find_unit_by_handle(ipc_get_arg1(icall)); 275 274 if (u == NULL) { 276 async_answer_0(i id, ENOENT);275 async_answer_0(icall, ENOENT); 277 276 } else { 278 async_answer_1(i id, EOK, u->state);279 } 280 } 281 282 static void sysman_shutdown(ipc_call id_t iid, ipc_call_t *icall)283 { 284 int retval;277 async_answer_1(icall, EOK, u->state); 278 } 279 } 280 281 static void sysman_shutdown(ipc_call_t *icall) 282 { 283 errno_t retval; 285 284 unit_t *u = repo_find_unit_by_name(TARGET_SHUTDOWN); 286 285 if (u == NULL) { … … 293 292 294 293 finish: 295 async_answer_0(i id, retval);296 } 297 298 void sysman_connection_ctl(ipc_call id_t iid, ipc_call_t *icall)294 async_answer_0(icall, retval); 295 } 296 297 void sysman_connection_ctl(ipc_call_t *icall) 299 298 { 300 299 sysman_log(LVL_DEBUG2, "%s", __func__); 301 300 /* First, accept connection */ 302 async_answer_0(i id, EOK);301 async_answer_0(icall, EOK); 303 302 304 303 while (true) { 305 304 ipc_call_t call; 306 ipc_callid_t callid = async_get_call(&call); 307 308 if (!IPC_GET_IMETHOD(call)) { 305 306 if (!async_get_call(&call) || !ipc_get_imethod(&call)) { 309 307 /* Client disconnected */ 310 308 break; 311 309 } 312 310 313 switch ( IPC_GET_IMETHOD(call)) {311 switch (ipc_get_imethod(&call)) { 314 312 case SYSMAN_CTL_UNIT_HANDLE: 315 sysman_unit_handle( callid,&call);313 sysman_unit_handle(&call); 316 314 break; 317 315 case SYSMAN_CTL_UNIT_START_BY_NAME: 318 sysman_unit_start_by_name( callid,&call);316 sysman_unit_start_by_name(&call); 319 317 break; 320 318 case SYSMAN_CTL_UNIT_START: 321 sysman_unit_start( callid,&call);319 sysman_unit_start(&call); 322 320 break; 323 321 case SYSMAN_CTL_UNIT_STOP: 324 sysman_unit_stop( callid,&call);322 sysman_unit_stop(&call); 325 323 break; 326 324 case SYSMAN_CTL_GET_UNITS: 327 sysman_get_units( callid,&call);325 sysman_get_units(&call); 328 326 break; 329 327 case SYSMAN_CTL_UNIT_GET_NAME: 330 sysman_unit_get_name( callid,&call);328 sysman_unit_get_name(&call); 331 329 break; 332 330 case SYSMAN_CTL_UNIT_GET_STATE: 333 sysman_unit_get_state( callid,&call);331 sysman_unit_get_state(&call); 334 332 break; 335 333 case SYSMAN_CTL_SHUTDOWN: 336 sysman_shutdown( callid,&call);334 sysman_shutdown(&call); 337 335 break; 338 336 default: 339 async_answer_0( callid, ENOENT);337 async_answer_0(&call, ENOENT); 340 338 } 341 339 } -
uspace/srv/sysman/connection_ctl.h
rf92b315 r241f1985 32 32 #include <async.h> 33 33 34 extern void sysman_connection_ctl(ipc_call id_t, ipc_call_t *);34 extern void sysman_connection_ctl(ipc_call_t *); 35 35 36 36 #endif -
uspace/srv/sysman/edge.c
rf92b315 r241f1985 122 122 * @return EOK on success 123 123 * @return ENOMEM 124 * @return EEXIST S124 * @return EEXIST 125 125 */ 126 126 int edge_connect(unit_t *input, unit_t *output) 127 127 { 128 128 if (edge_extract_internal(input, output)) { 129 return EEXIST S;129 return EEXIST; 130 130 } 131 131 -
uspace/srv/sysman/job.c
rf92b315 r241f1985 31 31 #include <errno.h> 32 32 #include <stdlib.h> 33 #include <str.h> 33 34 34 35 #include "repo.h" … … 66 67 link_initialize(&job->job_queue); 67 68 68 atomic_s et(&job->refcnt, 0);69 atomic_store(&job->refcnt, 0); 69 70 70 71 job->target_state = target_state; … … 163 164 void job_add_ref(job_t *job) 164 165 { 165 atomic_ inc(&job->refcnt);166 atomic_fetch_add(&job->refcnt, 1); 166 167 } 167 168 … … 178 179 179 180 assert(job != NULL); 180 assert(atomic_get(&job->refcnt) > 0); 181 if (atomic_predec(&job->refcnt) == 0) { 181 assert(atomic_load(&job->refcnt) > 0); 182 atomic_fetch_sub(&job->refcnt, 1); 183 if (atomic_load(&job->refcnt) == 0) { 182 184 job_destroy(job_ptr); 183 185 } … … 249 251 assert(!job->unit->job || job->unit->job == job); 250 252 251 sysman_log(LVL_DEBUG2, "%s(%p) %s ret %i, ref % i",253 sysman_log(LVL_DEBUG2, "%s(%p) %s ret %i, ref %u", 252 254 __func__, job, unit_name(job->unit), job->retval, 253 atomic_ get(&job->refcnt));255 atomic_load(&job->refcnt)); 254 256 255 257 job->state = JOB_FINISHED; -
uspace/srv/sysman/job.h
rf92b315 r241f1985 32 32 #include <adt/dyn_array.h> 33 33 #include <adt/list.h> 34 #include < atomic.h>34 #include <stdatomic.h> 35 35 #include <stdbool.h> 36 36 … … 58 58 struct job { 59 59 link_t job_queue; 60 atomic_ t refcnt;60 atomic_uint refcnt; 61 61 62 62 unit_state_t target_state; -
uspace/srv/sysman/job_closure.c
rf92b315 r241f1985 345 345 dyn_array_foreach(*job_closure, job_t *, job_it) { 346 346 sysman_log(LVL_DEBUG2, "%s\t%s, refs: %u", __func__, 347 unit_name((*job_it)->unit), atomic_ get(&(*job_it)->refcnt));347 unit_name((*job_it)->unit), atomic_load(&(*job_it)->refcnt)); 348 348 } 349 349 } -
uspace/srv/sysman/log.h
rf92b315 r241f1985 41 41 //#define sysman_log(level, fmt, ...) if(level > LVL_DEBUG2) printf("sysman: " fmt "\n", ##__VA_ARGS__) 42 42 43 extern void sysman_log(log_level_t, const char *, ...) PRINTF_ATTRIBUTE(2, 3);43 extern void sysman_log(log_level_t, const char *, ...) _HELENOS_PRINTF_ATTRIBUTE(2, 3); 44 44 45 45 extern void sysman_log_tofile(void); -
uspace/srv/sysman/main.c
rf92b315 r241f1985 66 66 */ 67 67 68 static void sysman_connection(ipc_call id_t iid, ipc_call_t *icall, void *arg)69 { 70 sysman_interface_t iface = IPC_GET_ARG1(*icall);68 static void sysman_connection(ipc_call_t *icall, void *arg) 69 { 70 sysman_interface_t iface = ipc_get_arg1(icall); 71 71 switch (iface) { 72 72 case SYSMAN_PORT_BROKER: 73 sysman_connection_broker(i id, icall);73 sysman_connection_broker(icall); 74 74 break; 75 75 case SYSMAN_PORT_CTL: 76 sysman_connection_ctl(i id, icall);76 sysman_connection_ctl(icall); 77 77 break; 78 78 default: 79 79 /* Unknown interface */ 80 async_answer_0(i id, ENOENT);80 async_answer_0(icall, ENOENT); 81 81 } 82 82 } 83 83 84 84 /** Build hard coded configuration */ 85 static int create_entry_configuration(void) {86 int rc;85 static errno_t create_entry_configuration(void) { 86 errno_t rc; 87 87 unit_t *mnt_initrd = NULL; 88 88 unit_t *cfg_init = NULL; … … 183 183 } 184 184 185 int rc = sysman_run_job(tgt, STATE_STARTED, 0, &sequence_job_handler,185 errno_t rc = sysman_run_job(tgt, STATE_STARTED, 0, &sequence_job_handler, 186 186 target_name_ptr); 187 187 … … 193 193 int main(int argc, char *argv[]) 194 194 { 195 async_set_client_connection(sysman_connection);196 195 printf(NAME ": HelenOS system daemon\n"); 197 196 … … 207 206 * Create initial configuration while we are in a single fibril 208 207 */ 209 int rc = create_entry_configuration();208 errno_t rc = create_entry_configuration(); 210 209 if (rc != EOK) { 211 210 sysman_log(LVL_FATAL, … … 222 221 223 222 /* We're service too */ 224 rc = service_register(SERVICE_SYSMAN );223 rc = service_register(SERVICE_SYSMAN, INTERFACE_SYSMAN, sysman_connection, NULL); 225 224 if (rc != EOK) { 226 225 sysman_log(LVL_FATAL, -
uspace/srv/sysman/repo.c
rf92b315 r241f1985 30 30 #include <adt/hash_table.h> 31 31 #include <adt/list.h> 32 #include <str.h> 32 33 #include <assert.h> 33 34 #include <errno.h> … … 55 56 } 56 57 57 static size_t units_by_handle_ht_key_hash( void *key)58 static size_t units_by_handle_ht_key_hash(const void *key) 58 59 { 59 60 return *(unit_handle_t *)key; … … 67 68 } 68 69 69 static bool units_by_handle_ht_key_equal( void *key, const ht_link_t *item)70 static bool units_by_handle_ht_key_equal(const void *key, const ht_link_t *item) 70 71 { 71 72 return *(unit_handle_t *)key == … … 88 89 } 89 90 90 static size_t units_by_name_ht_key_hash( void *key)91 static size_t units_by_name_ht_key_hash(const void *key) 91 92 { 92 93 return hash_string((const char *)key); … … 100 101 } 101 102 102 static bool units_by_name_ht_key_equal( void *key, const ht_link_t *item)103 static bool units_by_name_ht_key_equal(const void *key, const ht_link_t *item) 103 104 { 104 105 return str_cmp((const char *)key, … … 166 167 return EOK; 167 168 } else { 168 return EEXIST S;169 return EEXIST; 169 170 } 170 171 } -
uspace/srv/sysman/sm_task.c
rf92b315 r241f1985 210 210 } 211 211 212 int sm_task_start(void) 213 { 214 int rc = task_register_event_handler(&sm_task_event_handler, true); 215 return rc; 216 } 212 errno_t sm_task_start(void) 213 { 214 return task_register_event_handler(&sm_task_event_handler, true); 215 } -
uspace/srv/sysman/sm_task.h
rf92b315 r241f1985 33 33 typedef struct sm_task_event sm_task_event_t; 34 34 35 extern int sm_task_start(void);35 extern errno_t sm_task_start(void); 36 36 37 37 #endif -
uspace/srv/sysman/sysman.c
rf92b315 r241f1985 90 90 } 91 91 92 static size_t observed_objects_ht_key_hash( void *key)92 static size_t observed_objects_ht_key_hash(const void *key) 93 93 { 94 94 void *object = *(void **) key; … … 96 96 } 97 97 98 static bool observed_objects_ht_key_equal( void *key, const ht_link_t *item)98 static bool observed_objects_ht_key_equal(const void *key, const ht_link_t *item) 99 99 { 100 100 void *object = *(void **)key; … … 213 213 * @return EOK on successfully queued job 214 214 */ 215 int sysman_run_job(unit_t *unit, unit_state_t target_state, int flags,215 errno_t sysman_run_job(unit_t *unit, unit_state_t target_state, int flags, 216 216 callback_handler_t callback, void *callback_arg) 217 217 { … … 279 279 * @return ENOMEM 280 280 */ 281 int sysman_object_observer(void *object, callback_handler_t handler, void *data)282 { 283 int rc;281 errno_t sysman_object_observer(void *object, callback_handler_t handler, void *data) 282 { 283 errno_t rc; 284 284 observed_object_t *observed_object = NULL; 285 285 observed_object_t *new_observed_object = NULL; … … 314 314 } 315 315 316 int sysman_move_observers(void *src_object, void *dst_object)316 errno_t sysman_move_observers(void *src_object, void *dst_object) 317 317 { 318 318 ht_link_t *src_link = hash_table_find(&observed_objects, &src_object); -
uspace/srv/sysman/sysman.h
rf92b315 r241f1985 51 51 extern void sysman_events_init(void); 52 52 extern int sysman_events_loop(void *); 53 extern int sysman_run_job(unit_t *, unit_state_t, int, callback_handler_t, void *);53 extern errno_t sysman_run_job(unit_t *, unit_state_t, int, callback_handler_t, void *); 54 54 55 55 56 56 extern void sysman_raise_event(event_handler_t, void *); 57 57 extern void sysman_process_queue(void); 58 extern int sysman_object_observer(void *, callback_handler_t, void *);59 extern int sysman_move_observers(void *, void *);58 extern errno_t sysman_object_observer(void *, callback_handler_t, void *); 59 extern errno_t sysman_move_observers(void *, void *); 60 60 extern size_t sysman_observers_count(void *); 61 61 -
uspace/srv/sysman/test/job_closure.c
rf92b315 r241f1985 51 51 { 52 52 if (expected->size != actual->size) { 53 printf("%s: |expected|, |actual| = % u, %u\n",53 printf("%s: |expected|, |actual| = %lu, %lu\n", 54 54 __func__, expected->size, actual->size); 55 55 return false; -
uspace/srv/sysman/units/unit_cfg.c
rf92b315 r241f1985 55 55 * @param[out] unit_ptr Unit loaded from the file. Undefined when function fails. 56 56 */ 57 static int cfg_parse_file(const char *dirname, const char *filename,57 static errno_t cfg_parse_file(const char *dirname, const char *filename, 58 58 unit_t **unit_ptr) 59 59 { 60 int rc = EOK;60 errno_t rc = EOK; 61 61 unit_t *new_unit = NULL; 62 62 char *fn = NULL; … … 86 86 if (u != NULL) { 87 87 // TODO allow updating configuration of existing unit 88 rc = EEXIST S;88 rc = EEXIST; 89 89 goto finish; 90 90 } else { … … 136 136 list_foreach(text_parse.errors, link, text_parse_error_t, err) { 137 137 sysman_log(LVL_WARN, 138 "Error (%i) when parsing '%s' on line % i.",138 "Error (%i) when parsing '%s' on line %lu.", 139 139 err->parse_errno, fn, err->lineno); 140 140 } … … 151 151 } 152 152 153 static int cfg_load_configuration(const char *path)153 static errno_t cfg_load_configuration(const char *path) 154 154 { 155 155 DIR *dir; … … 167 167 while ((de = readdir(dir))) { 168 168 unit_t *unit = NULL; 169 int rc = cfg_parse_file(path, de->d_name, &unit);169 errno_t rc = cfg_parse_file(path, de->d_name, &unit); 170 170 if (rc != EOK) { 171 171 sysman_log(LVL_WARN, "Cannot load unit from file %s/%s", … … 183 183 closedir(dir); 184 184 185 int rc = repo_resolve_references();185 errno_t rc = repo_resolve_references(); 186 186 if (rc != EOK) { 187 187 repo_rollback(); … … 207 207 } 208 208 209 static int unit_cfg_load(unit_t *unit, ini_configuration_t *ini_conf,209 static errno_t unit_cfg_load(unit_t *unit, ini_configuration_t *ini_conf, 210 210 text_parse_t *text_parse) 211 211 { … … 225 225 } 226 226 227 static int unit_cfg_start(unit_t *unit)228 { 229 unit_cfg_t *u_cfg = CAST_CFG(unit); 230 assert(u_cfg); 231 232 int rc = cfg_load_configuration(u_cfg->path);227 static errno_t unit_cfg_start(unit_t *unit) 228 { 229 unit_cfg_t *u_cfg = CAST_CFG(unit); 230 assert(u_cfg); 231 232 errno_t rc = cfg_load_configuration(u_cfg->path); 233 233 234 234 if (rc == EOK) { … … 241 241 } 242 242 243 static int unit_cfg_stop(unit_t *unit)243 static errno_t unit_cfg_stop(unit_t *unit) 244 244 { 245 245 unit_cfg_t *u_cfg = CAST_CFG(unit); -
uspace/srv/sysman/units/unit_mnt.c
rf92b315 r241f1985 130 130 } 131 131 132 static int unit_mnt_load(unit_t *unit, ini_configuration_t *ini_conf,132 static errno_t unit_mnt_load(unit_t *unit, ini_configuration_t *ini_conf, 133 133 text_parse_t *text_parse) 134 134 { … … 148 148 } 149 149 150 static int mount_exec(void *arg)150 static errno_t mount_exec(void *arg) 151 151 { 152 152 mount_data_t *mnt_data = arg; … … 156 156 mnt_data->flags, mnt_data->instance); 157 157 158 int rc = mount(mnt_data->type, mnt_data->mountpoint, mnt_data->device,158 errno_t rc = vfs_mount_path(mnt_data->type, mnt_data->mountpoint, mnt_data->device, 159 159 mnt_data->options ? mnt_data->options : "", 160 160 mnt_data->flags, mnt_data->instance); … … 188 188 } 189 189 190 static int unit_mnt_start(unit_t *unit)190 static errno_t unit_mnt_start(unit_t *unit) 191 191 { 192 192 unit_mnt_t *u_mnt = CAST_MNT(unit); … … 228 228 } 229 229 230 static int unit_mnt_stop(unit_t *unit)230 static errno_t unit_mnt_stop(unit_t *unit) 231 231 { 232 232 unit_mnt_t *u_mnt = CAST_MNT(unit); … … 245 245 * unmount synchronously in the event loop fibril. 246 246 */ 247 int rc = unmount(u_mnt->mountpoint);247 errno_t rc = vfs_unmount_path(u_mnt->mountpoint); 248 248 249 249 if (rc == EOK) { -
uspace/srv/sysman/units/unit_svc.c
rf92b315 r241f1985 32 32 #include <stdlib.h> 33 33 #include <task.h> 34 #include <str.h> 34 35 35 36 #include "log.h" … … 58 59 } 59 60 60 static int unit_svc_load(unit_t *unit, ini_configuration_t *ini_conf,61 static errno_t unit_svc_load(unit_t *unit, ini_configuration_t *ini_conf, 61 62 text_parse_t *text_parse) 62 63 { … … 76 77 } 77 78 78 static int unit_svc_start(unit_t *unit)79 static errno_t unit_svc_start(unit_t *unit) 79 80 { 80 81 unit_svc_t *u_svc = CAST_SVC(unit); … … 84 85 assert(unit->state == STATE_STOPPED); 85 86 86 int rc = task_spawnv(&u_svc->main_task_id, NULL, u_svc->exec_start.path,87 errno_t rc = task_spawnv(&u_svc->main_task_id, NULL, u_svc->exec_start.path, 87 88 u_svc->exec_start.argv); 88 89 … … 100 101 */ 101 102 if (str_cmp(unit->name, "devman.svc") == 0) { 102 async_usleep(100000);103 fibril_usleep(100000); 103 104 if (console_kcon()) { 104 105 sysman_log(LVL_DEBUG2, "%s: Kconsole grabbed.", __func__); … … 111 112 } 112 113 113 static int unit_svc_stop(unit_t *unit)114 static errno_t unit_svc_stop(unit_t *unit) 114 115 { 115 116 unit_svc_t *u_svc = CAST_SVC(unit); … … 129 130 } 130 131 131 int rc = task_kill(u_svc->main_task_id);132 errno_t rc = task_kill(u_svc->main_task_id); 132 133 133 134 if (rc != EOK) { -
uspace/srv/taskman/event.c
rf92b315 r241f1985 49 49 task_id_t id; /**< Task ID who we wait for. */ 50 50 task_id_t waiter_id; /**< Task ID who waits. */ 51 ipc_call id_t callid; /**< Call ID waiting for the event. */51 ipc_call_t *icall; /**< Call ID waiting for the event. */ 52 52 int flags; /**< Wait flags. */ 53 53 } pending_wait_t; … … 59 59 static FIBRIL_RWLOCK_INITIALIZE(listeners_lock); 60 60 61 int event_init(void)61 errno_t event_init(void) 62 62 { 63 63 list_initialize(&pending_waits); … … 150 150 int match = notify_flags & pr->flags; 151 151 // TODO why do I even accept such calls? 152 bool answer = !(pr-> callid & IPC_CALLID_NOTIFICATION);152 bool answer = !(pr->icall->flags & IPC_CALL_NOTIF); 153 153 154 154 if (match == 0) { … … 156 156 /* Nothing to wait for anymore */ 157 157 if (answer) { 158 async_answer_0(pr-> callid, EINTR);158 async_answer_0(pr->icall, EINTR); 159 159 } 160 160 } else { … … 165 165 if ((pr->flags & TASK_WAIT_BOTH) && match == TASK_WAIT_EXIT) { 166 166 /* No sense to wait for both anymore */ 167 async_answer_1(pr-> callid, EINTR, t->exit);167 async_answer_1(pr->icall, EINTR, t->exit); 168 168 } else { 169 169 /* Send both exit status and retval, caller 170 170 * should know what is valid */ 171 async_answer_3(pr-> callid, EOK, t->exit,171 async_answer_3(pr->icall, EOK, t->exit, 172 172 t->retval, rest); 173 173 } … … 195 195 196 196 void event_register_listener(task_id_t id, bool past_events, async_sess_t *sess, 197 ipc_call id_t iid)198 { 199 int rc = EOK;197 ipc_call_t *icall) 198 { 199 errno_t rc = EOK; 200 200 /* 201 201 * We have lock of tasks structures so that we can guarantee … … 219 219 * while we dump events. 220 220 */ 221 async_answer_0(i id, rc);221 async_answer_0(icall, rc); 222 222 if (past_events) { 223 223 task_foreach(&dump_walker, t->sess); … … 228 228 fibril_rwlock_write_unlock(&task_hash_table_lock); 229 229 if (rc != EOK) { 230 async_answer_0(i id, rc);231 } 232 } 233 234 void wait_for_task(task_id_t id, int flags, ipc_call id_t callid,230 async_answer_0(icall, rc); 231 } 232 } 233 234 void wait_for_task(task_id_t id, int flags, ipc_call_t *icall, 235 235 task_id_t waiter_id) 236 236 { … … 244 244 if (t == NULL) { 245 245 /* No such task exists. */ 246 async_answer_0( callid, ENOENT);246 async_answer_0(icall, ENOENT); 247 247 return; 248 248 } … … 250 250 if (t->exit != TASK_EXIT_RUNNING) { 251 251 //TODO are flags BOTH processed correctly here? 252 async_answer_3( callid, EOK, t->exit, t->retval, 0);252 async_answer_3(icall, EOK, t->exit, t->retval, 0); 253 253 return; 254 254 } … … 267 267 } 268 268 269 int rc = EOK;269 errno_t rc = EOK; 270 270 if (pr == NULL) { 271 271 pr = malloc(sizeof(pending_wait_t)); … … 279 279 pr->waiter_id = waiter_id; 280 280 pr->flags = flags; 281 pr-> callid = callid;281 pr->icall = icall; 282 282 283 283 list_append(&pr->link, &pending_waits); … … 288 288 * fibril). 289 289 */ 290 rc = EEXIST S;290 rc = EEXIST; 291 291 } else { 292 292 /* … … 294 294 */ 295 295 pr->flags &= ~TASK_WAIT_BOTH; // TODO maybe new flags should be set? 296 pr-> callid = callid;296 pr->icall = icall; 297 297 } 298 298 … … 300 300 fibril_rwlock_write_unlock(&pending_wait_lock); 301 301 // TODO why IPC_CALLID_NOTIFICATION? explain! 302 if (rc != EOK && !( callid & IPC_CALLID_NOTIFICATION)) {303 async_answer_0( callid, rc);304 } 305 } 306 307 308 int task_set_retval(task_id_t sender, int retval, bool wait_for_exit)309 { 310 int rc = EOK;302 if (rc != EOK && !(icall->flags & IPC_CALL_NOTIF)) { 303 async_answer_0(icall, rc); 304 } 305 } 306 307 308 errno_t task_set_retval(task_id_t sender, int retval, bool wait_for_exit) 309 { 310 errno_t rc = EOK; 311 311 312 312 fibril_rwlock_write_lock(&task_hash_table_lock); -
uspace/srv/taskman/event.h
rf92b315 r241f1985 39 39 #include <abi/proc/task.h> 40 40 41 extern int event_init(void);41 extern errno_t event_init(void); 42 42 43 43 extern void event_register_listener(task_id_t, bool, async_sess_t *, 44 ipc_call id_t);45 extern void dump_events(task_id_t, ipc_call id_t);46 extern void wait_for_task(task_id_t, int, ipc_call id_t, task_id_t);47 extern int task_set_retval(task_id_t, int, bool);44 ipc_call_t *); 45 extern void dump_events(task_id_t, ipc_call_t *); 46 extern void wait_for_task(task_id_t, int, ipc_call_t *, task_id_t); 47 extern errno_t task_set_retval(task_id_t, int, bool); 48 48 49 49 extern void task_terminated(task_id_t, exit_reason_t); -
uspace/srv/taskman/main.c
rf92b315 r241f1985 71 71 * Static functions 72 72 */ 73 static void connect_to_loader(ipc_call id_t iid, ipc_call_t *icall)74 { 75 DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall-> in_task_id);73 static void connect_to_loader(ipc_call_t *icall) 74 { 75 DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->task_id); 76 76 /* We don't accept the connection request, we forward it instead to 77 77 * freshly spawned loader. */ 78 int rc = loader_spawn("loader");79 80 if (rc != EOK) { 81 async_answer_0(i id, rc);78 errno_t rc = loader_spawn("loader"); 79 80 if (rc != EOK) { 81 async_answer_0(icall, rc); 82 82 return; 83 83 } … … 89 89 /* Forward the connection request (strip interface arg). */ 90 90 async_exch_t *exch = async_exchange_begin(sess_ref->sess); 91 rc = async_forward_ fast(iid, exch,92 IPC_GET_ARG2(*icall),93 IPC_GET_ARG3(*icall),94 0,IPC_FF_NONE);91 rc = async_forward_1(icall, exch, 92 ipc_get_arg2(icall), 93 ipc_get_arg3(icall), 94 IPC_FF_NONE); 95 95 async_exchange_end(exch); 96 96 … … 100 100 101 101 if (rc != EOK) { 102 async_answer_0(i id, rc);102 async_answer_0(icall, rc); 103 103 return; 104 104 } … … 107 107 } 108 108 109 static void connect_to_ns(ipc_call id_t iid, ipc_call_t *icall)110 { 111 DPRINTF("%s, %llu\n", __func__, icall-> in_task_id);109 static void connect_to_ns(ipc_call_t *icall) 110 { 111 DPRINTF("%s, %llu\n", __func__, icall->task_id); 112 112 113 113 /* Wait until we know NS */ … … 120 120 /* Do not accept connection, forward it */ 121 121 async_exch_t *exch = async_exchange_begin(session_ns); 122 int rc = async_forward_fast(iid, exch, 0, 0, 0, IPC_FF_NONE);122 errno_t rc = async_forward_0(icall, exch, 0, IPC_FF_NONE); 123 123 async_exchange_end(exch); 124 124 125 125 if (rc != EOK) { 126 async_answer_0(i id, rc);127 return; 128 } 129 } 130 131 static void taskman_new_task(ipc_call id_t iid, ipc_call_t *icall)132 { 133 int rc = task_intro(icall->in_task_id);134 async_answer_0(i id, rc);135 } 136 137 static void taskman_i_am_ns(ipc_call id_t iid, ipc_call_t *icall)138 { 139 DPRINTF("%s, %llu\n", __func__, icall-> in_task_id);140 int rc = EOK;126 async_answer_0(icall, rc); 127 return; 128 } 129 } 130 131 static void taskman_new_task(ipc_call_t *icall) 132 { 133 errno_t rc = task_intro(icall->task_id); 134 async_answer_0(icall, rc); 135 } 136 137 static void taskman_i_am_ns(ipc_call_t *icall) 138 { 139 DPRINTF("%s, %llu\n", __func__, icall->task_id); 140 errno_t rc = EOK; 141 141 142 142 fibril_mutex_lock(&session_ns_mtx); 143 143 if (session_ns != NULL) { 144 rc = EEXIST S;144 rc = EEXIST; 145 145 goto finish; 146 146 } … … 157 157 finish: 158 158 fibril_mutex_unlock(&session_ns_mtx); 159 async_answer_0(i id, rc);160 } 161 162 static void taskman_ctl_wait(ipc_call id_t iid, ipc_call_t *icall)159 async_answer_0(icall, rc); 160 } 161 162 static void taskman_ctl_wait(ipc_call_t *icall) 163 163 { 164 164 task_id_t id = (task_id_t) 165 MERGE_LOUP32( IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));166 int flags = IPC_GET_ARG3(*icall);167 task_id_t waiter_id = icall-> in_task_id;168 169 wait_for_task(id, flags, i id, waiter_id);170 } 171 172 static void taskman_ctl_retval(ipc_call id_t iid, ipc_call_t *icall)173 { 174 task_id_t sender = icall-> in_task_id;175 int retval = IPC_GET_ARG1(*icall);176 bool wait_for_exit = IPC_GET_ARG2(*icall);165 MERGE_LOUP32(ipc_get_arg1(icall), ipc_get_arg2(icall)); 166 int flags = ipc_get_arg3(icall); 167 task_id_t waiter_id = icall->task_id; 168 169 wait_for_task(id, flags, icall, waiter_id); 170 } 171 172 static void taskman_ctl_retval(ipc_call_t *icall) 173 { 174 task_id_t sender = icall->task_id; 175 int retval = ipc_get_arg1(icall); 176 bool wait_for_exit = ipc_get_arg2(icall); 177 177 178 178 DPRINTF("%s:%i from %llu/%i\n", __func__, __LINE__, sender, retval); 179 179 180 int rc = task_set_retval(sender, retval, wait_for_exit);181 async_answer_0(i id, rc);182 } 183 184 static void taskman_ctl_ev_callback(ipc_call id_t iid, ipc_call_t *icall)185 { 186 DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall-> in_task_id);187 188 bool past_events = IPC_GET_ARG1(*icall);180 errno_t rc = task_set_retval(sender, retval, wait_for_exit); 181 async_answer_0(icall, rc); 182 } 183 184 static void taskman_ctl_ev_callback(ipc_call_t *icall) 185 { 186 DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->task_id); 187 188 bool past_events = ipc_get_arg1(icall); 189 189 190 190 /* Atomic -- will be used for notifications only */ 191 191 async_sess_t *sess = async_callback_receive(EXCHANGE_ATOMIC); 192 192 if (sess == NULL) { 193 async_answer_0(i id, ENOMEM);194 return; 195 } 196 197 event_register_listener(icall-> in_task_id, past_events, sess, iid);198 } 199 200 static void task_exit_event(ipc_call id_t iid, ipc_call_t *icall, void *arg)201 { 202 task_id_t id = MERGE_LOUP32( IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));203 exit_reason_t exit_reason = IPC_GET_ARG3(*icall);193 async_answer_0(icall, ENOMEM); 194 return; 195 } 196 197 event_register_listener(icall->task_id, past_events, sess, icall); 198 } 199 200 static void task_exit_event(ipc_call_t *icall, void *arg) 201 { 202 task_id_t id = MERGE_LOUP32(ipc_get_arg1(icall), ipc_get_arg2(icall)); 203 exit_reason_t exit_reason = ipc_get_arg3(icall); 204 204 DPRINTF("%s:%i from %llu/%i\n", __func__, __LINE__, id, exit_reason); 205 205 task_terminated(id, exit_reason); 206 206 } 207 207 208 static void task_fault_event(ipc_call id_t iid, ipc_call_t *icall, void *arg)209 { 210 task_id_t id = MERGE_LOUP32( IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));208 static void task_fault_event(ipc_call_t *icall, void *arg) 209 { 210 task_id_t id = MERGE_LOUP32(ipc_get_arg1(icall), ipc_get_arg2(icall)); 211 211 DPRINTF("%s:%i from %llu\n", __func__, __LINE__, id); 212 212 task_failed(id); 213 213 } 214 214 215 static void loader_callback(ipc_call id_t iid, ipc_call_t *icall)216 { 217 DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall-> in_task_id);215 static void loader_callback(ipc_call_t *icall) 216 { 217 DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->task_id); 218 218 // TODO check that loader is expected, would probably discard prodcons 219 219 // scheme … … 222 222 sess_ref_t *sess_ref = malloc(sizeof(sess_ref_t)); 223 223 if (sess_ref == NULL) { 224 async_answer_0(i id, ENOMEM);224 async_answer_0(icall, ENOMEM); 225 225 } 226 226 … … 228 228 sess_ref->sess = async_callback_receive_start(EXCHANGE_ATOMIC, icall); 229 229 if (sess_ref->sess == NULL) { 230 async_answer_0(i id, EINVAL);231 return; 232 } 233 234 async_answer_0(i id, EOK);230 async_answer_0(icall, EINVAL); 231 return; 232 } 233 234 async_answer_0(icall, EOK); 235 235 236 236 /* Notify spawners */ … … 239 239 } 240 240 241 static bool handle_call(ipc_call id_t iid, ipc_call_t *icall)242 { 243 switch ( IPC_GET_IMETHOD(*icall)) {241 static bool handle_call(ipc_call_t *icall) 242 { 243 switch (ipc_get_imethod(icall)) { 244 244 case TASKMAN_NEW_TASK: 245 taskman_new_task(i id, icall);245 taskman_new_task(icall); 246 246 break; 247 247 case TASKMAN_I_AM_NS: 248 taskman_i_am_ns(i id, icall);248 taskman_i_am_ns(icall); 249 249 break; 250 250 case TASKMAN_WAIT: 251 taskman_ctl_wait(i id, icall);251 taskman_ctl_wait(icall); 252 252 break; 253 253 case TASKMAN_RETVAL: 254 taskman_ctl_retval(i id, icall);254 taskman_ctl_retval(icall); 255 255 break; 256 256 case TASKMAN_EVENT_CALLBACK: 257 taskman_ctl_ev_callback(i id, icall);257 taskman_ctl_ev_callback(icall); 258 258 break; 259 259 default: … … 263 263 } 264 264 265 static bool handle_implicit_call(ipc_call id_t iid, ipc_call_t *icall)265 static bool handle_implicit_call(ipc_call_t *icall) 266 266 { 267 267 /*DPRINTF("%s:%i %i(%i) from %llu\n", __func__, __LINE__, … … 270 270 icall->in_task_id);*/ 271 271 272 if ( IPC_GET_IMETHOD(*icall) < IPC_FIRST_USER_METHOD) {273 switch ( IPC_GET_ARG1(*icall)) {272 if (ipc_get_imethod(icall) < IPC_FIRST_USER_METHOD) { 273 switch (ipc_get_arg1(icall)) { 274 274 case TASKMAN_CONNECT_TO_NS: 275 connect_to_ns(i id, icall);275 connect_to_ns(icall); 276 276 break; 277 277 case TASKMAN_CONNECT_TO_LOADER: 278 connect_to_loader(i id, icall);278 connect_to_loader(icall); 279 279 break; 280 280 case TASKMAN_LOADER_CALLBACK: 281 loader_callback(i id, icall);281 loader_callback(icall); 282 282 break; 283 283 default: … … 286 286 } 287 287 } else { 288 return handle_call(i id, icall);288 return handle_call(icall); 289 289 } 290 290 … … 292 292 } 293 293 294 static void implicit_connection(ipc_call id_t iid, ipc_call_t *icall, void *arg)295 { 296 if (!handle_implicit_call(i id, icall)) {297 async_answer_0(i id, ENOTSUP);294 static void implicit_connection(ipc_call_t *icall, void *arg) 295 { 296 if (!handle_implicit_call(icall)) { 297 async_answer_0(icall, ENOTSUP); 298 298 return; 299 299 } … … 301 301 while (true) { 302 302 ipc_call_t call; 303 ipc_callid_t callid = async_get_call(&call); 304 305 if (!IPC_GET_IMETHOD(call)) { 303 304 if (!async_get_call(&call) || !ipc_get_imethod(&call)) { 306 305 /* Client disconnected */ 307 306 break; 308 307 } 309 308 310 if (!handle_implicit_call( callid,&call)) {311 async_answer_0( callid, ENOTSUP);309 if (!handle_implicit_call(&call)) { 310 async_answer_0(icall, ENOTSUP); 312 311 break; 313 312 } … … 315 314 } 316 315 317 static void taskman_connection(ipc_call id_t iid, ipc_call_t *icall, void *arg)316 static void taskman_connection(ipc_call_t *icall, void *arg) 318 317 { 319 318 /* … … 324 323 * "listening" on such connections. 325 324 */ 326 if (!handle_implicit_call(i id, icall)) {327 /* If cannot handle connection requ st, give up trying */328 async_answer_0(i id, EHANGUP);325 if (!handle_implicit_call(icall)) { 326 /* If cannot handle connection request, give up trying */ 327 async_answer_0(icall, EHANGUP); 329 328 return; 330 329 } … … 339 338 /* Initialization */ 340 339 prodcons_initialize(&sess_queue); 341 int rc = tasks_init();340 errno_t rc = tasks_init(); 342 341 if (rc != EOK) { 343 342 return rc; … … 368 367 /* Start sysman server */ 369 368 async_set_implicit_connection(implicit_connection); 370 async_set_ client_connection(taskman_connection);369 async_set_fallback_port_handler(taskman_connection, NULL); 371 370 372 371 printf(NAME ": Accepting connections\n"); -
uspace/srv/taskman/task.c
rf92b315 r241f1985 57 57 */ 58 58 59 static size_t ht_task_key_hash( void *key)59 static size_t ht_task_key_hash(const void *key) 60 60 { 61 61 return *(task_id_t*)key; … … 68 68 } 69 69 70 static bool ht_task_key_equal( void *key, const ht_link_t *item)70 static bool ht_task_key_equal(const void *key, const ht_link_t *item) 71 71 { 72 72 task_t *ht = hash_table_get_inst(item, task_t, link); … … 199 199 task_t *t = task_get_by_id(id); 200 200 if (t != NULL) { 201 rc = EEXIST S;201 rc = EEXIST; 202 202 goto finish; 203 203 } -
uspace/srv/vfs/Makefile
rf92b315 r241f1985 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBSYSMAN_PREFIX)/libsysman.a32 EXTRA_CFLAGS += -I$( LIBSYSMAN_PREFIX)/include31 LIBS = sysman 32 EXTRA_CFLAGS += -I$(USPACE_PREFIX)/lib/sysman/include 33 33 BINARY = vfs 34 34 STATIC_NEEDED = y -
uspace/srv/vfs/vfs.c
rf92b315 r241f1985 43 43 #include <as.h> 44 44 #include <async.h> 45 #include < atomic.h>45 #include <stdatomic.h> 46 46 #include <errno.h> 47 47 #include <str_error.h> -
uspace/srv/vfs/vfs.h
rf92b315 r241f1985 178 178 extern fs_handle_t fs_name_to_handle(const char *, unsigned int instance, bool); 179 179 extern vfs_info_t *fs_handle_to_info(fs_handle_t); 180 extern int vfs_get_fstypes(vfs_fstypes_t *); 180 181 extern errno_t fs_unit_name(const char *, unsigned int, char **); 181 182 -
uspace/srv/vfs/vfs_ops.c
rf92b315 r241f1985 50 50 #include <assert.h> 51 51 #include <vfs/canonify.h> 52 #include <sysman/ctl.h> 52 53 53 54 /* Forward declarations of static functions. */ 54 55 static errno_t vfs_truncate_internal(fs_handle_t, service_id_t, fs_index_t, 55 56 aoff64_t); 57 58 static errno_t vfs_fs_request_start(const char *fs_name, unsigned int instance); 56 59 57 60 /** … … 144 147 */ 145 148 fibril_mutex_unlock(&fs_list_lock); 146 rc = vfs_fs_request_start(fs_name, instance);149 errno_t rc = vfs_fs_request_start(fsname, instance); 147 150 fibril_mutex_lock(&fs_list_lock); 148 151 149 152 if (rc != EOK) { 150 fibril_mutex_unlock(&fs_list_lock); 151 async_answer_0(callid, rc); 152 async_answer_0(rid, rc); 153 free(mp); 154 free(fs_name); 155 free(opts); 156 return; 153 return rc; 157 154 } 155 158 156 /* 159 157 * Succesful start request, new server should be … … 216 214 } 217 215 218 static int vfs_fs_request_start(const char *fs_name, unsigned int instance)216 static errno_t vfs_fs_request_start(const char *fs_name, unsigned int instance) 219 217 { 220 218 char *unit_name = NULL; -
uspace/srv/vfs/vfs_register.c
rf92b315 r241f1985 40 40 #include <assert.h> 41 41 #include <async.h> 42 #include < atomic.h>42 #include <stdatomic.h> 43 43 #include <ctype.h> 44 44 #include <errno.h> … … 169 169 fibril_mutex_unlock(&fs_list_lock); 170 170 free(fs_info); 171 async_answer_0(r id, rc);172 return; 173 } 174 sysman_main_exposee_added(unit_name, req uest->in_task_id);171 async_answer_0(req, rc); 172 return; 173 } 174 sysman_main_exposee_added(unit_name, req->task_id); 175 175 free(unit_name); 176 176
Note:
See TracChangeset
for help on using the changeset viewer.
