Changes in uspace/lib/block/block.c [38d150e:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/block/block.c
r38d150e rb7fd2a0 52 52 #include <stdio.h> 53 53 #include <stacktrace.h> 54 #include <str_error.h> 54 55 #include <offset.h> 55 56 #include <inttypes.h> … … 87 88 } devcon_t; 88 89 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);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); 91 92 static aoff64_t ba_ltop(devcon_t *, aoff64_t); 92 93 … … 106 107 } 107 108 108 static int devcon_add(service_id_t service_id, async_sess_t *sess,109 static errno_t devcon_add(service_id_t service_id, async_sess_t *sess, 109 110 size_t bsize, aoff64_t dev_size, bd_t *bd) 110 111 { … … 145 146 } 146 147 147 int block_init(service_id_t service_id, size_t comm_size)148 errno_t block_init(service_id_t service_id, size_t comm_size) 148 149 { 149 150 bd_t *bd; … … 155 156 } 156 157 157 int rc = bd_open(sess, &bd);158 errno_t rc = bd_open(sess, &bd); 158 159 if (rc != EOK) { 159 160 async_hangup(sess); … … 208 209 } 209 210 210 int block_bb_read(service_id_t service_id, aoff64_t ba)211 errno_t block_bb_read(service_id_t service_id, aoff64_t ba) 211 212 { 212 213 void *bb_buf; 213 int rc;214 errno_t rc; 214 215 215 216 devcon_t *devcon = devcon_search(service_id); … … 269 270 }; 270 271 271 int block_cache_init(service_id_t service_id, size_t size, unsigned blocks,272 errno_t block_cache_init(service_id_t service_id, size_t size, unsigned blocks, 272 273 enum cache_mode mode) 273 274 { … … 306 307 } 307 308 308 int block_cache_fini(service_id_t service_id)309 errno_t block_cache_fini(service_id_t service_id) 309 310 { 310 311 devcon_t *devcon = devcon_search(service_id); 311 312 cache_t *cache; 312 int rc;313 errno_t rc; 313 314 314 315 if (!devcon) … … 380 381 * device. 381 382 * 382 * @return EOK on success or a negativeerror 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 */ 385 errno_t block_get(block_t **block, service_id_t service_id, aoff64_t ba, int flags) 385 386 { 386 387 devcon_t *devcon; … … 389 390 link_t *link; 390 391 aoff64_t p_ba; 391 int rc;392 errno_t rc; 392 393 393 394 devcon = devcon_search(service_id); … … 577 578 * @param block Block of which a reference is to be released. 578 579 * 579 * @return EOK on success or a negativeerror code.580 */ 581 int block_put(block_t *block)580 * @return EOK on success or an error code. 581 */ 582 errno_t block_put(block_t *block) 582 583 { 583 584 devcon_t *devcon = devcon_search(block->service_id); … … 585 586 unsigned blocks_cached; 586 587 enum cache_mode mode; 587 int rc = EOK;588 errno_t rc = EOK; 588 589 589 590 assert(devcon); … … 698 699 * @param block_size Block size to be used for the transfer. 699 700 * 700 * @return EOK on success or a negative returncode 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 */ 703 errno_t block_seqread(service_id_t service_id, void *buf, size_t *bufpos, 703 704 size_t *buflen, aoff64_t *pos, void *dst, size_t size) 704 705 { … … 734 735 if (*bufpos == *buflen) { 735 736 /* Refill the communication buffer with a new block. */ 736 int rc;737 errno_t rc; 737 738 738 739 rc = read_blocks(devcon, *pos / block_size, 1, buf, … … 757 758 * @param src Buffer for storing the data. 758 759 * 759 * @return EOK on success or negativeerror 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 */ 762 errno_t block_read_direct(service_id_t service_id, aoff64_t ba, size_t cnt, void *buf) 762 763 { 763 764 devcon_t *devcon; … … 776 777 * @param src The data to be written. 777 778 * 778 * @return EOK on success or negativeerror 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 */ 781 errno_t block_write_direct(service_id_t service_id, aoff64_t ba, size_t cnt, 781 782 const void *data) 782 783 { … … 795 796 * @param cnt Number of blocks. 796 797 * 797 * @return EOK on success or negativeerror 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 */ 800 errno_t block_sync_cache(service_id_t service_id, aoff64_t ba, size_t cnt) 800 801 { 801 802 devcon_t *devcon; … … 812 813 * @param bsize Output block size. 813 814 * 814 * @return EOK on success or negativeerror 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 */ 817 errno_t block_get_bsize(service_id_t service_id, size_t *bsize) 817 818 { 818 819 devcon_t *devcon; … … 829 830 * @param nblocks Output number of blocks. 830 831 * 831 * @return EOK on success or negativeerror 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 */ 834 errno_t block_get_nblocks(service_id_t service_id, aoff64_t *nblocks) 834 835 { 835 836 devcon_t *devcon = devcon_search(service_id); … … 846 847 * @param data Buffer that receives the data 847 848 * 848 * @return EOK on success or negativeerror 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 */ 851 errno_t block_read_bytes_direct(service_id_t service_id, aoff64_t abs_offset, 851 852 size_t bytes, void *data) 852 853 { 853 int rc;854 errno_t rc; 854 855 size_t phys_block_size; 855 856 size_t buf_size; … … 897 898 * 898 899 * @return Allocated TOC structure. 899 * @return EOK on success or negativeerror 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 */ 903 errno_t block_read_toc(service_id_t service_id, uint8_t session, void *buf, 903 904 size_t bufsize) 904 905 { … … 916 917 * @param src Buffer for storing the data. 917 918 * 918 * @return EOK on success or negativeerror 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 */ 921 static errno_t read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt, void *buf, 921 922 size_t size) 922 923 { 923 924 assert(devcon); 924 925 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); 926 927 if (rc != EOK) { 927 printf("Error % dreading %zu blocks starting at block %" PRIuOFF64928 " 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, 929 930 devcon->service_id); 930 931 #ifndef NDEBUG … … 943 944 * @param src Buffer containing the data to write. 944 945 * 945 * @return EOK on success or negativeerror 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 */ 948 static errno_t write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt, void *data, 948 949 size_t size) 949 950 { 950 951 assert(devcon); 951 952 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); 953 954 if (rc != EOK) { 954 printf("Error % dwriting %zu blocks starting at block %" PRIuOFF64955 " 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); 956 957 #ifndef NDEBUG 957 958 stacktrace_print();
Note:
See TracChangeset
for help on using the changeset viewer.