Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/loader/main.c

    rbfdb5af1 r27b76ca  
    6161#include <elf/elf.h>
    6262#include <elf/elf_load.h>
     63#include <vfs/vfs.h>
    6364
    6465#ifdef CONFIG_RTLD
     
    8990
    9091/** Number of preset files */
    91 static int filc = 0;
    92 /** Preset files vector */
    93 static fdi_node_t **filv = NULL;
    94 /** Buffer holding all preset files */
    95 static fdi_node_t *fil_buf = NULL;
     92static unsigned int filc = 0;
    9693
    9794static elf_info_t prog_info;
     
    239236static void ldr_set_files(ipc_callid_t rid, ipc_call_t *request)
    240237{
    241         fdi_node_t *buf;
    242         size_t buf_size;
    243         int rc = async_data_write_accept((void **) &buf, false, 0, 0,
    244             sizeof(fdi_node_t), &buf_size);
    245        
    246         if (rc == EOK) {
    247                 int count = buf_size / sizeof(fdi_node_t);
    248                
    249                 /*
    250                  * Allocate new filv
    251                  */
    252                 fdi_node_t **_filv = (fdi_node_t **) calloc(count + 1, sizeof(fdi_node_t *));
    253                 if (_filv == NULL) {
    254                         free(buf);
    255                         async_answer_0(rid, ENOMEM);
    256                         return;
     238        size_t count = IPC_GET_ARG1(*request);
     239
     240        async_exch_t *vfs_exch = vfs_exchange_begin();
     241
     242        for (filc = 0; filc < count; filc++) {
     243                ipc_callid_t callid;
     244                int fd;
     245
     246                if (!async_state_change_receive(&callid, NULL, NULL, NULL)) {
     247                        async_answer_0(callid, EINVAL);
     248                        break;
    257249                }
    258                
    259                 /*
    260                  * Fill the new filv with argument pointers
    261                  */
    262                 int i;
    263                 for (i = 0; i < count; i++)
    264                         _filv[i] = &buf[i];
    265                
    266                 _filv[count] = NULL;
    267                
    268                 /*
    269                  * Copy temporary data to global variables
    270                  */
    271                 if (fil_buf != NULL)
    272                         free(fil_buf);
    273                
    274                 if (filv != NULL)
    275                         free(filv);
    276                
    277                 filc = count;
    278                 fil_buf = buf;
    279                 filv = _filv;
    280         }
    281        
     250                async_state_change_finalize(callid, vfs_exch);
     251                fd = fd_wait();
     252                assert(fd == (int) filc);
     253        }
     254
     255        vfs_exchange_end(vfs_exch);
     256
    282257        async_answer_0(rid, EOK);
    283258}
     
    308283       
    309284        pcb.filc = filc;
    310         pcb.filv = filv;
    311285       
    312286        if (prog_info.interp == NULL) {
Note: See TracChangeset for help on using the changeset viewer.