Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/loader.c

    rd96d9bc rb7fd2a0  
    5252 * @param name Symbolic name to set on the newly created task.
    5353 *
    54  * @return Pointer to the loader connection structure (should be
    55  *         deallocated using free() after use).
    56  *
    57  */
    58 int loader_spawn(const char *name)
    59 {
    60         return __SYSCALL2(SYS_PROGRAM_SPAWN_LOADER,
     54 * @return Error code.
     55 */
     56errno_t loader_spawn(const char *name)
     57{
     58        return (errno_t) __SYSCALL2(SYS_PROGRAM_SPAWN_LOADER,
    6159            (sysarg_t) name, str_size(name));
    6260}
     
    8684 * @param task_id Points to a variable where the ID should be stored.
    8785 *
    88  * @return Zero on success or negative error code.
    89  *
    90  */
    91 int loader_get_task_id(loader_t *ldr, task_id_t *task_id)
     86 * @return Zero on success or an error code.
     87 *
     88 */
     89errno_t loader_get_task_id(loader_t *ldr, task_id_t *task_id)
    9290{
    9391        /* Get task ID. */
     
    9694        ipc_call_t answer;
    9795        aid_t req = async_send_0(exch, LOADER_GET_TASKID, &answer);
    98         sysarg_t rc = async_data_read_start(exch, task_id, sizeof(task_id_t));
    99        
    100         async_exchange_end(exch);
    101        
    102         if (rc != EOK) {
    103                 async_forget(req);
    104                 return (int) rc;
     96        errno_t rc = async_data_read_start(exch, task_id, sizeof(task_id_t));
     97       
     98        async_exchange_end(exch);
     99       
     100        if (rc != EOK) {
     101                async_forget(req);
     102                return (errno_t) rc;
    105103        }
    106104       
    107105        async_wait_for(req, &rc);
    108         return (int) rc;
     106        return (errno_t) rc;
    109107}
    110108
     
    115113 * @param ldr  Loader connection structure.
    116114 *
    117  * @return Zero on success or negative error code.
    118  *
    119  */
    120 int loader_set_cwd(loader_t *ldr)
     115 * @return Zero on success or an error code.
     116 *
     117 */
     118errno_t loader_set_cwd(loader_t *ldr)
    121119{
    122120        char *cwd = (char *) malloc(MAX_PATH_LEN + 1);
     
    133131        ipc_call_t answer;
    134132        aid_t req = async_send_0(exch, LOADER_SET_CWD, &answer);
    135         sysarg_t rc = async_data_write_start(exch, cwd, len);
     133        errno_t rc = async_data_write_start(exch, cwd, len);
    136134       
    137135        async_exchange_end(exch);
     
    140138        if (rc != EOK) {
    141139                async_forget(req);
    142                 return (int) rc;
     140                return (errno_t) rc;
    143141        }
    144142       
    145143        async_wait_for(req, &rc);
    146         return (int) rc;
     144        return (errno_t) rc;
    147145}
    148146
     
    153151 * @param file Program file.
    154152 *
    155  * @return Zero on success or negative error code.
    156  *
    157  */
    158 int loader_set_program(loader_t *ldr, const char *name, int file)
     153 * @return Zero on success or an error code.
     154 *
     155 */
     156errno_t loader_set_program(loader_t *ldr, const char *name, int file)
    159157{
    160158        async_exch_t *exch = async_exchange_begin(ldr->sess);
     
    163161        aid_t req = async_send_0(exch, LOADER_SET_PROGRAM, &answer);
    164162
    165         sysarg_t rc = async_data_write_start(exch, name, str_size(name) + 1);
     163        errno_t rc = async_data_write_start(exch, name, str_size(name) + 1);
    166164        if (rc == EOK) {
    167165                async_exch_t *vfs_exch = vfs_exchange_begin();
     
    174172        if (rc != EOK) {
    175173                async_forget(req);
    176                 return (int) rc;
     174                return (errno_t) rc;
    177175        }
    178176
    179177        async_wait_for(req, &rc);
    180         return (int) rc;
     178        return (errno_t) rc;
    181179}
    182180
     
    186184 * @param path Program path.
    187185 *
    188  * @return Zero on success or negative error code.
    189  *
    190  */
    191 int loader_set_program_path(loader_t *ldr, const char *path)
     186 * @return Zero on success or an error code.
     187 *
     188 */
     189errno_t loader_set_program_path(loader_t *ldr, const char *path)
    192190{
    193191        const char *name = str_rchr(path, '/');
     
    198196        }
    199197       
    200         int fd = vfs_lookup(path, 0);
    201         if (fd < 0) {
    202                 return fd;
    203         }
    204        
    205         int rc = loader_set_program(ldr, name, fd);
     198        int fd;
     199        errno_t rc = vfs_lookup(path, 0, &fd);
     200        if (rc != EOK) {
     201                return rc;
     202        }
     203       
     204        rc = loader_set_program(ldr, name, fd);
    206205        vfs_put(fd);
    207206        return rc;
     
    218217 * @param argv NULL-terminated array of pointers to arguments.
    219218 *
    220  * @return Zero on success or negative error code.
    221  *
    222  */
    223 int loader_set_args(loader_t *ldr, const char *const argv[])
     219 * @return Zero on success or an error code.
     220 *
     221 */
     222errno_t loader_set_args(loader_t *ldr, const char *const argv[])
    224223{
    225224        /*
     
    253252        ipc_call_t answer;
    254253        aid_t req = async_send_0(exch, LOADER_SET_ARGS, &answer);
    255         sysarg_t rc = async_data_write_start(exch, (void *) arg_buf,
     254        errno_t rc = async_data_write_start(exch, (void *) arg_buf,
    256255            buffer_size);
    257256       
     
    261260        if (rc != EOK) {
    262261                async_forget(req);
    263                 return (int) rc;
     262                return (errno_t) rc;
    264263        }
    265264       
    266265        async_wait_for(req, &rc);
    267         return (int) rc;
     266        return (errno_t) rc;
    268267}
    269268
     
    274273 * @param file       The file's descriptor.
    275274 *
    276  * @return Zero on success or negative error code.
    277  *
    278  */
    279 int loader_add_inbox(loader_t *ldr, const char *name, int file)
     275 * @return Zero on success or an error code.
     276 *
     277 */
     278errno_t loader_add_inbox(loader_t *ldr, const char *name, int file)
    280279{
    281280        async_exch_t *exch = async_exchange_begin(ldr->sess);
     
    284283        aid_t req = async_send_0(exch, LOADER_ADD_INBOX, NULL);
    285284       
    286         sysarg_t rc = async_data_write_start(exch, name, str_size(name) + 1);
     285        errno_t rc = async_data_write_start(exch, name, str_size(name) + 1);
    287286        if (rc == EOK) {
    288287                rc = vfs_pass_handle(vfs_exch, file, exch);
     
    298297        }
    299298       
    300         return (int) rc;
     299        return (errno_t) rc;
    301300}
    302301
     
    308307 * @param ldr Loader connection structure.
    309308 *
    310  * @return Zero on success or negative error code.
    311  *
    312  */
    313 int loader_load_program(loader_t *ldr)
    314 {
    315         async_exch_t *exch = async_exchange_begin(ldr->sess);
    316         int rc = async_req_0_0(exch, LOADER_LOAD);
     309 * @return Zero on success or an error code.
     310 *
     311 */
     312errno_t loader_load_program(loader_t *ldr)
     313{
     314        async_exch_t *exch = async_exchange_begin(ldr->sess);
     315        errno_t rc = async_req_0_0(exch, LOADER_LOAD);
    317316        async_exchange_end(exch);
    318317       
     
    331330 * @param ldr Loader connection structure.
    332331 *
    333  * @return Zero on success or negative error code.
    334  *
    335  */
    336 int loader_run(loader_t *ldr)
    337 {
    338         async_exch_t *exch = async_exchange_begin(ldr->sess);
    339         int rc = async_req_0_0(exch, LOADER_RUN);
     332 * @return Zero on success or an error code.
     333 *
     334 */
     335errno_t loader_run(loader_t *ldr)
     336{
     337        async_exch_t *exch = async_exchange_begin(ldr->sess);
     338        errno_t rc = async_req_0_0(exch, LOADER_RUN);
    340339        async_exchange_end(exch);
    341340       
     
    357356 * @param ldr Loader connection structure.
    358357 *
    359  * @return Zero on success or negative error code.
     358 * @return Zero on success or an error code.
    360359 *
    361360 */
Note: See TracChangeset for help on using the changeset viewer.