Changes in uspace/lib/label/src/mbr.c [9f64c1e:d8513177] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/label/src/mbr.c
r9f64c1e rd8513177 34 34 */ 35 35 36 #include <block.h> 36 37 #include <byteorder.h> 37 38 #include <errno.h> … … 39 40 #include <stdlib.h> 40 41 41 #include "std/fat.h"42 42 #include "std/mbr.h" 43 43 #include "mbr.h" 44 44 45 static int mbr_open( label_bd_t *, label_t **);45 static int mbr_open(service_id_t, label_t **); 46 46 static int mbr_open_ext(label_t *); 47 static int mbr_create( label_bd_t *, label_t **);47 static int mbr_create(service_id_t, label_t **); 48 48 static void mbr_close(label_t *); 49 49 static int mbr_destroy(label_t *); … … 86 86 }; 87 87 88 static int mbr_open( label_bd_t *bd, label_t **rlabel)88 static int mbr_open(service_id_t sid, label_t **rlabel) 89 89 { 90 90 label_t *label = NULL; 91 91 mbr_br_block_t *mbr = NULL; 92 fat_bs_t *bs;93 92 mbr_pte_t *eptr; 94 93 uint16_t sgn; … … 98 97 int rc; 99 98 100 rc = b d->ops->get_bsize(bd->arg, &bsize);101 if (rc != EOK) { 102 rc = EIO; 103 goto error; 104 } 105 106 rc = b d->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); 107 106 if (rc != EOK) { 108 107 rc = EIO; … … 126 125 } 127 126 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); 131 128 if (rc != EOK) { 132 129 rc = EIO; … … 149 146 } 150 147 151 /*152 * We can't really tell whether this is an MBR. Make sure153 * this is not actually the BR of a 12/16-bit FAT file system154 */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 system162 */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 }168 148 169 149 label->ext_part = NULL; … … 180 160 label->ops = &mbr_label_ops; 181 161 label->ltype = lt_mbr; 182 label-> bd = *bd;162 label->svc_id = sid; 183 163 label->block_size = bsize; 184 164 label->ablock0 = mbr_ablock0; … … 239 219 while (true) { 240 220 /* 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); 242 222 if (rc != EOK) { 243 223 rc = EIO; … … 300 280 } 301 281 302 static int mbr_create( label_bd_t *bd, label_t **rlabel)282 static int mbr_create(service_id_t sid, label_t **rlabel) 303 283 { 304 284 label_t *label = NULL; … … 309 289 int rc; 310 290 311 rc = b d->ops->get_bsize(bd->arg, &bsize);312 if (rc != EOK) { 313 rc = EIO; 314 goto error; 315 } 316 317 rc = b d->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); 318 298 if (rc != EOK) { 319 299 rc = EIO; … … 341 321 mbr->signature = host2uint16_t_le(mbr_br_signature); 342 322 343 rc = b d->ops->write(bd->arg, mbr_ba, 1, mbr);323 rc = block_write_direct(sid, mbr_ba, 1, mbr); 344 324 if (rc != EOK) { 345 325 rc = EIO; … … 353 333 label->ltype = lt_mbr; 354 334 label->block_size = bsize; 355 label-> bd = *bd;335 label->svc_id = sid; 356 336 label->ablock0 = mbr_ablock0; 357 337 label->anblocks = nblocks - mbr_ablock0; … … 407 387 } 408 388 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); 410 390 if (rc != EOK) { 411 391 rc = EIO; … … 1018 998 return ENOMEM; 1019 999 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); 1021 1001 if (rc != EOK) { 1022 1002 rc = EIO; … … 1026 1006 br->pte[index] = *pte; 1027 1007 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); 1029 1009 if (rc != EOK) { 1030 1010 rc = EIO; … … 1086 1066 br->signature = host2uint16_t_le(mbr_br_signature); 1087 1067 1088 rc = label->bd.ops->write(label->bd.arg, ba, 1, br);1068 rc = block_write_direct(label->svc_id, ba, 1, br); 1089 1069 if (rc != EOK) { 1090 1070 rc = EIO; … … 1111 1091 ba = part->block0 - part->hdr_blocks; 1112 1092 1113 rc = label->bd.ops->write(label->bd.arg, ba, 1, br);1093 rc = block_write_direct(label->svc_id, ba, 1, br); 1114 1094 if (rc != EOK) { 1115 1095 rc = EIO; … … 1138 1118 return ENOMEM; 1139 1119 1140 rc = label->bd.ops->read(label->bd.arg, ba, 1, br);1120 rc = block_read_direct(label->svc_id, ba, 1, br); 1141 1121 if (rc != EOK) { 1142 1122 rc = EIO; … … 1153 1133 mbr_log_part_to_ptes(part, NULL, &br->pte[mbr_ebr_pte_next]); 1154 1134 1155 rc = label->bd.ops->write(label->bd.arg, ba, 1, br);1135 rc = block_write_direct(label->svc_id, ba, 1, br); 1156 1136 if (rc != EOK) { 1157 1137 rc = EIO;
Note:
See TracChangeset
for help on using the changeset viewer.