Changeset 08232ee in mainline for uspace/lib/libblock/libblock.c


Ignore:
Timestamp:
2010-01-09T21:52:07Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9245413
Parents:
dccf721
Message:

Obtain block device size automatically, if possible. Implement ftell(). Fix seek implementation in VFS if whence == SEEK_END.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libblock/libblock.c

    rdccf721 r08232ee  
    8787static int write_blocks(devcon_t *devcon, bn_t ba, size_t cnt);
    8888static int get_block_size(int dev_phone, size_t *bsize);
     89static int get_num_blocks(int dev_phone, bn_t *nblocks);
    8990
    9091static devcon_t *devcon_search(dev_handle_t dev_handle)
     
    738739}
    739740
     741/** Get number of blocks on device.
     742 *
     743 * @param dev_handle    Device handle of the block device.
     744 * @param nblocks       Output number of blocks.
     745 *
     746 * @return              EOK on success or negative error code on failure.
     747 */
     748int block_get_nblocks(dev_handle_t dev_handle, bn_t *nblocks)
     749{
     750        devcon_t *devcon;
     751
     752        devcon = devcon_search(dev_handle);
     753        assert(devcon);
     754       
     755        return get_num_blocks(devcon->dev_phone, nblocks);
     756}
     757
    740758/** Read blocks from block device.
    741759 *
     
    789807}
    790808
     809/** Get total number of blocks on block device. */
     810static int get_num_blocks(int dev_phone, bn_t *nblocks)
     811{
     812        ipcarg_t nb_l, nb_h;
     813        int rc;
     814
     815        rc = async_req_0_2(dev_phone, BD_GET_NUM_BLOCKS, &nb_l, &nb_h);
     816        if (rc == EOK) {
     817                *nblocks = (bn_t) MERGE_LOUP32(nb_l, nb_h);
     818        }
     819
     820        return rc;
     821}
     822
    791823/** @}
    792824 */
Note: See TracChangeset for help on using the changeset viewer.