Changes in uspace/lib/block/libblock.c [08cba4b:7a72ce1a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/block/libblock.c
r08cba4b r7a72ce1a 93 93 static int get_block_size(async_sess_t *, size_t *); 94 94 static int get_num_blocks(async_sess_t *, aoff64_t *); 95 static int read_toc(async_sess_t *, uint8_t); 95 96 static aoff64_t ba_ltop(devcon_t *, aoff64_t); 96 97 … … 895 896 * @param service_id Service ID of the block device. 896 897 * @param session Starting session. 897 * 898 * @return Allocated TOC structure. 899 * @return NULL on failure. 900 * 901 */ 902 toc_block_t *block_get_toc(service_id_t service_id, uint8_t session) 898 * @param data Buffer to read TOC into. 899 * 900 * @return EOK on success. 901 * @return Error code on failure. 902 * 903 */ 904 int block_get_toc(service_id_t service_id, uint8_t session, void *data) 903 905 { 904 906 devcon_t *devcon = devcon_search(service_id); 905 907 assert(devcon); 906 908 907 toc_block_t *toc = NULL;908 909 909 fibril_mutex_lock(&devcon->comm_area_lock); 910 910 911 async_exch_t *exch = async_exchange_begin(devcon->sess); 912 int rc = async_req_1_0(exch, BD_READ_TOC, session); 913 async_exchange_end(exch); 914 915 if (rc == EOK) { 916 toc = (toc_block_t *) malloc(sizeof(toc_block_t)); 917 if (toc != NULL) { 918 memset(toc, 0, sizeof(toc_block_t)); 919 memcpy(toc, devcon->comm_area, 920 min(devcon->pblock_size, sizeof(toc_block_t))); 921 } 922 } 923 911 int rc = read_toc(devcon->sess, session); 912 if (rc == EOK) 913 memcpy(data, devcon->comm_area, devcon->pblock_size); 924 914 925 915 fibril_mutex_unlock(&devcon->comm_area_lock); 926 916 927 return toc;917 return rc; 928 918 } 929 919 … … 1018 1008 } 1019 1009 1010 /** Get TOC from block device. */ 1011 static int read_toc(async_sess_t *sess, uint8_t session) 1012 { 1013 async_exch_t *exch = async_exchange_begin(sess); 1014 int rc = async_req_1_0(exch, BD_READ_TOC, session); 1015 async_exchange_end(exch); 1016 1017 return rc; 1018 } 1019 1020 1020 /** Convert logical block address to physical block address. */ 1021 1021 static aoff64_t ba_ltop(devcon_t *devcon, aoff64_t lba)
Note:
See TracChangeset
for help on using the changeset viewer.