Changeset 8f6c7785 in mainline for uspace/lib/gpt/libgpt.c
- Timestamp:
- 2013-04-26T02:55:32Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 700f89e
- Parents:
- d617050
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gpt/libgpt.c
rd617050 r8f6c7785 67 67 int rc; 68 68 size_t b_size; 69 69 70 rc = block_init(EXCHANGE_ATOMIC, dev_handle, 512); 71 if (rc != EOK) 72 return NULL; 73 70 74 rc = block_get_bsize(dev_handle, &b_size); 71 75 if (rc != EOK) { … … 73 77 return NULL; 74 78 } 75 79 76 80 gpt_t * gpt = malloc(sizeof(gpt_t)); 77 81 if (gpt == NULL) { … … 80 84 } 81 85 82 gpt->raw_data = malloc(b_size); // We might need only sizeof(gpt_header_t),86 gpt->raw_data = malloc(b_size); // We might need only sizeof(gpt_header_t), 83 87 if (gpt == NULL) { // but we should follow specs and have 84 88 free(gpt); // zeroes through all the rest of the block … … 86 90 return NULL; 87 91 } 88 89 92 93 90 94 rc = load_and_check_header(dev_handle, GPT_HDR_BA, b_size, gpt->raw_data); 91 95 if (rc == EBADCHECKSUM || rc == EINVAL) { … … 103 107 } 104 108 } 105 109 106 110 gpt->device = dev_handle; 107 111 block_fini(dev_handle); 108 112 return gpt; 109 113 110 114 fail: 115 block_fini(dev_handle); 111 116 gpt_free_gpt(gpt); 112 117 return NULL; … … 130 135 uint32_t_le2host(gpt->raw_data->header_size)); 131 136 137 rc = block_init(EXCHANGE_ATOMIC, dev_handle, b_size); 138 if (rc != EOK) 139 return rc; 140 132 141 rc = block_get_bsize(dev_handle, &b_size); 133 if (rc != EOK)134 return rc;135 136 rc = block_init(EXCHANGE_ATOMIC, dev_handle, b_size);137 142 if (rc != EOK) 138 143 return rc; … … 252 257 gpt->raw_data->pe_array_crc32 = compute_crc32((uint8_t *) parts->part_array, parts->fill * gpt->raw_data->entry_size); 253 258 259 rc = block_init(EXCHANGE_ATOMIC, dev_handle, b_size); 260 if (rc != EOK) 261 return rc; 262 254 263 rc = block_get_bsize(dev_handle, &b_size); 255 if (rc != EOK)256 return rc;257 258 rc = block_init(EXCHANGE_ATOMIC, dev_handle, b_size);259 264 if (rc != EOK) 260 265 return rc; … … 473 478 int rc; 474 479 475 rc = block_init(EXCHANGE_ATOMIC, dev_handle, b_size);476 if (rc != EOK)477 return rc;478 479 480 rc = block_read_direct(dev_handle, addr, GPT_HDR_BS, header); 480 block_fini(dev_handle); 481 if (rc != EOK) 482 return rc; 483 481 if (rc != EOK) 482 return rc; 484 483 485 484 unsigned int i;
Note:
See TracChangeset
for help on using the changeset viewer.