Changeset 241f1985 in mainline for uspace/srv


Ignore:
Timestamp:
2019-08-31T10:45:17Z (7 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
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)
Message:

Correcting failure from previous merge

The commits from Michal Koutný from the branch system-daemon
where built on a old version of Helenos. Because of this
many types and API functions have changed. This commit
upgrades the merge code

Location:
uspace/srv
Files:
37 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/Makefile

    rf92b315 r241f1985  
    2929
    3030USPACE_PREFIX = ../..
    31 LIBS = $(LIBSYSMAN_PREFIX)/libsysman.a
    32 EXTRA_CFLAGS += -I$(LIBSYSMAN_PREFIX)/include
     31LIBS = sysman
    3332BINARY = devman
    3433STATIC_NEEDED = y
  • uspace/srv/devman/driver.c

    rf92b315 r241f1985  
    3434#include <dirent.h>
    3535#include <errno.h>
    36 #include <fcntl.h>
    3736#include <io/log.h>
    3837#include <vfs/vfs.h>
     38#include <dirent.h>
    3939#include <loc.h>
    4040#include <stdio.h>
    4141#include <str_error.h>
    42 #include <sys/stat.h>
    4342#include <sysman/ctl.h>
    4443#include <task.h>
  • uspace/srv/devman/drv_conn.c

    rf92b315 r241f1985  
    4141#include <io/log.h>
    4242#include <ipc/devman.h>
    43 #include <ipc/driver.h>
    4443#include <ipc/services.h>
    4544#include <loc.h>
     
    111110        if (rc != EOK) {
    112111                fibril_mutex_unlock(&driver->driver_mutex);
    113                 async_answer_0(callid, rc);
     112                async_answer_0(call, rc);
    114113                return NULL;
    115114        }
    116         sysman_main_exposee_added(unit_name, call->in_task_id);
     115        sysman_main_exposee_added(unit_name, call->task_id);
    117116        free(unit_name);
    118117       
  • uspace/srv/hid/compositor/compositor.c

    rf92b315 r241f1985  
    23042304
    23052305        /* Finally, register compositor server. */
    2306         async_set_fallback_port_handler(client_connection);
     2306        async_set_fallback_port_handler(client_connection, NULL);
    23072307       
    23082308        rc = loc_server_register(NAME);
  • uspace/srv/loader/main.c

    rf92b315 r241f1985  
    5656#include <entry_point.h>
    5757#include <errno.h>
    58 #include <fcntl.h>
    5958#include <fibril_synch.h>
    6059#include <ipc/loader.h>
     
    6261#include <ns.h>
    6362#include <str.h>
    64 #include <sys/types.h>
    6563#include <task.h>
    6664#include <taskman.h>
    67 #include <unistd.h>
    6865#include <vfs/vfs.h>
    6966#include <vfs/inbox.h>
  • uspace/srv/locsrv/Makefile

    rf92b315 r241f1985  
    2929
    3030USPACE_PREFIX = ../..
    31 LIBS = $(LIBSYSMAN_PREFIX)/libsysman.a
    32 EXTRA_CFLAGS += -I$(LIBSYSMAN_PREFIX)/include
     31LIBS = sysman
    3332BINARY = locsrv
    3433STATIC_NEEDED = y
  • uspace/srv/locsrv/locsrv.c

    rf92b315 r241f1985  
    584584                free(service);
    585585                free(unit_name);
    586                 async_answer_0(iid, rc);
     586                async_answer_0(icall, rc);
    587587                return;
    588588        }
     
    591591                sysman_exposee_added(unit_name);
    592592        } else {
    593                 sysman_main_exposee_added(unit_name, icall->in_task_id);
     593                sysman_main_exposee_added(unit_name, icall->task_id);
    594594        }
    595595        free(unit_name);
     
    619619 *
    620620 */
    621 static void loc_service_unregister(ipc_callid_t iid, ipc_call_t *icall,
    622     loc_server_t *server)
     621static void loc_service_unregister(ipc_call_t *icall, loc_server_t *server)
    623622{
    624623        loc_service_t *svc;
     
    840839        fibril_mutex_lock(&services_list_mutex);
    841840        const loc_service_t *svc;
    842         int flags = ipc_get_arg1(*icall);
     841        int flags = ipc_get_arg1(icall);
    843842        bool start_requested = false;
    844843       
     
    889888finish:
    890889        if (rc == EOK) {
    891                 async_answer_1(iid, EOK, svc->id);
     890                async_answer_1(icall, EOK, svc->id);
    892891        } else {
    893                 async_answer_0(iid, rc);
     892                async_answer_0(icall, rc);
    894893        }
    895894       
     
    16691668        if (rc != EOK) {
    16701669                printf("%s: Error while registering broker service: %s\n", NAME, str_error(rc));
     1670                return rc;
     1671        }
    16711672
    16721673        /* Let sysman know we are broker */
  • uspace/srv/ns/ns.c

    rf92b315 r241f1985  
    7575                        break;
    7676
    77                 task_id_t id;
    7877                errno_t retval;
    79 
    8078                service_t service;
    8179
     
    108106        }
    109107
    110         (void) ns_task_disconnect(&call);
     108        /* TODO: Ignore so far, in future we might unregister services */
     109        //(void) ns_task_disconnect(&call);
    111110        async_answer_0(&call, EOK);
    112111}
  • uspace/srv/sysman/Makefile

    rf92b315 r241f1985  
    2929
    3030USPACE_PREFIX = ../..
    31 LIBS = $(LIBCONF_PREFIX)/libconf.a
    32 EXTRA_CFLAGS += -I. \
    33         -I./units \
    34         -I$(LIBCONF_PREFIX)/include \
    35         -I$(LIBSYSMAN_PREFIX)/include
     31LIBS = conf sysman
     32EXTRA_CFLAGS = -I. -I./units
    3633BINARY = sysman
    3734STATIC_NEEDED = y
  • uspace/srv/sysman/connection_broker.c

    rf92b315 r241f1985  
    3636#include "sysman.h"
    3737
    38 static void sysman_broker_register(ipc_callid_t iid, ipc_call_t *icall)
     38static void sysman_broker_register(ipc_call_t *icall)
    3939{
    4040        sysman_log(LVL_DEBUG2, "%s", __func__);
    41         async_answer_0(iid, EOK);
     41        async_answer_0(icall, EOK);
    4242        /*
    4343         *  What exactly do here? Similar behavior that has locsrv with
     
    4848}
    4949
    50 static void sysman_ipc_forwarded(ipc_callid_t iid, ipc_call_t *icall)
     50static void sysman_ipc_forwarded(ipc_call_t *icall)
    5151{
    5252        sysman_log(LVL_DEBUG2, "%s", __func__);
    53         async_answer_0(iid, ENOTSUP);
     53        async_answer_0(icall, ENOTSUP);
    5454        // TODO implement
    5555}
    5656
    57 static void sysman_main_exposee_added(ipc_callid_t iid, ipc_call_t *icall)
     57static void sysman_main_exposee_added(ipc_call_t *icall)
    5858{
    5959        char *unit_name = NULL;
     
    7979
    8080finish:
    81         async_answer_0(iid, retval);
     81        async_answer_0(icall, retval);
    8282        free(unit_name);
    8383}
    8484
    85 static void sysman_exposee_added(ipc_callid_t iid, ipc_call_t *icall)
     85static void sysman_exposee_added(ipc_call_t *icall)
    8686{
    8787        char *exposee = NULL;
     
    100100
    101101finish:
    102         async_answer_0(iid, retval);
     102        async_answer_0(icall, retval);
    103103        free(exposee);
    104104}
    105105
    106 static void sysman_exposee_removed(ipc_callid_t iid, ipc_call_t *icall)
     106static void sysman_exposee_removed(ipc_call_t *icall)
    107107{
    108108        sysman_log(LVL_DEBUG2, "%s", __func__);
    109         async_answer_0(iid, ENOTSUP);
     109        async_answer_0(icall, ENOTSUP);
    110110        // TODO implement
    111111}
    112112
    113 void sysman_connection_broker(ipc_callid_t iid, ipc_call_t *icall)
     113void sysman_connection_broker(ipc_call_t *icall)
    114114{
    115115        sysman_log(LVL_DEBUG2, "%s", __func__);
    116116        /* First, accept connection */
    117         async_answer_0(iid, EOK);
     117        async_answer_0(icall, EOK);
    118118
    119119        while (true) {
    120120                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)) {
    124123                        /* Client disconnected */
    125124                        break;
    126125                }
    127126
    128                 switch (IPC_GET_IMETHOD(call)) {
     127                switch (ipc_get_imethod(&call)) {
    129128                case SYSMAN_BROKER_REGISTER:
    130                         sysman_broker_register(callid, &call);
     129                        sysman_broker_register(&call);
    131130                        break;
    132131                case SYSMAN_BROKER_IPC_FWD:
    133                         sysman_ipc_forwarded(callid, &call);
     132                        sysman_ipc_forwarded(&call);
    134133                        break;
    135134                case SYSMAN_BROKER_MAIN_EXP_ADDED:
    136                         sysman_main_exposee_added(callid, &call);
     135                        sysman_main_exposee_added(&call);
    137136                        break;
    138137                case SYSMAN_BROKER_EXP_ADDED:
    139                         sysman_exposee_added(callid, &call);
     138                        sysman_exposee_added(&call);
    140139                        break;
    141140                case SYSMAN_BROKER_EXP_REMOVED:
    142                         sysman_exposee_removed(callid, &call);
     141                        sysman_exposee_removed(&call);
    143142                        break;
    144143                default:
    145                         async_answer_0(callid, ENOENT);
     144                        async_answer_0(&call, ENOENT);
    146145                }
    147146        }
  • uspace/srv/sysman/connection_broker.h

    rf92b315 r241f1985  
    3232#include <async.h>
    3333
    34 extern void sysman_connection_broker(ipc_callid_t, ipc_call_t *);
     34extern void sysman_connection_broker(ipc_call_t *);
    3535
    3636#endif
  • uspace/srv/sysman/connection_ctl.c

    rf92b315 r241f1985  
    4343
    4444// TODO possibly provide as type-safe function + macro in sysman.h for generic boxing
    45 static ipc_callid_t *box_callid(ipc_callid_t iid)
    46 {
    47         ipc_callid_t *result = malloc(sizeof(ipc_callid_t));
    48         if (result) {
    49                 *result = iid;
    50         }
    51         return result;
     45static 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;
    5252}
    5353
     
    5858        assert(job->retval != JOB_UNDEFINED_);
    5959
    60         ipc_callid_t *iid_ptr = arg;
     60        ipc_call_t *icall = arg;
    6161        // TODO use descriptive return value (probably refactor job retval)
    6262        sysarg_t retval = (job->retval == JOB_OK) ? EOK : EIO;
    63         async_answer_0(*iid_ptr, retval);
    64         free(iid_ptr);
     63        async_answer_0(icall, retval);
     64        free(icall);
    6565        job_del_ref(&job);
    6666}
    6767
    68 static void sysman_unit_handle(ipc_callid_t iid, ipc_call_t *icall)
     68static void sysman_unit_handle(ipc_call_t *icall)
    6969{
    7070        char *unit_name = NULL;
     
    8484        }
    8585
    86         async_answer_1(iid, EOK, unit->handle);
     86        async_answer_1(icall, EOK, unit->handle);
    8787        goto finish;
    8888
    8989fail:
    90         async_answer_0(iid, retval);
     90        async_answer_0(icall, retval);
    9191finish:
    9292        free(unit_name);
    9393}
    9494
    95 static void sysman_unit_start_by_name(ipc_callid_t iid, ipc_call_t *icall)
     95static void sysman_unit_start_by_name(ipc_call_t *icall)
    9696{
    9797        char *unit_name = NULL;
     
    105105        }
    106106
    107         int flags = IPC_GET_ARG1(*icall);
     107        int flags = ipc_get_arg1(icall);
    108108        sysman_log(LVL_DEBUG2, "%s(%s, %x)", __func__, unit_name, flags);
    109109
     
    120120        }
    121121
    122         ipc_callid_t *iid_ptr = box_callid(iid);
    123         if (iid_ptr == NULL) {
     122        ipc_call_t *icall_copy = box_callid(icall);
     123        if (icall_copy == NULL) {
    124124                retval = ENOMEM;
    125125                goto answer;
    126126        }
    127127        retval = sysman_run_job(unit, STATE_STARTED, 0, &answer_callback,
    128             iid_ptr);
     128            icall_copy);
    129129        if (retval != EOK) {
    130130                goto answer;
     
    135135
    136136answer:
    137         async_answer_0(iid, retval);
     137        async_answer_0(icall, retval);
    138138finish:
    139139        free(unit_name);
    140140}
    141141
    142 static void sysman_unit_operation(ipc_callid_t iid, ipc_call_t *icall,
    143     unit_state_t state)
     142static void sysman_unit_operation(ipc_call_t *icall, unit_state_t state)
    144143{
    145144        sysarg_t retval;
    146145
    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);
    150149
    151150        unit_t *unit = repo_find_unit_by_handle(handle);
     
    160159        }
    161160
    162         ipc_callid_t *iid_ptr = box_callid(iid);
    163         if (iid_ptr == NULL) {
     161        ipc_call_t *icall_copy = box_callid(icall);
     162        if (icall_copy == NULL) {
    164163                retval = ENOMEM;
    165164                goto answer;
    166165        }
    167166        retval = sysman_run_job(unit, state, 0, &answer_callback,
    168             iid_ptr);
     167            icall_copy);
    169168        if (retval != EOK) {
    170169                goto answer;
     
    175174
    176175answer:
    177         async_answer_0(iid, retval);
    178 }
    179 
    180 static void sysman_unit_start(ipc_callid_t iid, ipc_call_t *icall)
    181 {
    182         sysman_unit_operation(iid, icall, STATE_STARTED);
    183 }
    184 
    185 static void sysman_unit_stop(ipc_callid_t iid, ipc_call_t *icall)
    186 {
    187         sysman_unit_operation(iid, icall, STATE_STOPPED);
     176        async_answer_0(icall, retval);
     177}
     178
     179static void sysman_unit_start(ipc_call_t *icall)
     180{
     181        sysman_unit_operation(icall, STATE_STARTED);
     182}
     183
     184static void sysman_unit_stop(ipc_call_t *icall)
     185{
     186        sysman_unit_operation(icall, STATE_STOPPED);
    188187}
    189188
     
    210209}
    211210
    212 static void sysman_get_units(ipc_callid_t iid, ipc_call_t *icall)
    213 {
    214         ipc_callid_t callid;
     211static void sysman_get_units(ipc_call_t *icall)
     212{
     213        ipc_call_t call;
    215214        size_t size;
    216215        size_t act_size;
    217216        int rc;
    218217       
    219         if (!async_data_read_receive(&callid, &size)) {
    220                 async_answer_0(callid, EREFUSED);
    221                 async_answer_0(iid, EREFUSED);
     218        if (!async_data_read_receive(&call, &size)) {
     219                async_answer_0(&call, EREFUSED);
     220                async_answer_0(icall, EREFUSED);
    222221                return;
    223222        }
     
    226225        unit_handle_t *handles = malloc(size);
    227226        if (handles == NULL && size > 0) {
    228                 async_answer_0(callid, ENOMEM);
    229                 async_answer_0(iid, ENOMEM);
     227                async_answer_0(&call, ENOMEM);
     228                async_answer_0(icall, ENOMEM);
    230229                return;
    231230        }
     
    234233        rc = fill_handles_buffer(handles, size, &act_size);
    235234        if (rc != EOK) {
    236                 async_answer_0(callid, rc);
    237                 async_answer_0(iid, rc);
     235                async_answer_0(&call, rc);
     236                async_answer_0(icall, rc);
    238237                return;
    239238        }
    240239       
    241240        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);
    243242        free(handles);
    244243       
    245         async_answer_1(iid, retval, act_size);
    246 }
    247 
    248 static void sysman_unit_get_name(ipc_callid_t iid, ipc_call_t *icall)
    249 {
    250         ipc_callid_t callid;
     244        async_answer_1(icall, retval, act_size);
     245}
     246
     247static void sysman_unit_get_name(ipc_call_t *icall)
     248{
     249        ipc_call_t call;
    251250        size_t size;
    252251       
    253         if (!async_data_read_receive(&callid, &size)) {
    254                 async_answer_0(callid, EREFUSED);
    255                 async_answer_0(iid, 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));
    260259        if (u == NULL) {
    261                 async_answer_0(callid, ENOENT);
    262                 async_answer_0(iid, ENOENT);
     260                async_answer_0(&call, ENOENT);
     261                async_answer_0(icall, ENOENT);
    263262                return;
    264263        }
    265264       
    266265        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(iid, retval);
    270 }
    271 
    272 static void sysman_unit_get_state(ipc_callid_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
     271static void sysman_unit_get_state(ipc_call_t *icall)
     272{
     273        unit_t *u = repo_find_unit_by_handle(ipc_get_arg1(icall));
    275274        if (u == NULL) {
    276                 async_answer_0(iid, ENOENT);
     275                async_answer_0(icall, ENOENT);
    277276        } else {
    278                 async_answer_1(iid, EOK, u->state);
    279         }
    280 }
    281 
    282 static void sysman_shutdown(ipc_callid_t iid, ipc_call_t *icall)
    283 {
    284         int retval;
     277                async_answer_1(icall, EOK, u->state);
     278        }
     279}
     280
     281static void sysman_shutdown(ipc_call_t *icall)
     282{
     283        errno_t retval;
    285284        unit_t *u = repo_find_unit_by_name(TARGET_SHUTDOWN);
    286285        if (u == NULL) {
     
    293292
    294293finish:
    295         async_answer_0(iid, retval);
    296 }
    297 
    298 void sysman_connection_ctl(ipc_callid_t iid, ipc_call_t *icall)
     294        async_answer_0(icall, retval);
     295}
     296
     297void sysman_connection_ctl(ipc_call_t *icall)
    299298{
    300299        sysman_log(LVL_DEBUG2, "%s", __func__);
    301300        /* First, accept connection */
    302         async_answer_0(iid, EOK);
     301        async_answer_0(icall, EOK);
    303302
    304303        while (true) {
    305304                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)) {
    309307                        /* Client disconnected */
    310308                        break;
    311309                }
    312310
    313                 switch (IPC_GET_IMETHOD(call)) {
     311                switch (ipc_get_imethod(&call)) {
    314312                case SYSMAN_CTL_UNIT_HANDLE:
    315                         sysman_unit_handle(callid, &call);
     313                        sysman_unit_handle(&call);
    316314                        break;
    317315                case SYSMAN_CTL_UNIT_START_BY_NAME:
    318                         sysman_unit_start_by_name(callid, &call);
     316                        sysman_unit_start_by_name(&call);
    319317                        break;
    320318                case SYSMAN_CTL_UNIT_START:
    321                         sysman_unit_start(callid, &call);
     319                        sysman_unit_start(&call);
    322320                        break;
    323321                case SYSMAN_CTL_UNIT_STOP:
    324                         sysman_unit_stop(callid, &call);
     322                        sysman_unit_stop(&call);
    325323                        break;
    326324                case SYSMAN_CTL_GET_UNITS:
    327                         sysman_get_units(callid, &call);
     325                        sysman_get_units(&call);
    328326                        break;
    329327                case SYSMAN_CTL_UNIT_GET_NAME:
    330                         sysman_unit_get_name(callid, &call);
     328                        sysman_unit_get_name(&call);
    331329                        break;
    332330                case SYSMAN_CTL_UNIT_GET_STATE:
    333                         sysman_unit_get_state(callid, &call);
     331                        sysman_unit_get_state(&call);
    334332                        break;
    335333                case SYSMAN_CTL_SHUTDOWN:
    336                         sysman_shutdown(callid, &call);
     334                        sysman_shutdown(&call);
    337335                        break;
    338336                default:
    339                         async_answer_0(callid, ENOENT);
     337                        async_answer_0(&call, ENOENT);
    340338                }
    341339        }
  • uspace/srv/sysman/connection_ctl.h

    rf92b315 r241f1985  
    3232#include <async.h>
    3333
    34 extern void sysman_connection_ctl(ipc_callid_t, ipc_call_t *);
     34extern void sysman_connection_ctl(ipc_call_t *);
    3535
    3636#endif
  • uspace/srv/sysman/edge.c

    rf92b315 r241f1985  
    122122 * @return        EOK on success
    123123 * @return        ENOMEM
    124  * @return        EEXISTS
     124 * @return        EEXIST
    125125 */
    126126int edge_connect(unit_t *input, unit_t *output)
    127127{
    128128        if (edge_extract_internal(input, output)) {
    129                 return EEXISTS;
     129                return EEXIST;
    130130        }
    131131
  • uspace/srv/sysman/job.c

    rf92b315 r241f1985  
    3131#include <errno.h>
    3232#include <stdlib.h>
     33#include <str.h>
    3334
    3435#include "repo.h"
     
    6667        link_initialize(&job->job_queue);
    6768
    68         atomic_set(&job->refcnt, 0);
     69        atomic_store(&job->refcnt, 0);
    6970
    7071        job->target_state = target_state;
     
    163164void job_add_ref(job_t *job)
    164165{
    165         atomic_inc(&job->refcnt);
     166        atomic_fetch_add(&job->refcnt, 1);
    166167}
    167168
     
    178179
    179180        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) {
    182184                job_destroy(job_ptr);
    183185        }
     
    249251        assert(!job->unit->job || job->unit->job == job);
    250252
    251         sysman_log(LVL_DEBUG2, "%s(%p) %s ret %i, ref %i",
     253        sysman_log(LVL_DEBUG2, "%s(%p) %s ret %i, ref %u",
    252254            __func__, job, unit_name(job->unit), job->retval,
    253             atomic_get(&job->refcnt));
     255            atomic_load(&job->refcnt));
    254256
    255257        job->state = JOB_FINISHED;
  • uspace/srv/sysman/job.h

    rf92b315 r241f1985  
    3232#include <adt/dyn_array.h>
    3333#include <adt/list.h>
    34 #include <atomic.h>
     34#include <stdatomic.h>
    3535#include <stdbool.h>
    3636
     
    5858struct job {
    5959        link_t job_queue;
    60         atomic_t refcnt;
     60        atomic_uint refcnt;
    6161
    6262        unit_state_t target_state;
  • uspace/srv/sysman/job_closure.c

    rf92b315 r241f1985  
    345345                dyn_array_foreach(*job_closure, job_t *, job_it) {
    346346                        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));
    348348                }
    349349        }
  • uspace/srv/sysman/log.h

    rf92b315 r241f1985  
    4141//#define sysman_log(level, fmt, ...) if(level > LVL_DEBUG2) printf("sysman: " fmt "\n", ##__VA_ARGS__)
    4242
    43 extern void sysman_log(log_level_t, const char *, ...) PRINTF_ATTRIBUTE(2, 3);
     43extern void sysman_log(log_level_t, const char *, ...) _HELENOS_PRINTF_ATTRIBUTE(2, 3);
    4444
    4545extern void sysman_log_tofile(void);
  • uspace/srv/sysman/main.c

    rf92b315 r241f1985  
    6666 */
    6767
    68 static void sysman_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    69 {
    70         sysman_interface_t iface = IPC_GET_ARG1(*icall);
     68static void sysman_connection(ipc_call_t *icall, void *arg)
     69{
     70        sysman_interface_t iface = ipc_get_arg1(icall);
    7171        switch (iface) {
    7272        case SYSMAN_PORT_BROKER:
    73                 sysman_connection_broker(iid, icall);
     73                sysman_connection_broker(icall);
    7474                break;
    7575        case SYSMAN_PORT_CTL:
    76                 sysman_connection_ctl(iid, icall);
     76                sysman_connection_ctl(icall);
    7777                break;
    7878        default:
    7979                /* Unknown interface */
    80                 async_answer_0(iid, ENOENT);
     80                async_answer_0(icall, ENOENT);
    8181        }
    8282}
    8383
    8484/** Build hard coded configuration */
    85 static int create_entry_configuration(void) {
    86         int rc;
     85static errno_t create_entry_configuration(void) {
     86        errno_t rc;
    8787        unit_t *mnt_initrd = NULL;
    8888        unit_t *cfg_init = NULL;
     
    183183        }
    184184
    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,
    186186            target_name_ptr);
    187187
     
    193193int main(int argc, char *argv[])
    194194{
    195         async_set_client_connection(sysman_connection);
    196195        printf(NAME ": HelenOS system daemon\n");
    197196
     
    207206         * Create initial configuration while we are in a single fibril
    208207         */
    209         int rc = create_entry_configuration();
     208        errno_t rc = create_entry_configuration();
    210209        if (rc != EOK) {
    211210                sysman_log(LVL_FATAL,
     
    222221
    223222        /* We're service too */
    224         rc = service_register(SERVICE_SYSMAN);
     223        rc = service_register(SERVICE_SYSMAN, INTERFACE_SYSMAN, sysman_connection, NULL);
    225224        if (rc != EOK) {
    226225                sysman_log(LVL_FATAL,
  • uspace/srv/sysman/repo.c

    rf92b315 r241f1985  
    3030#include <adt/hash_table.h>
    3131#include <adt/list.h>
     32#include <str.h>
    3233#include <assert.h>
    3334#include <errno.h>
     
    5556}
    5657
    57 static size_t units_by_handle_ht_key_hash(void *key)
     58static size_t units_by_handle_ht_key_hash(const void *key)
    5859{
    5960        return *(unit_handle_t *)key;
     
    6768}
    6869
    69 static bool units_by_handle_ht_key_equal(void *key, const ht_link_t *item)
     70static bool units_by_handle_ht_key_equal(const void *key, const ht_link_t *item)
    7071{
    7172        return *(unit_handle_t *)key ==
     
    8889}
    8990
    90 static size_t units_by_name_ht_key_hash(void *key)
     91static size_t units_by_name_ht_key_hash(const void *key)
    9192{
    9293        return hash_string((const char *)key);
     
    100101}
    101102
    102 static bool units_by_name_ht_key_equal(void *key, const ht_link_t *item)
     103static bool units_by_name_ht_key_equal(const void *key, const ht_link_t *item)
    103104{
    104105        return str_cmp((const char *)key,
     
    166167                return EOK;
    167168        } else {
    168                 return EEXISTS;
     169                return EEXIST;
    169170        }
    170171}
  • uspace/srv/sysman/sm_task.c

    rf92b315 r241f1985  
    210210}
    211211
    212 int sm_task_start(void)
    213 {
    214         int rc = task_register_event_handler(&sm_task_event_handler, true);
    215         return rc;
    216 }
     212errno_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  
    3333typedef struct sm_task_event sm_task_event_t;
    3434
    35 extern int sm_task_start(void);
     35extern errno_t sm_task_start(void);
    3636
    3737#endif
  • uspace/srv/sysman/sysman.c

    rf92b315 r241f1985  
    9090}
    9191
    92 static size_t observed_objects_ht_key_hash(void *key)
     92static size_t observed_objects_ht_key_hash(const void *key)
    9393{
    9494        void *object = *(void **) key;
     
    9696}
    9797
    98 static bool observed_objects_ht_key_equal(void *key, const ht_link_t *item)
     98static bool observed_objects_ht_key_equal(const void *key, const ht_link_t *item)
    9999{
    100100        void *object = *(void **)key;
     
    213213 * @return EOK on successfully queued job
    214214 */
    215 int sysman_run_job(unit_t *unit, unit_state_t target_state, int flags,
     215errno_t sysman_run_job(unit_t *unit, unit_state_t target_state, int flags,
    216216    callback_handler_t callback, void *callback_arg)
    217217{
     
    279279 * @return ENOMEM
    280280 */
    281 int sysman_object_observer(void *object, callback_handler_t handler, void *data)
    282 {
    283         int rc;
     281errno_t sysman_object_observer(void *object, callback_handler_t handler, void *data)
     282{
     283        errno_t rc;
    284284        observed_object_t *observed_object = NULL;
    285285        observed_object_t *new_observed_object = NULL;
     
    314314}
    315315
    316 int sysman_move_observers(void *src_object, void *dst_object)
     316errno_t sysman_move_observers(void *src_object, void *dst_object)
    317317{
    318318        ht_link_t *src_link = hash_table_find(&observed_objects, &src_object);
  • uspace/srv/sysman/sysman.h

    rf92b315 r241f1985  
    5151extern void sysman_events_init(void);
    5252extern int sysman_events_loop(void *);
    53 extern int sysman_run_job(unit_t *, unit_state_t, int, callback_handler_t, void *);
     53extern errno_t sysman_run_job(unit_t *, unit_state_t, int, callback_handler_t, void *);
    5454
    5555
    5656extern void sysman_raise_event(event_handler_t, void *);
    5757extern void sysman_process_queue(void);
    58 extern int sysman_object_observer(void *, callback_handler_t, void *);
    59 extern int sysman_move_observers(void *, void *);
     58extern errno_t sysman_object_observer(void *, callback_handler_t, void *);
     59extern errno_t sysman_move_observers(void *, void *);
    6060extern size_t sysman_observers_count(void *);
    6161
  • uspace/srv/sysman/test/job_closure.c

    rf92b315 r241f1985  
    5151{
    5252        if (expected->size != actual->size) {
    53                 printf("%s: |expected|, |actual| = %u, %u\n",
     53                printf("%s: |expected|, |actual| = %lu, %lu\n",
    5454                    __func__, expected->size, actual->size);
    5555                return false;
  • uspace/srv/sysman/units/unit_cfg.c

    rf92b315 r241f1985  
    5555 * @param[out]  unit_ptr   Unit loaded from the file. Undefined when function fails.
    5656 */
    57 static int cfg_parse_file(const char *dirname, const char *filename,
     57static errno_t cfg_parse_file(const char *dirname, const char *filename,
    5858    unit_t **unit_ptr)
    5959{
    60         int rc = EOK;
     60        errno_t rc = EOK;
    6161        unit_t *new_unit = NULL;
    6262        char *fn = NULL;
     
    8686        if (u != NULL) {
    8787                // TODO allow updating configuration of existing unit
    88                 rc = EEXISTS;
     88                rc = EEXIST;
    8989                goto finish;
    9090        } else {
     
    136136        list_foreach(text_parse.errors, link, text_parse_error_t, err) {
    137137                sysman_log(LVL_WARN,
    138                     "Error (%i) when parsing '%s' on line %i.",
     138                    "Error (%i) when parsing '%s' on line %lu.",
    139139                    err->parse_errno, fn, err->lineno);
    140140        }
     
    151151}
    152152
    153 static int cfg_load_configuration(const char *path)
     153static errno_t cfg_load_configuration(const char *path)
    154154{
    155155        DIR *dir;
     
    167167        while ((de = readdir(dir))) {
    168168                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);
    170170                if (rc != EOK) {
    171171                        sysman_log(LVL_WARN, "Cannot load unit from file %s/%s",
     
    183183        closedir(dir);
    184184
    185         int rc = repo_resolve_references();
     185        errno_t rc = repo_resolve_references();
    186186        if (rc != EOK) {
    187187                repo_rollback();
     
    207207}
    208208
    209 static int unit_cfg_load(unit_t *unit, ini_configuration_t *ini_conf,
     209static errno_t unit_cfg_load(unit_t *unit, ini_configuration_t *ini_conf,
    210210    text_parse_t *text_parse)
    211211{
     
    225225}
    226226
    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);
     227static 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);
    233233       
    234234        if (rc == EOK) {
     
    241241}
    242242
    243 static int unit_cfg_stop(unit_t *unit)
     243static errno_t unit_cfg_stop(unit_t *unit)
    244244{
    245245        unit_cfg_t *u_cfg = CAST_CFG(unit);
  • uspace/srv/sysman/units/unit_mnt.c

    rf92b315 r241f1985  
    130130}
    131131
    132 static int unit_mnt_load(unit_t *unit, ini_configuration_t *ini_conf,
     132static errno_t unit_mnt_load(unit_t *unit, ini_configuration_t *ini_conf,
    133133    text_parse_t *text_parse)
    134134{
     
    148148}
    149149
    150 static int mount_exec(void *arg)
     150static errno_t mount_exec(void *arg)
    151151{
    152152        mount_data_t *mnt_data = arg;
     
    156156            mnt_data->flags, mnt_data->instance);
    157157
    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,
    159159            mnt_data->options ? mnt_data->options : "",
    160160            mnt_data->flags, mnt_data->instance);
     
    188188}
    189189
    190 static int unit_mnt_start(unit_t *unit)
     190static errno_t unit_mnt_start(unit_t *unit)
    191191{
    192192        unit_mnt_t *u_mnt = CAST_MNT(unit);
     
    228228}
    229229
    230 static int unit_mnt_stop(unit_t *unit)
     230static errno_t unit_mnt_stop(unit_t *unit)
    231231{
    232232        unit_mnt_t *u_mnt = CAST_MNT(unit);
     
    245245         * unmount synchronously in the event loop fibril.
    246246         */
    247         int rc = unmount(u_mnt->mountpoint);
     247        errno_t rc = vfs_unmount_path(u_mnt->mountpoint);
    248248
    249249        if (rc == EOK) {
  • uspace/srv/sysman/units/unit_svc.c

    rf92b315 r241f1985  
    3232#include <stdlib.h>
    3333#include <task.h>
     34#include <str.h>
    3435
    3536#include "log.h"
     
    5859}
    5960
    60 static int unit_svc_load(unit_t *unit, ini_configuration_t *ini_conf,
     61static errno_t unit_svc_load(unit_t *unit, ini_configuration_t *ini_conf,
    6162    text_parse_t *text_parse)
    6263{
     
    7677}
    7778
    78 static int unit_svc_start(unit_t *unit)
     79static errno_t unit_svc_start(unit_t *unit)
    7980{
    8081        unit_svc_t *u_svc = CAST_SVC(unit);
     
    8485        assert(unit->state == STATE_STOPPED);
    8586
    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,
    8788            u_svc->exec_start.argv);
    8889
     
    100101         */
    101102        if (str_cmp(unit->name, "devman.svc") == 0) {
    102                 async_usleep(100000);
     103                fibril_usleep(100000);
    103104                if (console_kcon()) {
    104105                        sysman_log(LVL_DEBUG2, "%s: Kconsole grabbed.", __func__);
     
    111112}
    112113
    113 static int unit_svc_stop(unit_t *unit)
     114static errno_t unit_svc_stop(unit_t *unit)
    114115{
    115116        unit_svc_t *u_svc = CAST_SVC(unit);
     
    129130        }
    130131
    131         int rc = task_kill(u_svc->main_task_id);
     132        errno_t rc = task_kill(u_svc->main_task_id);
    132133
    133134        if (rc != EOK) {
  • uspace/srv/taskman/event.c

    rf92b315 r241f1985  
    4949        task_id_t id;         /**< Task ID who we wait for. */
    5050        task_id_t waiter_id;  /**< Task ID who waits. */
    51         ipc_callid_t callid;  /**< Call ID waiting for the event. */
     51        ipc_call_t *icall;  /**< Call ID waiting for the event. */
    5252        int flags;            /**< Wait flags. */
    5353} pending_wait_t;
     
    5959static FIBRIL_RWLOCK_INITIALIZE(listeners_lock);
    6060
    61 int event_init(void)
     61errno_t event_init(void)
    6262{
    6363        list_initialize(&pending_waits);
     
    150150                int match = notify_flags & pr->flags;
    151151                // 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);
    153153
    154154                if (match == 0) {
     
    156156                                /* Nothing to wait for anymore */
    157157                                if (answer) {
    158                                         async_answer_0(pr->callid, EINTR);
     158                                        async_answer_0(pr->icall, EINTR);
    159159                                }
    160160                        } else {
     
    165165                        if ((pr->flags & TASK_WAIT_BOTH) && match == TASK_WAIT_EXIT) {
    166166                                /* 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);
    168168                        } else {
    169169                                /* Send both exit status and retval, caller
    170170                                 * should know what is valid */
    171                                 async_answer_3(pr->callid, EOK, t->exit,
     171                                async_answer_3(pr->icall, EOK, t->exit,
    172172                                    t->retval, rest);
    173173                        }
     
    195195
    196196void event_register_listener(task_id_t id, bool past_events, async_sess_t *sess,
    197     ipc_callid_t iid)
    198 {
    199         int rc = EOK;
     197    ipc_call_t *icall)
     198{
     199        errno_t rc = EOK;
    200200        /*
    201201         * We have lock of tasks structures so that we can guarantee
     
    219219         * while we dump events.
    220220         */
    221         async_answer_0(iid, rc);
     221        async_answer_0(icall, rc);
    222222        if (past_events) {
    223223                task_foreach(&dump_walker, t->sess);
     
    228228        fibril_rwlock_write_unlock(&task_hash_table_lock);
    229229        if (rc != EOK) {
    230                 async_answer_0(iid, rc);
    231         }
    232 }
    233 
    234 void wait_for_task(task_id_t id, int flags, ipc_callid_t callid,
     230                async_answer_0(icall, rc);
     231        }
     232}
     233
     234void wait_for_task(task_id_t id, int flags, ipc_call_t *icall,
    235235     task_id_t waiter_id)
    236236{
     
    244244        if (t == NULL) {
    245245                /* No such task exists. */
    246                 async_answer_0(callid, ENOENT);
     246                async_answer_0(icall, ENOENT);
    247247                return;
    248248        }
     
    250250        if (t->exit != TASK_EXIT_RUNNING) {
    251251                //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);
    253253                return;
    254254        }
     
    267267        }
    268268
    269         int rc = EOK;
     269        errno_t rc = EOK;
    270270        if (pr == NULL) {
    271271                pr = malloc(sizeof(pending_wait_t));
     
    279279                pr->waiter_id = waiter_id;
    280280                pr->flags = flags;
    281                 pr->callid = callid;
     281                pr->icall = icall;
    282282
    283283                list_append(&pr->link, &pending_waits);
     
    288288                 * fibril).
    289289                 */
    290                 rc = EEXISTS;
     290                rc = EEXIST;
    291291        } else {
    292292                /*
     
    294294                 */
    295295                pr->flags &= ~TASK_WAIT_BOTH; // TODO maybe new flags should be set?
    296                 pr->callid = callid;
     296                pr->icall = icall;
    297297        }
    298298
     
    300300        fibril_rwlock_write_unlock(&pending_wait_lock);
    301301        // 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
     308errno_t task_set_retval(task_id_t sender, int retval, bool wait_for_exit)
     309{
     310        errno_t rc = EOK;
    311311       
    312312        fibril_rwlock_write_lock(&task_hash_table_lock);
  • uspace/srv/taskman/event.h

    rf92b315 r241f1985  
    3939#include <abi/proc/task.h>
    4040
    41 extern int event_init(void);
     41extern errno_t event_init(void);
    4242
    4343extern void event_register_listener(task_id_t, bool, async_sess_t *,
    44     ipc_callid_t);
    45 extern void dump_events(task_id_t, ipc_callid_t);
    46 extern void wait_for_task(task_id_t, int, ipc_callid_t, task_id_t);
    47 extern int task_set_retval(task_id_t, int, bool);
     44    ipc_call_t *);
     45extern void dump_events(task_id_t, ipc_call_t *);
     46extern void wait_for_task(task_id_t, int, ipc_call_t *, task_id_t);
     47extern errno_t task_set_retval(task_id_t, int, bool);
    4848
    4949extern void task_terminated(task_id_t, exit_reason_t);
  • uspace/srv/taskman/main.c

    rf92b315 r241f1985  
    7171 * Static functions
    7272 */
    73 static void connect_to_loader(ipc_callid_t iid, ipc_call_t *icall)
    74 {
    75         DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->in_task_id);
     73static void connect_to_loader(ipc_call_t *icall)
     74{
     75        DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->task_id);
    7676        /* We don't accept the connection request, we forward it instead to
    7777         * freshly spawned loader. */
    78         int rc = loader_spawn("loader");
    79        
    80         if (rc != EOK) {
    81                 async_answer_0(iid, rc);
     78        errno_t rc = loader_spawn("loader");
     79       
     80        if (rc != EOK) {
     81                async_answer_0(icall, rc);
    8282                return;
    8383        }
     
    8989        /* Forward the connection request (strip interface arg). */
    9090        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);
    9595        async_exchange_end(exch);
    9696
     
    100100
    101101        if (rc != EOK) {
    102                 async_answer_0(iid, rc);
     102                async_answer_0(icall, rc);
    103103                return;
    104104        }
     
    107107}
    108108
    109 static void connect_to_ns(ipc_callid_t iid, ipc_call_t *icall)
    110 {
    111         DPRINTF("%s, %llu\n", __func__, icall->in_task_id);
     109static void connect_to_ns(ipc_call_t *icall)
     110{
     111        DPRINTF("%s, %llu\n", __func__, icall->task_id);
    112112
    113113        /* Wait until we know NS */
     
    120120        /* Do not accept connection, forward it */
    121121        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);
    123123        async_exchange_end(exch);
    124124
    125125        if (rc != EOK) {
    126                 async_answer_0(iid, rc);
    127                 return;
    128         }
    129 }
    130 
    131 static void taskman_new_task(ipc_callid_t iid, ipc_call_t *icall)
    132 {
    133         int rc = task_intro(icall->in_task_id);
    134         async_answer_0(iid, rc);
    135 }
    136 
    137 static void taskman_i_am_ns(ipc_callid_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
     131static 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
     137static void taskman_i_am_ns(ipc_call_t *icall)
     138{
     139        DPRINTF("%s, %llu\n", __func__, icall->task_id);
     140        errno_t rc = EOK;
    141141
    142142        fibril_mutex_lock(&session_ns_mtx);
    143143        if (session_ns != NULL) {
    144                 rc = EEXISTS;
     144                rc = EEXIST;
    145145                goto finish;
    146146        }
     
    157157finish:
    158158        fibril_mutex_unlock(&session_ns_mtx);
    159         async_answer_0(iid, rc);
    160 }
    161 
    162 static void taskman_ctl_wait(ipc_callid_t iid, ipc_call_t *icall)
     159        async_answer_0(icall, rc);
     160}
     161
     162static void taskman_ctl_wait(ipc_call_t *icall)
    163163{
    164164        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, iid, waiter_id);
    170 }
    171 
    172 static void taskman_ctl_retval(ipc_callid_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
     172static 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);
    177177
    178178        DPRINTF("%s:%i from %llu/%i\n", __func__, __LINE__, sender, retval);
    179179
    180         int rc = task_set_retval(sender, retval, wait_for_exit);
    181         async_answer_0(iid, rc);
    182 }
    183 
    184 static void taskman_ctl_ev_callback(ipc_callid_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
     184static 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);
    189189
    190190        /* Atomic -- will be used for notifications only */
    191191        async_sess_t *sess = async_callback_receive(EXCHANGE_ATOMIC);
    192192        if (sess == NULL) {
    193                 async_answer_0(iid, 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_callid_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
     200static 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);
    204204        DPRINTF("%s:%i from %llu/%i\n", __func__, __LINE__, id, exit_reason);
    205205        task_terminated(id, exit_reason);
    206206}
    207207
    208 static void task_fault_event(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    209 {
    210         task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));
     208static 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));
    211211        DPRINTF("%s:%i from %llu\n", __func__, __LINE__, id);
    212212        task_failed(id);
    213213}
    214214
    215 static void loader_callback(ipc_callid_t iid, ipc_call_t *icall)
    216 {
    217         DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->in_task_id);
     215static void loader_callback(ipc_call_t *icall)
     216{
     217        DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->task_id);
    218218        // TODO check that loader is expected, would probably discard prodcons
    219219        //      scheme
     
    222222        sess_ref_t *sess_ref = malloc(sizeof(sess_ref_t));
    223223        if (sess_ref == NULL) {
    224                 async_answer_0(iid, ENOMEM);
     224                async_answer_0(icall, ENOMEM);
    225225        }
    226226
     
    228228        sess_ref->sess = async_callback_receive_start(EXCHANGE_ATOMIC, icall);
    229229        if (sess_ref->sess == NULL) {
    230                 async_answer_0(iid, EINVAL);
    231                 return;
    232         }
    233 
    234         async_answer_0(iid, EOK);
     230                async_answer_0(icall, EINVAL);
     231                return;
     232        }
     233
     234        async_answer_0(icall, EOK);
    235235
    236236        /* Notify spawners */
     
    239239}
    240240
    241 static bool handle_call(ipc_callid_t iid, ipc_call_t *icall)
    242 {
    243         switch (IPC_GET_IMETHOD(*icall)) {
     241static bool handle_call(ipc_call_t *icall)
     242{
     243        switch (ipc_get_imethod(icall)) {
    244244        case TASKMAN_NEW_TASK:
    245                 taskman_new_task(iid, icall);
     245                taskman_new_task(icall);
    246246                break;
    247247        case TASKMAN_I_AM_NS:
    248                 taskman_i_am_ns(iid, icall);
     248                taskman_i_am_ns(icall);
    249249                break;
    250250        case TASKMAN_WAIT:
    251                 taskman_ctl_wait(iid, icall);
     251                taskman_ctl_wait(icall);
    252252                break;
    253253        case TASKMAN_RETVAL:
    254                 taskman_ctl_retval(iid, icall);
     254                taskman_ctl_retval(icall);
    255255                break;
    256256        case TASKMAN_EVENT_CALLBACK:
    257                 taskman_ctl_ev_callback(iid, icall);
     257                taskman_ctl_ev_callback(icall);
    258258                break;
    259259        default:
     
    263263}
    264264
    265 static bool handle_implicit_call(ipc_callid_t iid, ipc_call_t *icall)
     265static bool handle_implicit_call(ipc_call_t *icall)
    266266{
    267267        /*DPRINTF("%s:%i %i(%i) from %llu\n", __func__, __LINE__,
     
    270270            icall->in_task_id);*/
    271271
    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)) {
    274274                case TASKMAN_CONNECT_TO_NS:
    275                         connect_to_ns(iid, icall);
     275                        connect_to_ns(icall);
    276276                        break;
    277277                case TASKMAN_CONNECT_TO_LOADER:
    278                         connect_to_loader(iid, icall);
     278                        connect_to_loader(icall);
    279279                        break;
    280280                case TASKMAN_LOADER_CALLBACK:
    281                         loader_callback(iid, icall);
     281                        loader_callback(icall);
    282282                        break;
    283283                default:
     
    286286                }
    287287        } else {
    288                 return handle_call(iid, icall);
     288                return handle_call(icall);
    289289        }
    290290
     
    292292}
    293293
    294 static void implicit_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    295 {
    296         if (!handle_implicit_call(iid, icall)) {
    297                 async_answer_0(iid, ENOTSUP);
     294static void implicit_connection(ipc_call_t *icall, void *arg)
     295{
     296        if (!handle_implicit_call(icall)) {
     297                async_answer_0(icall, ENOTSUP);
    298298                return;
    299299        }
     
    301301        while (true) {
    302302                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)) {
    306305                        /* Client disconnected */
    307306                        break;
    308307                }
    309308
    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);
    312311                        break;
    313312                }
     
    315314}
    316315
    317 static void taskman_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     316static void taskman_connection(ipc_call_t *icall, void *arg)
    318317{
    319318        /*
     
    324323         * "listening" on such connections.
    325324         */
    326         if (!handle_implicit_call(iid, icall)) {
    327                 /* If cannot handle connection requst, give up trying */
    328                 async_answer_0(iid, EHANGUP);
     325        if (!handle_implicit_call(icall)) {
     326                /* If cannot handle connection request, give up trying */
     327                async_answer_0(icall, EHANGUP);
    329328                return;
    330329        }
     
    339338        /* Initialization */
    340339        prodcons_initialize(&sess_queue);
    341         int rc = tasks_init();
     340        errno_t rc = tasks_init();
    342341        if (rc != EOK) {
    343342                return rc;
     
    368367        /* Start sysman server */
    369368        async_set_implicit_connection(implicit_connection);
    370         async_set_client_connection(taskman_connection);
     369        async_set_fallback_port_handler(taskman_connection, NULL);
    371370
    372371        printf(NAME ": Accepting connections\n");
  • uspace/srv/taskman/task.c

    rf92b315 r241f1985  
    5757 */
    5858
    59 static size_t ht_task_key_hash(void *key)
     59static size_t ht_task_key_hash(const void *key)
    6060{
    6161        return *(task_id_t*)key;
     
    6868}
    6969
    70 static bool ht_task_key_equal(void *key, const ht_link_t *item)
     70static bool ht_task_key_equal(const void *key, const ht_link_t *item)
    7171{
    7272        task_t *ht = hash_table_get_inst(item, task_t, link);
     
    199199        task_t *t = task_get_by_id(id);
    200200        if (t != NULL) {
    201                 rc = EEXISTS;
     201                rc = EEXIST;
    202202                goto finish;
    203203        }
  • uspace/srv/vfs/Makefile

    rf92b315 r241f1985  
    2929
    3030USPACE_PREFIX = ../..
    31 LIBS = $(LIBSYSMAN_PREFIX)/libsysman.a
    32 EXTRA_CFLAGS += -I$(LIBSYSMAN_PREFIX)/include
     31LIBS = sysman
     32EXTRA_CFLAGS += -I$(USPACE_PREFIX)/lib/sysman/include
    3333BINARY = vfs
    3434STATIC_NEEDED = y
  • uspace/srv/vfs/vfs.c

    rf92b315 r241f1985  
    4343#include <as.h>
    4444#include <async.h>
    45 #include <atomic.h>
     45#include <stdatomic.h>
    4646#include <errno.h>
    4747#include <str_error.h>
  • uspace/srv/vfs/vfs.h

    rf92b315 r241f1985  
    178178extern fs_handle_t fs_name_to_handle(const char *, unsigned int instance, bool);
    179179extern vfs_info_t *fs_handle_to_info(fs_handle_t);
     180extern int vfs_get_fstypes(vfs_fstypes_t *);
    180181extern errno_t fs_unit_name(const char *, unsigned int, char **);
    181182
  • uspace/srv/vfs/vfs_ops.c

    rf92b315 r241f1985  
    5050#include <assert.h>
    5151#include <vfs/canonify.h>
     52#include <sysman/ctl.h>
    5253
    5354/* Forward declarations of static functions. */
    5455static errno_t vfs_truncate_internal(fs_handle_t, service_id_t, fs_index_t,
    5556    aoff64_t);
     57
     58static errno_t vfs_fs_request_start(const char *fs_name, unsigned int instance);
    5659
    5760/**
     
    144147                                 */
    145148                                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);
    147150                                fibril_mutex_lock(&fs_list_lock);
    148151
    149152                                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;
    157154                                }
     155
    158156                                /*
    159157                                 * Succesful start request, new server should be
     
    216214}
    217215
    218 static int vfs_fs_request_start(const char *fs_name, unsigned int instance)
     216static errno_t vfs_fs_request_start(const char *fs_name, unsigned int instance)
    219217{
    220218        char *unit_name = NULL;
  • uspace/srv/vfs/vfs_register.c

    rf92b315 r241f1985  
    4040#include <assert.h>
    4141#include <async.h>
    42 #include <atomic.h>
     42#include <stdatomic.h>
    4343#include <ctype.h>
    4444#include <errno.h>
     
    169169                fibril_mutex_unlock(&fs_list_lock);
    170170                free(fs_info);
    171                 async_answer_0(rid, rc);
    172                 return;
    173         }
    174         sysman_main_exposee_added(unit_name, request->in_task_id);
     171                async_answer_0(req, rc);
     172                return;
     173        }
     174        sysman_main_exposee_added(unit_name, req->task_id);
    175175        free(unit_name);
    176176       
Note: See TracChangeset for help on using the changeset viewer.