Ignore:
File:
1 edited

Legend:

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

    r38d150e rb7fd2a0  
    5252#include <stdio.h>
    5353#include <stacktrace.h>
     54#include <str_error.h>
    5455#include <offset.h>
    5556#include <inttypes.h>
     
    8788} devcon_t;
    8889
    89 static int read_blocks(devcon_t *, aoff64_t, size_t, void *, size_t);
    90 static int write_blocks(devcon_t *, aoff64_t, size_t, void *, size_t);
     90static errno_t read_blocks(devcon_t *, aoff64_t, size_t, void *, size_t);
     91static errno_t write_blocks(devcon_t *, aoff64_t, size_t, void *, size_t);
    9192static aoff64_t ba_ltop(devcon_t *, aoff64_t);
    9293
     
    106107}
    107108
    108 static int devcon_add(service_id_t service_id, async_sess_t *sess,
     109static errno_t devcon_add(service_id_t service_id, async_sess_t *sess,
    109110    size_t bsize, aoff64_t dev_size, bd_t *bd)
    110111{
     
    145146}
    146147
    147 int block_init(service_id_t service_id, size_t comm_size)
     148errno_t block_init(service_id_t service_id, size_t comm_size)
    148149{
    149150        bd_t *bd;
     
    155156        }
    156157       
    157         int rc = bd_open(sess, &bd);
     158        errno_t rc = bd_open(sess, &bd);
    158159        if (rc != EOK) {
    159160                async_hangup(sess);
     
    208209}
    209210
    210 int block_bb_read(service_id_t service_id, aoff64_t ba)
     211errno_t block_bb_read(service_id_t service_id, aoff64_t ba)
    211212{
    212213        void *bb_buf;
    213         int rc;
     214        errno_t rc;
    214215
    215216        devcon_t *devcon = devcon_search(service_id);
     
    269270};
    270271
    271 int block_cache_init(service_id_t service_id, size_t size, unsigned blocks,
     272errno_t block_cache_init(service_id_t service_id, size_t size, unsigned blocks,
    272273    enum cache_mode mode)
    273274{
     
    306307}
    307308
    308 int block_cache_fini(service_id_t service_id)
     309errno_t block_cache_fini(service_id_t service_id)
    309310{
    310311        devcon_t *devcon = devcon_search(service_id);
    311312        cache_t *cache;
    312         int rc;
     313        errno_t rc;
    313314
    314315        if (!devcon)
     
    380381 *                              device.
    381382 *
    382  * @return                      EOK on success or a negative error code.
    383  */
    384 int block_get(block_t **block, service_id_t service_id, aoff64_t ba, int flags)
     383 * @return                      EOK on success or an error code.
     384 */
     385errno_t block_get(block_t **block, service_id_t service_id, aoff64_t ba, int flags)
    385386{
    386387        devcon_t *devcon;
     
    389390        link_t *link;
    390391        aoff64_t p_ba;
    391         int rc;
     392        errno_t rc;
    392393       
    393394        devcon = devcon_search(service_id);
     
    577578 * @param block         Block of which a reference is to be released.
    578579 *
    579  * @return              EOK on success or a negative error code.
    580  */
    581 int block_put(block_t *block)
     580 * @return              EOK on success or an error code.
     581 */
     582errno_t block_put(block_t *block)
    582583{
    583584        devcon_t *devcon = devcon_search(block->service_id);
     
    585586        unsigned blocks_cached;
    586587        enum cache_mode mode;
    587         int rc = EOK;
     588        errno_t rc = EOK;
    588589
    589590        assert(devcon);
     
    698699 * @param block_size    Block size to be used for the transfer.
    699700 *
    700  * @return              EOK on success or a negative return code on failure.
    701  */
    702 int block_seqread(service_id_t service_id, void *buf, size_t *bufpos,
     701 * @return              EOK on success or an error code on failure.
     702 */
     703errno_t block_seqread(service_id_t service_id, void *buf, size_t *bufpos,
    703704    size_t *buflen, aoff64_t *pos, void *dst, size_t size)
    704705{
     
    734735                if (*bufpos == *buflen) {
    735736                        /* Refill the communication buffer with a new block. */
    736                         int rc;
     737                        errno_t rc;
    737738
    738739                        rc = read_blocks(devcon, *pos / block_size, 1, buf,
     
    757758 * @param src           Buffer for storing the data.
    758759 *
    759  * @return              EOK on success or negative error code on failure.
    760  */
    761 int block_read_direct(service_id_t service_id, aoff64_t ba, size_t cnt, void *buf)
     760 * @return              EOK on success or an error code on failure.
     761 */
     762errno_t block_read_direct(service_id_t service_id, aoff64_t ba, size_t cnt, void *buf)
    762763{
    763764        devcon_t *devcon;
     
    776777 * @param src           The data to be written.
    777778 *
    778  * @return              EOK on success or negative error code on failure.
    779  */
    780 int block_write_direct(service_id_t service_id, aoff64_t ba, size_t cnt,
     779 * @return              EOK on success or an error code on failure.
     780 */
     781errno_t block_write_direct(service_id_t service_id, aoff64_t ba, size_t cnt,
    781782    const void *data)
    782783{
     
    795796 * @param cnt           Number of blocks.
    796797 *
    797  * @return              EOK on success or negative error code on failure.
    798  */
    799 int block_sync_cache(service_id_t service_id, aoff64_t ba, size_t cnt)
     798 * @return              EOK on success or an error code on failure.
     799 */
     800errno_t block_sync_cache(service_id_t service_id, aoff64_t ba, size_t cnt)
    800801{
    801802        devcon_t *devcon;
     
    812813 * @param bsize         Output block size.
    813814 *
    814  * @return              EOK on success or negative error code on failure.
    815  */
    816 int block_get_bsize(service_id_t service_id, size_t *bsize)
     815 * @return              EOK on success or an error code on failure.
     816 */
     817errno_t block_get_bsize(service_id_t service_id, size_t *bsize)
    817818{
    818819        devcon_t *devcon;
     
    829830 * @param nblocks       Output number of blocks.
    830831 *
    831  * @return              EOK on success or negative error code on failure.
    832  */
    833 int block_get_nblocks(service_id_t service_id, aoff64_t *nblocks)
     832 * @return              EOK on success or an error code on failure.
     833 */
     834errno_t block_get_nblocks(service_id_t service_id, aoff64_t *nblocks)
    834835{
    835836        devcon_t *devcon = devcon_search(service_id);
     
    846847 * @param data                  Buffer that receives the data
    847848 *
    848  * @return              EOK on success or negative error code on failure.
    849  */
    850 int block_read_bytes_direct(service_id_t service_id, aoff64_t abs_offset,
     849 * @return              EOK on success or an error code on failure.
     850 */
     851errno_t block_read_bytes_direct(service_id_t service_id, aoff64_t abs_offset,
    851852    size_t bytes, void *data)
    852853{
    853         int rc;
     854        errno_t rc;
    854855        size_t phys_block_size;
    855856        size_t buf_size;
     
    897898 *
    898899 * @return Allocated TOC structure.
    899  * @return EOK on success or negative error code.
    900  *
    901  */
    902 int block_read_toc(service_id_t service_id, uint8_t session, void *buf,
     900 * @return EOK on success or an error code.
     901 *
     902 */
     903errno_t block_read_toc(service_id_t service_id, uint8_t session, void *buf,
    903904    size_t bufsize)
    904905{
     
    916917 * @param src           Buffer for storing the data.
    917918 *
    918  * @return              EOK on success or negative error code on failure.
    919  */
    920 static int read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt, void *buf,
     919 * @return              EOK on success or an error code on failure.
     920 */
     921static errno_t read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt, void *buf,
    921922    size_t size)
    922923{
    923924        assert(devcon);
    924925       
    925         int rc = bd_read_blocks(devcon->bd, ba, cnt, buf, size);
     926        errno_t rc = bd_read_blocks(devcon->bd, ba, cnt, buf, size);
    926927        if (rc != EOK) {
    927                 printf("Error %d reading %zu blocks starting at block %" PRIuOFF64
    928                     " from device handle %" PRIun "\n", rc, cnt, ba,
     928                printf("Error %s reading %zu blocks starting at block %" PRIuOFF64
     929                    " from device handle %" PRIun "\n", str_error_name(rc), cnt, ba,
    929930                    devcon->service_id);
    930931#ifndef NDEBUG
     
    943944 * @param src           Buffer containing the data to write.
    944945 *
    945  * @return              EOK on success or negative error code on failure.
    946  */
    947 static int write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt, void *data,
     946 * @return              EOK on success or an error code on failure.
     947 */
     948static errno_t write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt, void *data,
    948949    size_t size)
    949950{
    950951        assert(devcon);
    951952       
    952         int rc = bd_write_blocks(devcon->bd, ba, cnt, data, size);
     953        errno_t rc = bd_write_blocks(devcon->bd, ba, cnt, data, size);
    953954        if (rc != EOK) {
    954                 printf("Error %d writing %zu blocks starting at block %" PRIuOFF64
    955                     " to device handle %" PRIun "\n", rc, cnt, ba, devcon->service_id);
     955                printf("Error %s writing %zu blocks starting at block %" PRIuOFF64
     956                    " to device handle %" PRIun "\n", str_error_name(rc), cnt, ba, devcon->service_id);
    956957#ifndef NDEBUG
    957958                stacktrace_print();
Note: See TracChangeset for help on using the changeset viewer.