Changes in uspace/lib/label/src/gpt.c [b33d140:6a66923] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/label/src/gpt.c
rb33d140 r6a66923 35 35 36 36 #include <adt/checksum.h> 37 #include <block.h> 37 38 #include <byteorder.h> 38 39 #include <errno.h> … … 46 47 #include "gpt.h" 47 48 48 static int gpt_open( label_bd_t *, label_t **);49 static int gpt_create( label_bd_t *, label_t **);49 static int gpt_open(service_id_t, label_t **); 50 static int gpt_create(service_id_t, label_t **); 50 51 static void gpt_close(label_t *); 51 52 static int gpt_destroy(label_t *); … … 70 71 static int gpt_hdr_get_crc(gpt_header_t *, size_t, uint32_t *); 71 72 72 static int gpt_pmbr_create( label_bd_t *, size_t, uint64_t);73 static int gpt_pmbr_destroy( label_bd_t *, size_t);73 static int gpt_pmbr_create(service_id_t, size_t, uint64_t); 74 static int gpt_pmbr_destroy(service_id_t, size_t); 74 75 75 76 const uint8_t efi_signature[8] = { … … 92 93 }; 93 94 94 static int gpt_open( label_bd_t *bd, label_t **rlabel)95 static int gpt_open(service_id_t sid, label_t **rlabel) 95 96 { 96 97 label_t *label = NULL; … … 99 100 uint8_t *etable[2]; 100 101 size_t bsize; 101 aoff64_t nblocks;102 102 uint32_t num_entries; 103 103 uint32_t esize; … … 118 118 etable[1] = NULL; 119 119 120 rc = bd->ops->get_bsize(bd->arg, &bsize); 121 if (rc != EOK) { 122 rc = EIO; 123 goto error; 124 } 125 126 rc = bd->ops->get_nblocks(bd->arg, &nblocks); 120 rc = block_get_bsize(sid, &bsize); 127 121 if (rc != EOK) { 128 122 rc = EIO; … … 147 141 } 148 142 149 rc = b d->ops->read(bd->arg, gpt_hdr_ba, 1, gpt_hdr[0]);143 rc = block_read_direct(sid, gpt_hdr_ba, 1, gpt_hdr[0]); 150 144 if (rc != EOK) { 151 145 rc = EIO; … … 155 149 h1ba = uint64_t_le2host(gpt_hdr[0]->alternate_lba); 156 150 157 if (h1ba >= nblocks) { 158 rc = EINVAL; 159 goto error; 160 } 161 162 rc = bd->ops->read(bd->arg, h1ba, 1, gpt_hdr[1]); 151 rc = block_read_direct(sid, h1ba, 1, gpt_hdr[1]); 163 152 if (rc != EOK) { 164 153 rc = EIO; … … 288 277 } 289 278 290 rc = b d->ops->read(bd->arg, ptba[j], pt_blocks / 2, etable[j]);279 rc = block_read_direct(sid, ptba[j], pt_blocks / 2, etable[j]); 291 280 if (rc != EOK) { 292 281 rc = EIO; … … 319 308 label->ops = &gpt_label_ops; 320 309 label->ltype = lt_gpt; 321 label-> bd = *bd;310 label->svc_id = sid; 322 311 label->ablock0 = ba_min; 323 312 label->anblocks = ba_max - ba_min + 1; … … 345 334 } 346 335 347 static int gpt_create( label_bd_t *bd, label_t **rlabel)336 static int gpt_create(service_id_t sid, label_t **rlabel) 348 337 { 349 338 label_t *label = NULL; … … 364 353 int rc; 365 354 366 rc = b d->ops->get_bsize(bd->arg, &bsize);355 rc = block_get_bsize(sid, &bsize); 367 356 if (rc != EOK) { 368 357 rc = EIO; … … 375 364 } 376 365 377 rc = b d->ops->get_nblocks(bd->arg, &nblocks);366 rc = block_get_nblocks(sid, &nblocks); 378 367 if (rc != EOK) { 379 368 rc = EIO; … … 391 380 } 392 381 393 rc = gpt_pmbr_create( bd, bsize, nblocks);382 rc = gpt_pmbr_create(sid, bsize, nblocks); 394 383 if (rc != EOK) { 395 384 rc = EIO; … … 416 405 } 417 406 418 rc = b d->ops->write(bd->arg, ptba[i], pt_blocks, etable);407 rc = block_write_direct(sid, ptba[i], pt_blocks, etable); 419 408 if (rc != EOK) { 420 409 rc = EIO; … … 451 440 gpt_hdr_compute_crc(gpt_hdr, sizeof(gpt_header_t)); 452 441 453 rc = b d->ops->write(bd->arg, hdr_ba[i], 1, gpt_hdr);442 rc = block_write_direct(sid, hdr_ba[i], 1, gpt_hdr); 454 443 if (rc != EOK) { 455 444 rc = EIO; … … 471 460 label->ops = &gpt_label_ops; 472 461 label->ltype = lt_gpt; 473 label-> bd = *bd;462 label->svc_id = sid; 474 463 label->ablock0 = ba_min; 475 464 label->anblocks = ba_max - ba_min + 1; … … 531 520 } 532 521 533 rc = label->bd.ops->write(label->bd.arg, label->lt.gpt.hdr_ba[i],522 rc = block_write_direct(label->svc_id, label->lt.gpt.hdr_ba[i], 534 523 1, gpt_hdr); 535 524 if (rc != EOK) { … … 548 537 } 549 538 550 rc = label->bd.ops->write(label->bd.arg,539 rc = block_write_direct(label->svc_id, 551 540 label->lt.gpt.ptable_ba[i], label->lt.gpt.pt_blocks, 552 541 etable); … … 560 549 } 561 550 562 rc = gpt_pmbr_destroy( &label->bd, label->block_size);551 rc = gpt_pmbr_destroy(label->svc_id, label->block_size); 563 552 if (rc != EOK) 564 553 goto error; … … 882 871 nblocks = label->lt.gpt.pt_blocks; 883 872 884 rc = label->bd.ops->read(label->bd.arg, ba, nblocks, buf);873 rc = block_read_direct(label->svc_id, ba, nblocks, buf); 885 874 if (rc != EOK) { 886 875 rc = EIO; … … 899 888 *e = *pte; 900 889 901 rc = label->bd.ops->write(label->bd.arg, ba, nblocks, buf);890 rc = block_write_direct(label->svc_id, ba, nblocks, buf); 902 891 if (rc != EOK) { 903 892 rc = EIO; … … 934 923 935 924 for (i = 0; i < 2; i++) { 936 rc = label->bd.ops->read(label->bd.arg,925 rc = block_read_direct(label->svc_id, 937 926 label->lt.gpt.hdr_ba[i], 1, gpt_hdr); 938 927 if (rc != EOK) { … … 944 933 gpt_hdr_compute_crc(gpt_hdr, label->lt.gpt.hdr_size); 945 934 946 rc = label->bd.ops->write(label->bd.arg,935 rc = block_write_direct(label->svc_id, 947 936 label->lt.gpt.hdr_ba[i], 1, gpt_hdr); 948 937 if (rc != EOK) { … … 951 940 } 952 941 } 953 942 954 943 rc = EOK; 955 944 956 945 exit: 957 946 free(gpt_hdr); … … 985 974 986 975 /** Create GPT Protective MBR */ 987 static int gpt_pmbr_create( label_bd_t *bd, size_t bsize, uint64_t nblocks)976 static int gpt_pmbr_create(service_id_t sid, size_t bsize, uint64_t nblocks) 988 977 { 989 978 mbr_br_block_t *pmbr = NULL; … … 1009 998 pmbr->signature = host2uint16_t_le(mbr_br_signature); 1010 999 1011 rc = b d->ops->write(bd->arg, mbr_ba, 1, pmbr);1000 rc = block_write_direct(sid, mbr_ba, 1, pmbr); 1012 1001 if (rc != EOK) { 1013 1002 rc = EIO; … … 1023 1012 1024 1013 /** Destroy GPT Protective MBR */ 1025 static int gpt_pmbr_destroy( label_bd_t *bd, size_t bsize)1014 static int gpt_pmbr_destroy(service_id_t sid, size_t bsize) 1026 1015 { 1027 1016 mbr_br_block_t *pmbr = NULL; … … 1034 1023 } 1035 1024 1036 rc = b d->ops->write(bd->arg, mbr_ba, 1, pmbr);1025 rc = block_write_direct(sid, mbr_ba, 1, pmbr); 1037 1026 if (rc != EOK) { 1038 1027 rc = EIO;
Note:
See TracChangeset
for help on using the changeset viewer.