Changeset cffa82aa in mainline
- Timestamp:
- 2015-11-04T18:39:51Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f71b938
- Parents:
- eed70f1
- Location:
- uspace/lib/label
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/label/include/std/mbr.h
reed70f1 rcffa82aa 73 73 mbr_pt_minix = 0x81, 74 74 /** Linux */ 75 mbr_pt_linux = 0x83 75 mbr_pt_linux = 0x83, 76 /** GPT Protective */ 77 mbr_pt_gpt_protect = 0xee 76 78 }; 77 79 -
uspace/lib/label/src/gpt.c
reed70f1 rcffa82aa 39 39 #include <errno.h> 40 40 #include <mem.h> 41 #include <stdint.h> 41 42 #include <stdlib.h> 42 43 #include <uuid.h> 43 44 45 #include "std/mbr.h" 44 46 #include "std/gpt.h" 45 47 #include "gpt.h" … … 68 70 static void gpt_hdr_compute_crc(gpt_header_t *, size_t); 69 71 static int gpt_hdr_get_crc(gpt_header_t *, size_t, uint32_t *); 72 73 static int gpt_pmbr_create(service_id_t, size_t, uint64_t); 74 static int gpt_pmbr_destroy(service_id_t, size_t); 70 75 71 76 const uint8_t efi_signature[8] = { … … 375 380 } 376 381 382 rc = gpt_pmbr_create(sid, bsize, nblocks); 383 if (rc != EOK) { 384 rc = EIO; 385 goto error; 386 } 387 377 388 uuid_generate(&disk_uuid); 378 389 … … 538 549 } 539 550 551 rc = gpt_pmbr_destroy(label->svc_id, label->block_size); 552 if (rc != EOK) 553 goto error; 554 540 555 free(label); 541 556 return EOK; … … 957 972 } 958 973 974 /** Create GPT Protective MBR */ 975 static int gpt_pmbr_create(service_id_t sid, size_t bsize, uint64_t nblocks) 976 { 977 mbr_br_block_t *pmbr = NULL; 978 uint64_t pmbr_nb; 979 int rc; 980 981 pmbr = calloc(1, bsize); 982 if (pmbr == NULL) { 983 rc = ENOMEM; 984 goto error; 985 } 986 987 pmbr_nb = nblocks - gpt_hdr_ba; 988 989 pmbr->pte[0].ptype = mbr_pt_gpt_protect; 990 pmbr->pte[0].first_lba = gpt_hdr_ba; 991 992 if (pmbr_nb <= UINT32_MAX) 993 pmbr->pte[0].length = host2uint32_t_le((uint32_t)pmbr_nb); 994 else 995 pmbr->pte[0].length = host2uint32_t_le(UINT32_MAX); 996 997 pmbr->signature = host2uint16_t_le(mbr_br_signature); 998 999 rc = block_write_direct(sid, mbr_ba, 1, pmbr); 1000 if (rc != EOK) { 1001 rc = EIO; 1002 goto error; 1003 } 1004 1005 free(pmbr); 1006 return EOK; 1007 error: 1008 free(pmbr); 1009 return rc; 1010 } 1011 1012 /** Destroy GPT Protective MBR */ 1013 static int gpt_pmbr_destroy(service_id_t sid, size_t bsize) 1014 { 1015 mbr_br_block_t *pmbr = NULL; 1016 int rc; 1017 1018 pmbr = calloc(1, bsize); 1019 if (pmbr == NULL) { 1020 rc = ENOMEM; 1021 goto error; 1022 } 1023 1024 rc = block_write_direct(sid, mbr_ba, 1, pmbr); 1025 if (rc != EOK) { 1026 rc = EIO; 1027 goto error; 1028 } 1029 1030 free(pmbr); 1031 return EOK; 1032 error: 1033 free(pmbr); 1034 return rc; 1035 } 1036 959 1037 /** @} 960 1038 */
Note:
See TracChangeset
for help on using the changeset viewer.