Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/file_bd/file_bd.c

    r08232ee r1e4cada  
    5656
    5757static const size_t block_size = 512;
    58 static bn_t num_blocks;
    5958static FILE *img;
    6059
     
    10099{
    101100        int rc;
    102         long img_size;
    103101
    104102        rc = devmap_driver_register(NAME, file_bd_connection);
     
    111109        if (img == NULL)
    112110                return EINVAL;
    113 
    114         if (fseek(img, 0, SEEK_END) != 0) {
    115                 fclose(img);
    116                 return EIO;
    117         }
    118 
    119         img_size = ftell(img);
    120         if (img_size < 0) {
    121                 fclose(img);
    122                 return EIO;
    123         }
    124 
    125         num_blocks = img_size / block_size;
    126111
    127112        fibril_mutex_initialize(&dev_lock);
     
    189174                        ipc_answer_1(callid, EOK, block_size);
    190175                        continue;
    191                 case BD_GET_NUM_BLOCKS:
    192                         ipc_answer_2(callid, EOK, LOWER32(num_blocks),
    193                             UPPER32(num_blocks));
    194                         continue;
    195176                default:
    196177                        retval = EINVAL;
     
    232213
    233214        fseek(img, ba * block_size, SEEK_SET);
    234         n_wr = fwrite(buf, block_size, cnt, img);
     215        n_wr = fread(buf, block_size, cnt, img);
    235216
    236217        if (ferror(img) || n_wr < cnt) {
Note: See TracChangeset for help on using the changeset viewer.