Lines Matching refs:gpt_header

290     uint8_t *gpt_header = NULL;  in gpt2_set_boot_chain()  local
302 gpt_header = (uint8_t*)malloc(blk_size); in gpt2_set_boot_chain()
303 if (!gpt_header) { in gpt2_set_boot_chain()
317 r = blk_rw(fd, 0, blk_size, gpt_header, blk_size); in gpt2_set_boot_chain()
324 GET_8_BYTES(gpt_header + PENTRIES_OFFSET) * blk_size; in gpt2_set_boot_chain()
325 pentry_size = GET_4_BYTES(gpt_header + PENTRY_SIZE_OFFSET); in gpt2_set_boot_chain()
327 GET_4_BYTES(gpt_header + PARTITION_COUNT_OFFSET) * pentry_size; in gpt2_set_boot_chain()
342 if (GET_4_BYTES(gpt_header + PARTITION_CRC_OFFSET) != crc) { in gpt2_set_boot_chain()
349 r = blk_rw(fd, 0, gpt2_header_offset, gpt_header, blk_size); in gpt2_set_boot_chain()
353 gpt_header_size = GET_4_BYTES(gpt_header + HEADER_SIZE_OFFSET); in gpt2_set_boot_chain()
355 GET_8_BYTES(gpt_header + PENTRIES_OFFSET) * blk_size; in gpt2_set_boot_chain()
365 PUT_4_BYTES(gpt_header + PARTITION_CRC_OFFSET, crc); in gpt2_set_boot_chain()
368 PUT_4_BYTES(gpt_header + HEADER_CRC_OFFSET, 0); in gpt2_set_boot_chain()
369 crc = crc32(0, gpt_header, gpt_header_size); in gpt2_set_boot_chain()
370 PUT_4_BYTES(gpt_header + HEADER_CRC_OFFSET, crc); in gpt2_set_boot_chain()
373 r = blk_rw(fd, 1, gpt2_header_offset, gpt_header, blk_size); in gpt2_set_boot_chain()
380 if(gpt_header) in gpt2_set_boot_chain()
381 free(gpt_header); in gpt2_set_boot_chain()
404 uint8_t *gpt_header = NULL; in gpt_get_state() local
415 gpt_header = (uint8_t*)malloc(blk_size); in gpt_get_state()
416 if (!gpt_header) { in gpt_get_state()
430 if (blk_rw(fd, 0, gpt_header_offset, gpt_header, blk_size)) { in gpt_get_state()
434 if (memcmp(gpt_header, GPT_SIGNATURE, sizeof(GPT_SIGNATURE))) in gpt_get_state()
436 gpt_header_size = GET_4_BYTES(gpt_header + HEADER_SIZE_OFFSET); in gpt_get_state()
438 crc = GET_4_BYTES(gpt_header + HEADER_CRC_OFFSET); in gpt_get_state()
440 PUT_4_BYTES(gpt_header + HEADER_CRC_OFFSET, 0); in gpt_get_state()
441 if (crc32(0, gpt_header, gpt_header_size) != crc) in gpt_get_state()
443 free(gpt_header); in gpt_get_state()
446 if (gpt_header) in gpt_get_state()
447 free(gpt_header); in gpt_get_state()
470 uint8_t *gpt_header = NULL; in gpt_set_state() local
479 gpt_header = (uint8_t*)malloc(blk_size); in gpt_set_state()
480 if (!gpt_header) { in gpt_set_state()
493 if (blk_rw(fd, 0, gpt_header_offset, gpt_header, blk_size)) { in gpt_set_state()
498 memcpy(gpt_header, GPT_SIGNATURE, sizeof(GPT_SIGNATURE)); in gpt_set_state()
500 *gpt_header = 0; in gpt_set_state()
506 gpt_header_size = GET_4_BYTES(gpt_header + HEADER_SIZE_OFFSET); in gpt_set_state()
509 PUT_4_BYTES(gpt_header + HEADER_CRC_OFFSET, 0); in gpt_set_state()
510 crc = crc32(0, gpt_header, gpt_header_size); in gpt_set_state()
511 PUT_4_BYTES(gpt_header + HEADER_CRC_OFFSET, crc); in gpt_set_state()
513 if (blk_rw(fd, 1, gpt_header_offset, gpt_header, blk_size)) { in gpt_set_state()
519 if(gpt_header) in gpt_set_state()
520 free(gpt_header); in gpt_set_state()
1147 static int gpt_set_header(uint8_t *gpt_header, int fd, in gpt_set_header() argument
1152 if (!gpt_header || fd < 0) { in gpt_set_header()
1173 if (blk_rw(fd, 1, gpt_header_offset, gpt_header, block_size)) { in gpt_set_header()