Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/label/src/mbr.c

    r9f64c1e rd8513177  
    3434 */
    3535
     36#include <block.h>
    3637#include <byteorder.h>
    3738#include <errno.h>
     
    3940#include <stdlib.h>
    4041
    41 #include "std/fat.h"
    4242#include "std/mbr.h"
    4343#include "mbr.h"
    4444
    45 static int mbr_open(label_bd_t *, label_t **);
     45static int mbr_open(service_id_t, label_t **);
    4646static int mbr_open_ext(label_t *);
    47 static int mbr_create(label_bd_t *, label_t **);
     47static int mbr_create(service_id_t, label_t **);
    4848static void mbr_close(label_t *);
    4949static int mbr_destroy(label_t *);
     
    8686};
    8787
    88 static int mbr_open(label_bd_t *bd, label_t **rlabel)
     88static int mbr_open(service_id_t sid, label_t **rlabel)
    8989{
    9090        label_t *label = NULL;
    9191        mbr_br_block_t *mbr = NULL;
    92         fat_bs_t *bs;
    9392        mbr_pte_t *eptr;
    9493        uint16_t sgn;
     
    9897        int rc;
    9998
    100         rc = bd->ops->get_bsize(bd->arg, &bsize);
    101         if (rc != EOK) {
    102                 rc = EIO;
    103                 goto error;
    104         }
    105 
    106         rc = bd->ops->get_nblocks(bd->arg, &nblocks);
     99        rc = block_get_bsize(sid, &bsize);
     100        if (rc != EOK) {
     101                rc = EIO;
     102                goto error;
     103        }
     104
     105        rc = block_get_nblocks(sid, &nblocks);
    107106        if (rc != EOK) {
    108107                rc = EIO;
     
    126125        }
    127126
    128         bs = (fat_bs_t *)mbr;
    129 
    130         rc = bd->ops->read(bd->arg, mbr_ba, 1, mbr);
     127        rc = block_read_direct(sid, mbr_ba, 1, mbr);
    131128        if (rc != EOK) {
    132129                rc = EIO;
     
    149146        }
    150147
    151         /*
    152          * We can't really tell whether this is an MBR. Make sure
    153          * this is not actually the BR of a 12/16-bit FAT file system
    154          */
    155         if (bs->type[0] == 'F' && bs->type[1] == 'A' && bs->type[2] == 'T') {
    156                 rc = EIO;
    157                 goto error;
    158         }
    159 
    160         /*
    161          * Or a 32-bit FAT file system
    162          */
    163         if (bs->fat32.type[0] == 'F' && bs->fat32.type[1] == 'A' &&
    164             bs->fat32.type[2] == 'T') {
    165                 rc = EIO;
    166                 goto error;
    167         }
    168148
    169149        label->ext_part = NULL;
     
    180160        label->ops = &mbr_label_ops;
    181161        label->ltype = lt_mbr;
    182         label->bd = *bd;
     162        label->svc_id = sid;
    183163        label->block_size = bsize;
    184164        label->ablock0 = mbr_ablock0;
     
    239219        while (true) {
    240220                /* Read EBR */
    241                 rc = label->bd.ops->read(label->bd.arg, ebr_b0, 1, ebr);
     221                rc = block_read_direct(label->svc_id, ebr_b0, 1, ebr);
    242222                if (rc != EOK) {
    243223                        rc = EIO;
     
    300280}
    301281
    302 static int mbr_create(label_bd_t *bd, label_t **rlabel)
     282static int mbr_create(service_id_t sid, label_t **rlabel)
    303283{
    304284        label_t *label = NULL;
     
    309289        int rc;
    310290
    311         rc = bd->ops->get_bsize(bd->arg, &bsize);
    312         if (rc != EOK) {
    313                 rc = EIO;
    314                 goto error;
    315         }
    316 
    317         rc = bd->ops->get_nblocks(bd->arg, &nblocks);
     291        rc = block_get_bsize(sid, &bsize);
     292        if (rc != EOK) {
     293                rc = EIO;
     294                goto error;
     295        }
     296
     297        rc = block_get_nblocks(sid, &nblocks);
    318298        if (rc != EOK) {
    319299                rc = EIO;
     
    341321        mbr->signature = host2uint16_t_le(mbr_br_signature);
    342322
    343         rc = bd->ops->write(bd->arg, mbr_ba, 1, mbr);
     323        rc = block_write_direct(sid, mbr_ba, 1, mbr);
    344324        if (rc != EOK) {
    345325                rc = EIO;
     
    353333        label->ltype = lt_mbr;
    354334        label->block_size = bsize;
    355         label->bd = *bd;
     335        label->svc_id = sid;
    356336        label->ablock0 = mbr_ablock0;
    357337        label->anblocks = nblocks - mbr_ablock0;
     
    407387        }
    408388
    409         rc = label->bd.ops->write(label->bd.arg, mbr_ba, 1, mbr);
     389        rc = block_write_direct(label->svc_id, mbr_ba, 1, mbr);
    410390        if (rc != EOK) {
    411391                rc = EIO;
     
    1018998                return ENOMEM;
    1019999
    1020         rc = label->bd.ops->read(label->bd.arg, mbr_ba, 1, br);
     1000        rc = block_read_direct(label->svc_id, mbr_ba, 1, br);
    10211001        if (rc != EOK) {
    10221002                rc = EIO;
     
    10261006        br->pte[index] = *pte;
    10271007
    1028         rc = label->bd.ops->write(label->bd.arg, mbr_ba, 1, br);
     1008        rc = block_write_direct(label->svc_id, mbr_ba, 1, br);
    10291009        if (rc != EOK) {
    10301010                rc = EIO;
     
    10861066        br->signature = host2uint16_t_le(mbr_br_signature);
    10871067
    1088         rc = label->bd.ops->write(label->bd.arg, ba, 1, br);
     1068        rc = block_write_direct(label->svc_id, ba, 1, br);
    10891069        if (rc != EOK) {
    10901070                rc = EIO;
     
    11111091        ba = part->block0 - part->hdr_blocks;
    11121092
    1113         rc = label->bd.ops->write(label->bd.arg, ba, 1, br);
     1093        rc = block_write_direct(label->svc_id, ba, 1, br);
    11141094        if (rc != EOK) {
    11151095                rc = EIO;
     
    11381118                return ENOMEM;
    11391119
    1140         rc = label->bd.ops->read(label->bd.arg, ba, 1, br);
     1120        rc = block_read_direct(label->svc_id, ba, 1, br);
    11411121        if (rc != EOK) {
    11421122                rc = EIO;
     
    11531133        mbr_log_part_to_ptes(part, NULL, &br->pte[mbr_ebr_pte_next]);
    11541134
    1155         rc = label->bd.ops->write(label->bd.arg, ba, 1, br);
     1135        rc = block_write_direct(label->svc_id, ba, 1, br);
    11561136        if (rc != EOK) {
    11571137                rc = EIO;
Note: See TracChangeset for help on using the changeset viewer.