Ignore:
File:
1 edited

Legend:

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

    rb7fd2a0 r38d150e  
    5252#include <stdio.h>
    5353#include <stacktrace.h>
    54 #include <str_error.h>
    5554#include <offset.h>
    5655#include <inttypes.h>
     
    8887} devcon_t;
    8988
    90 static errno_t read_blocks(devcon_t *, aoff64_t, size_t, void *, size_t);
    91 static errno_t write_blocks(devcon_t *, aoff64_t, size_t, void *, size_t);
     89static int read_blocks(devcon_t *, aoff64_t, size_t, void *, size_t);
     90static int write_blocks(devcon_t *, aoff64_t, size_t, void *, size_t);
    9291static aoff64_t ba_ltop(devcon_t *, aoff64_t);
    9392
     
    107106}
    108107
    109 static errno_t devcon_add(service_id_t service_id, async_sess_t *sess,
     108static int devcon_add(service_id_t service_id, async_sess_t *sess,
    110109    size_t bsize, aoff64_t dev_size, bd_t *bd)
    111110{
     
    146145}
    147146
    148 errno_t block_init(service_id_t service_id, size_t comm_size)
     147int block_init(service_id_t service_id, size_t comm_size)
    149148{
    150149        bd_t *bd;
     
    156155        }
    157156       
    158         errno_t rc = bd_open(sess, &bd);
     157        int rc = bd_open(sess, &bd);
    159158        if (rc != EOK) {
    160159                async_hangup(sess);
     
    209208}
    210209
    211 errno_t block_bb_read(service_id_t service_id, aoff64_t ba)
     210int block_bb_read(service_id_t service_id, aoff64_t ba)
    212211{
    213212        void *bb_buf;
    214         errno_t rc;
     213        int rc;
    215214
    216215        devcon_t *devcon = devcon_search(service_id);
     
    270269};
    271270
    272 errno_t block_cache_init(service_id_t service_id, size_t size, unsigned blocks,
     271int block_cache_init(service_id_t service_id, size_t size, unsigned blocks,
    273272    enum cache_mode mode)
    274273{
     
    307306}
    308307
    309 errno_t block_cache_fini(service_id_t service_id)
     308int block_cache_fini(service_id_t service_id)
    310309{
    311310        devcon_t *devcon = devcon_search(service_id);
    312311        cache_t *cache;
    313         errno_t rc;
     312        int rc;
    314313
    315314        if (!devcon)
     
    381380 *                              device.
    382381 *
    383  * @return                      EOK on success or an error code.
    384  */
    385 errno_t block_get(block_t **block, service_id_t service_id, aoff64_t ba, int flags)
     382 * @return                      EOK on success or a negative error code.
     383 */
     384int block_get(block_t **block, service_id_t service_id, aoff64_t ba, int flags)
    386385{
    387386        devcon_t *devcon;
     
    390389        link_t *link;
    391390        aoff64_t p_ba;
    392         errno_t rc;
     391        int rc;
    393392       
    394393        devcon = devcon_search(service_id);
     
    578577 * @param block         Block of which a reference is to be released.
    579578 *
    580  * @return              EOK on success or an error code.
    581  */
    582 errno_t block_put(block_t *block)
     579 * @return              EOK on success or a negative error code.
     580 */
     581int block_put(block_t *block)
    583582{
    584583        devcon_t *devcon = devcon_search(block->service_id);
     
    586585        unsigned blocks_cached;
    587586        enum cache_mode mode;
    588         errno_t rc = EOK;
     587        int rc = EOK;
    589588
    590589        assert(devcon);
     
    699698 * @param block_size    Block size to be used for the transfer.
    700699 *
    701  * @return              EOK on success or an error code on failure.
    702  */
    703 errno_t block_seqread(service_id_t service_id, void *buf, size_t *bufpos,
     700 * @return              EOK on success or a negative return code on failure.
     701 */
     702int block_seqread(service_id_t service_id, void *buf, size_t *bufpos,
    704703    size_t *buflen, aoff64_t *pos, void *dst, size_t size)
    705704{
     
    735734                if (*bufpos == *buflen) {
    736735                        /* Refill the communication buffer with a new block. */
    737                         errno_t rc;
     736                        int rc;
    738737
    739738                        rc = read_blocks(devcon, *pos / block_size, 1, buf,
     
    758757 * @param src           Buffer for storing the data.
    759758 *
    760  * @return              EOK on success or an error code on failure.
    761  */
    762 errno_t block_read_direct(service_id_t service_id, aoff64_t ba, size_t cnt, void *buf)
     759 * @return              EOK on success or negative error code on failure.
     760 */
     761int block_read_direct(service_id_t service_id, aoff64_t ba, size_t cnt, void *buf)
    763762{
    764763        devcon_t *devcon;
     
    777776 * @param src           The data to be written.
    778777 *
    779  * @return              EOK on success or an error code on failure.
    780  */
    781 errno_t block_write_direct(service_id_t service_id, aoff64_t ba, size_t cnt,
     778 * @return              EOK on success or negative error code on failure.
     779 */
     780int block_write_direct(service_id_t service_id, aoff64_t ba, size_t cnt,
    782781    const void *data)
    783782{
     
    796795 * @param cnt           Number of blocks.
    797796 *
    798  * @return              EOK on success or an error code on failure.
    799  */
    800 errno_t block_sync_cache(service_id_t service_id, aoff64_t ba, size_t cnt)
     797 * @return              EOK on success or negative error code on failure.
     798 */
     799int block_sync_cache(service_id_t service_id, aoff64_t ba, size_t cnt)
    801800{
    802801        devcon_t *devcon;
     
    813812 * @param bsize         Output block size.
    814813 *
    815  * @return              EOK on success or an error code on failure.
    816  */
    817 errno_t block_get_bsize(service_id_t service_id, size_t *bsize)
     814 * @return              EOK on success or negative error code on failure.
     815 */
     816int block_get_bsize(service_id_t service_id, size_t *bsize)
    818817{
    819818        devcon_t *devcon;
     
    830829 * @param nblocks       Output number of blocks.
    831830 *
    832  * @return              EOK on success or an error code on failure.
    833  */
    834 errno_t block_get_nblocks(service_id_t service_id, aoff64_t *nblocks)
     831 * @return              EOK on success or negative error code on failure.
     832 */
     833int block_get_nblocks(service_id_t service_id, aoff64_t *nblocks)
    835834{
    836835        devcon_t *devcon = devcon_search(service_id);
     
    847846 * @param data                  Buffer that receives the data
    848847 *
    849  * @return              EOK on success or an error code on failure.
    850  */
    851 errno_t block_read_bytes_direct(service_id_t service_id, aoff64_t abs_offset,
     848 * @return              EOK on success or negative error code on failure.
     849 */
     850int block_read_bytes_direct(service_id_t service_id, aoff64_t abs_offset,
    852851    size_t bytes, void *data)
    853852{
    854         errno_t rc;
     853        int rc;
    855854        size_t phys_block_size;
    856855        size_t buf_size;
     
    898897 *
    899898 * @return Allocated TOC structure.
    900  * @return EOK on success or an error code.
    901  *
    902  */
    903 errno_t block_read_toc(service_id_t service_id, uint8_t session, void *buf,
     899 * @return EOK on success or negative error code.
     900 *
     901 */
     902int block_read_toc(service_id_t service_id, uint8_t session, void *buf,
    904903    size_t bufsize)
    905904{
     
    917916 * @param src           Buffer for storing the data.
    918917 *
    919  * @return              EOK on success or an error code on failure.
    920  */
    921 static errno_t read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt, void *buf,
     918 * @return              EOK on success or negative error code on failure.
     919 */
     920static int read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt, void *buf,
    922921    size_t size)
    923922{
    924923        assert(devcon);
    925924       
    926         errno_t rc = bd_read_blocks(devcon->bd, ba, cnt, buf, size);
     925        int rc = bd_read_blocks(devcon->bd, ba, cnt, buf, size);
    927926        if (rc != EOK) {
    928                 printf("Error %s reading %zu blocks starting at block %" PRIuOFF64
    929                     " from device handle %" PRIun "\n", str_error_name(rc), cnt, ba,
     927                printf("Error %d reading %zu blocks starting at block %" PRIuOFF64
     928                    " from device handle %" PRIun "\n", rc, cnt, ba,
    930929                    devcon->service_id);
    931930#ifndef NDEBUG
     
    944943 * @param src           Buffer containing the data to write.
    945944 *
    946  * @return              EOK on success or an error code on failure.
    947  */
    948 static errno_t write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt, void *data,
     945 * @return              EOK on success or negative error code on failure.
     946 */
     947static int write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt, void *data,
    949948    size_t size)
    950949{
    951950        assert(devcon);
    952951       
    953         errno_t rc = bd_write_blocks(devcon->bd, ba, cnt, data, size);
     952        int rc = bd_write_blocks(devcon->bd, ba, cnt, data, size);
    954953        if (rc != EOK) {
    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);
     954                printf("Error %d writing %zu blocks starting at block %" PRIuOFF64
     955                    " to device handle %" PRIun "\n", rc, cnt, ba, devcon->service_id);
    957956#ifndef NDEBUG
    958957                stacktrace_print();
Note: See TracChangeset for help on using the changeset viewer.