Changeset 234e39e in mainline for uspace/srv/bd/file_bd/file_bd.c


Ignore:
Timestamp:
2010-01-09T22:12:40Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c4702798
Parents:
40d4c1d (diff), 9245413 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mkfile and mkfat.

File:
1 edited

Legend:

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

    r40d4c1d r234e39e  
    5656
    5757static const size_t block_size = 512;
     58static bn_t num_blocks;
    5859static FILE *img;
    5960
     
    99100{
    100101        int rc;
     102        long img_size;
    101103
    102104        rc = devmap_driver_register(NAME, file_bd_connection);
     
    109111        if (img == NULL)
    110112                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;
    111126
    112127        fibril_mutex_initialize(&dev_lock);
     
    174189                        ipc_answer_1(callid, EOK, block_size);
    175190                        continue;
     191                case BD_GET_NUM_BLOCKS:
     192                        ipc_answer_2(callid, EOK, LOWER32(num_blocks),
     193                            UPPER32(num_blocks));
     194                        continue;
    176195                default:
    177196                        retval = EINVAL;
     
    213232
    214233        fseek(img, ba * block_size, SEEK_SET);
    215         n_wr = fread(buf, block_size, cnt, img);
     234        n_wr = fwrite(buf, block_size, cnt, img);
    216235
    217236        if (ferror(img) || n_wr < cnt) {
Note: See TracChangeset for help on using the changeset viewer.