Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/vbd/disk.c

    rd5c1051 rb7fd2a0  
    5858static category_id_t part_cid;
    5959
    60 static int vbds_disk_parts_add(vbds_disk_t *, label_t *);
    61 static int vbds_disk_parts_remove(vbds_disk_t *, vbds_rem_flag_t);
    62 
    63 static int vbds_bd_open(bd_srvs_t *, bd_srv_t *);
    64 static int vbds_bd_close(bd_srv_t *);
    65 static int vbds_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
    66 static int vbds_bd_sync_cache(bd_srv_t *, aoff64_t, size_t);
    67 static int vbds_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *,
     60static errno_t vbds_disk_parts_add(vbds_disk_t *, label_t *);
     61static errno_t vbds_disk_parts_remove(vbds_disk_t *, vbds_rem_flag_t);
     62
     63static errno_t vbds_bd_open(bd_srvs_t *, bd_srv_t *);
     64static errno_t vbds_bd_close(bd_srv_t *);
     65static errno_t vbds_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     66static errno_t vbds_bd_sync_cache(bd_srv_t *, aoff64_t, size_t);
     67static errno_t vbds_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *,
    6868    size_t);
    69 static int vbds_bd_get_block_size(bd_srv_t *, size_t *);
    70 static int vbds_bd_get_num_blocks(bd_srv_t *, aoff64_t *);
    71 
    72 static int vbds_bsa_translate(vbds_part_t *, aoff64_t, size_t, aoff64_t *);
    73 
    74 static int vbds_part_svc_register(vbds_part_t *);
    75 static int vbds_part_svc_unregister(vbds_part_t *);
    76 static int vbds_part_indices_update(vbds_disk_t *);
     69static errno_t vbds_bd_get_block_size(bd_srv_t *, size_t *);
     70static errno_t vbds_bd_get_num_blocks(bd_srv_t *, aoff64_t *);
     71
     72static errno_t vbds_bsa_translate(vbds_part_t *, aoff64_t, size_t, aoff64_t *);
     73
     74static errno_t vbds_part_svc_register(vbds_part_t *);
     75static errno_t vbds_part_svc_unregister(vbds_part_t *);
     76static errno_t vbds_part_indices_update(vbds_disk_t *);
    7777
    7878static vbd_part_id_t vbds_part_id = 1;
    7979
    80 static int vbds_label_get_bsize(void *, size_t *);
    81 static int vbds_label_get_nblocks(void *, aoff64_t *);
    82 static int vbds_label_read(void *, aoff64_t, size_t, void *);
    83 static int vbds_label_write(void *, aoff64_t, size_t, const void *);
     80static errno_t vbds_label_get_bsize(void *, size_t *);
     81static errno_t vbds_label_get_nblocks(void *, aoff64_t *);
     82static errno_t vbds_label_read(void *, aoff64_t, size_t, void *);
     83static errno_t vbds_label_write(void *, aoff64_t, size_t, const void *);
    8484
    8585/** Block device operations provided by VBD */
     
    132132}
    133133
    134 int vbds_disks_init(void)
    135 {
    136         int rc;
     134errno_t vbds_disks_init(void)
     135{
     136        errno_t rc;
    137137
    138138        fibril_mutex_initialize(&vbds_disks_lock);
     
    152152
    153153/** Check for new/removed disk devices */
    154 static int vbds_disks_check_new(void)
     154static errno_t vbds_disks_check_new(void)
    155155{
    156156        bool already_known;
     
    159159        size_t count, i;
    160160        vbds_disk_t *cur, *next;
    161         int rc;
     161        errno_t rc;
    162162
    163163        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_disks_check_new()");
     
    229229
    230230
    231 static int vbds_disk_by_svcid(service_id_t sid, vbds_disk_t **rdisk)
     231static errno_t vbds_disk_by_svcid(service_id_t sid, vbds_disk_t **rdisk)
    232232{
    233233        list_foreach(vbds_disks, ldisks, vbds_disk_t, disk) {
     
    256256}
    257257
    258 static int vbds_part_by_pid(vbds_part_id_t partid, vbds_part_t **rpart)
     258static errno_t vbds_part_by_pid(vbds_part_id_t partid, vbds_part_t **rpart)
    259259{
    260260        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_part_by_pid(%zu)", partid);
     
    278278}
    279279
    280 static int vbds_part_by_svcid(service_id_t svcid, vbds_part_t **rpart)
     280static errno_t vbds_part_by_svcid(service_id_t svcid, vbds_part_t **rpart)
    281281{
    282282        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_part_by_svcid(%zu)", svcid);
     
    301301
    302302/** Add partition to our inventory based on liblabel partition structure */
    303 static int vbds_part_add(vbds_disk_t *disk, label_part_t *lpart,
     303static errno_t vbds_part_add(vbds_disk_t *disk, label_part_t *lpart,
    304304    vbds_part_t **rpart)
    305305{
     
    307307        service_id_t psid = 0;
    308308        label_part_info_t lpinfo;
    309         int rc;
     309        errno_t rc;
    310310
    311311        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_part_add(%s, %p)",
     
    362362 *
    363363 */
    364 static int vbds_part_remove(vbds_part_t *part, vbds_rem_flag_t flag,
     364static errno_t vbds_part_remove(vbds_part_t *part, vbds_rem_flag_t flag,
    365365    label_part_t **rlpart)
    366366{
    367367        label_part_t *lpart;
    368         int rc;
     368        errno_t rc;
    369369
    370370        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_part_remove(%p)", part);
     
    404404/** Remove all disk partitions from our inventory leaving only the underlying
    405405 * liblabel partition structures. */
    406 static int vbds_disk_parts_add(vbds_disk_t *disk, label_t *label)
     406static errno_t vbds_disk_parts_add(vbds_disk_t *disk, label_t *label)
    407407{
    408408        label_part_t *part;
    409         int rc;
     409        errno_t rc;
    410410
    411411        part = label_part_first(label);
     
    426426/** Remove all disk partitions from our inventory leaving only the underlying
    427427 * liblabel partition structures. */
    428 static int vbds_disk_parts_remove(vbds_disk_t *disk, vbds_rem_flag_t flag)
     428static errno_t vbds_disk_parts_remove(vbds_disk_t *disk, vbds_rem_flag_t flag)
    429429{
    430430        link_t *link;
    431431        vbds_part_t *part;
    432         int rc;
     432        errno_t rc;
    433433
    434434        link = list_first(&disk->parts);
     
    450450}
    451451
    452 int vbds_disk_discovery_start(void)
    453 {
    454         int rc;
     452errno_t vbds_disk_discovery_start(void)
     453{
     454        errno_t rc;
    455455
    456456        rc = loc_register_cat_change_cb(vbds_disk_cat_change_cb);
     
    464464}
    465465
    466 int vbds_disk_add(service_id_t sid)
     466errno_t vbds_disk_add(service_id_t sid)
    467467{
    468468        label_t *label = NULL;
     
    472472        size_t block_size;
    473473        aoff64_t nblocks;
    474         int rc;
     474        errno_t rc;
    475475
    476476        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_disk_add(%zu)", sid);
     
    557557}
    558558
    559 int vbds_disk_remove(service_id_t sid)
     559errno_t vbds_disk_remove(service_id_t sid)
    560560{
    561561        vbds_disk_t *disk;
    562         int rc;
     562        errno_t rc;
    563563
    564564        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_disk_remove(%zu)", sid);
     
    583583
    584584/** Get list of disks as array of service IDs. */
    585 int vbds_disk_get_ids(service_id_t *id_buf, size_t buf_size, size_t *act_size)
     585errno_t vbds_disk_get_ids(service_id_t *id_buf, size_t buf_size, size_t *act_size)
    586586{
    587587        size_t act_cnt;
     
    611611}
    612612
    613 int vbds_disk_info(service_id_t sid, vbd_disk_info_t *info)
     613errno_t vbds_disk_info(service_id_t sid, vbd_disk_info_t *info)
    614614{
    615615        vbds_disk_t *disk;
    616616        label_info_t linfo;
    617         int rc;
     617        errno_t rc;
    618618
    619619        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_disk_info(%zu)", sid);
     
    638638}
    639639
    640 int vbds_get_parts(service_id_t sid, service_id_t *id_buf, size_t buf_size,
     640errno_t vbds_get_parts(service_id_t sid, service_id_t *id_buf, size_t buf_size,
    641641    size_t *act_size)
    642642{
     
    644644        size_t act_cnt;
    645645        size_t buf_cnt;
    646         int rc;
     646        errno_t rc;
    647647
    648648        rc = vbds_disk_by_svcid(sid, &disk);
     
    668668}
    669669
    670 int vbds_label_create(service_id_t sid, label_type_t ltype)
     670errno_t vbds_label_create(service_id_t sid, label_type_t ltype)
    671671{
    672672        label_t *label;
     
    674674        label_info_t linfo;
    675675        vbds_disk_t *disk;
    676         int rc, rc2;
     676        errno_t rc, rc2;
    677677
    678678        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_label_create(%zu)", sid);
     
    739739}
    740740
    741 int vbds_label_delete(service_id_t sid)
     741errno_t vbds_label_delete(service_id_t sid)
    742742{
    743743        vbds_disk_t *disk;
    744744        label_t *label;
    745745        label_bd_t lbd;
    746         int rc;
     746        errno_t rc;
    747747
    748748        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_label_delete(%zu)", sid);
     
    781781}
    782782
    783 int vbds_part_get_info(vbds_part_id_t partid, vbd_part_info_t *pinfo)
     783errno_t vbds_part_get_info(vbds_part_id_t partid, vbd_part_info_t *pinfo)
    784784{
    785785        vbds_part_t *part;
    786786        label_part_info_t lpinfo;
    787         int rc;
     787        errno_t rc;
    788788
    789789        rc = vbds_part_by_pid(partid, &part);
     
    810810}
    811811
    812 int vbds_part_create(service_id_t sid, vbd_part_spec_t *pspec,
     812errno_t vbds_part_create(service_id_t sid, vbd_part_spec_t *pspec,
    813813    vbds_part_id_t *rpart)
    814814{
     
    817817        label_part_spec_t lpspec;
    818818        label_part_t *lpart;
    819         int rc;
     819        errno_t rc;
    820820
    821821        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_part_create(%zu)", sid);
     
    879879}
    880880
    881 int vbds_part_delete(vbds_part_id_t partid)
     881errno_t vbds_part_delete(vbds_part_id_t partid)
    882882{
    883883        vbds_part_t *part;
    884884        vbds_disk_t *disk;
    885885        label_part_t *lpart;
    886         int rc;
     886        errno_t rc;
    887887
    888888        rc = vbds_part_by_pid(partid, &part);
     
    918918}
    919919
    920 int vbds_suggest_ptype(service_id_t sid, label_pcnt_t pcnt,
     920errno_t vbds_suggest_ptype(service_id_t sid, label_pcnt_t pcnt,
    921921    label_ptype_t *ptype)
    922922{
    923923        vbds_disk_t *disk;
    924         int rc;
     924        errno_t rc;
    925925
    926926        rc = vbds_disk_by_svcid(sid, &disk);
     
    942942}
    943943
    944 static int vbds_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
     944static errno_t vbds_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
    945945{
    946946        vbds_part_t *part = bd_srv_part(bd);
     
    953953}
    954954
    955 static int vbds_bd_close(bd_srv_t *bd)
     955static errno_t vbds_bd_close(bd_srv_t *bd)
    956956{
    957957        vbds_part_t *part = bd_srv_part(bd);
     
    967967}
    968968
    969 static int vbds_bd_read_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt,
     969static errno_t vbds_bd_read_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt,
    970970    void *buf, size_t size)
    971971{
    972972        vbds_part_t *part = bd_srv_part(bd);
    973973        aoff64_t gba;
    974         int rc;
     974        errno_t rc;
    975975
    976976        log_msg(LOG_DEFAULT, LVL_DEBUG2, "vbds_bd_read_blocks()");
     
    993993}
    994994
    995 static int vbds_bd_sync_cache(bd_srv_t *bd, aoff64_t ba, size_t cnt)
     995static errno_t vbds_bd_sync_cache(bd_srv_t *bd, aoff64_t ba, size_t cnt)
    996996{
    997997        vbds_part_t *part = bd_srv_part(bd);
    998998        aoff64_t gba;
    999         int rc;
     999        errno_t rc;
    10001000
    10011001        log_msg(LOG_DEFAULT, LVL_DEBUG2, "vbds_bd_sync_cache()");
     
    10171017}
    10181018
    1019 static int vbds_bd_write_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt,
     1019static errno_t vbds_bd_write_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt,
    10201020    const void *buf, size_t size)
    10211021{
    10221022        vbds_part_t *part = bd_srv_part(bd);
    10231023        aoff64_t gba;
    1024         int rc;
     1024        errno_t rc;
    10251025
    10261026        log_msg(LOG_DEFAULT, LVL_DEBUG2, "vbds_bd_write_blocks()");
     
    10421042}
    10431043
    1044 static int vbds_bd_get_block_size(bd_srv_t *bd, size_t *rsize)
     1044static errno_t vbds_bd_get_block_size(bd_srv_t *bd, size_t *rsize)
    10451045{
    10461046        vbds_part_t *part = bd_srv_part(bd);
     
    10551055}
    10561056
    1057 static int vbds_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
     1057static errno_t vbds_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
    10581058{
    10591059        vbds_part_t *part = bd_srv_part(bd);
     
    10711071{
    10721072        vbds_part_t *part;
    1073         int rc;
     1073        errno_t rc;
    10741074        service_id_t svcid;
    10751075
     
    10941094
    10951095/** Translate block segment address with range checking. */
    1096 static int vbds_bsa_translate(vbds_part_t *part, aoff64_t ba, size_t cnt,
     1096static errno_t vbds_bsa_translate(vbds_part_t *part, aoff64_t ba, size_t cnt,
    10971097    aoff64_t *gba)
    10981098{
     
    11051105
    11061106/** Register service for partition */
    1107 static int vbds_part_svc_register(vbds_part_t *part)
     1107static errno_t vbds_part_svc_register(vbds_part_t *part)
    11081108{
    11091109        char *name;
    11101110        service_id_t psid;
    11111111        int idx;
    1112         int rc;
     1112        errno_t rc;
    11131113
    11141114        idx = part->lpart->index;
     
    11521152
    11531153/** Unregister service for partition */
    1154 static int vbds_part_svc_unregister(vbds_part_t *part)
    1155 {
    1156         int rc;
     1154static errno_t vbds_part_svc_unregister(vbds_part_t *part)
     1155{
     1156        errno_t rc;
    11571157
    11581158        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_part_svc_unregister("
     
    11691169
    11701170/** Update service names for any partition whose index has changed. */
    1171 static int vbds_part_indices_update(vbds_disk_t *disk)
     1171static errno_t vbds_part_indices_update(vbds_disk_t *disk)
    11721172{
    11731173        label_part_info_t lpinfo;
    1174         int rc;
     1174        errno_t rc;
    11751175
    11761176        log_msg(LOG_DEFAULT, LVL_DEBUG, "vbds_part_indices_update()");
     
    12191219
    12201220/** Get block size wrapper for liblabel */
    1221 static int vbds_label_get_bsize(void *arg, size_t *bsize)
     1221static errno_t vbds_label_get_bsize(void *arg, size_t *bsize)
    12221222{
    12231223        vbds_disk_t *disk = (vbds_disk_t *)arg;
     
    12261226
    12271227/** Get number of blocks wrapper for liblabel */
    1228 static int vbds_label_get_nblocks(void *arg, aoff64_t *nblocks)
     1228static errno_t vbds_label_get_nblocks(void *arg, aoff64_t *nblocks)
    12291229{
    12301230        vbds_disk_t *disk = (vbds_disk_t *)arg;
     
    12331233
    12341234/** Read blocks wrapper for liblabel */
    1235 static int vbds_label_read(void *arg, aoff64_t ba, size_t cnt, void *buf)
     1235static errno_t vbds_label_read(void *arg, aoff64_t ba, size_t cnt, void *buf)
    12361236{
    12371237        vbds_disk_t *disk = (vbds_disk_t *)arg;
     
    12401240
    12411241/** Write blocks wrapper for liblabel */
    1242 static int vbds_label_write(void *arg, aoff64_t ba, size_t cnt, const void *data)
     1242static errno_t vbds_label_write(void *arg, aoff64_t ba, size_t cnt, const void *data)
    12431243{
    12441244        vbds_disk_t *disk = (vbds_disk_t *)arg;
Note: See TracChangeset for help on using the changeset viewer.