Changeset View
Changeset View
Standalone View
Standalone View
head/usr.bin/mkimg/gpt.c
Show First 20 Lines • Show All 253 Lines • ▼ Show 20 Lines | gpt_write(lba_t imgsz, void *bootcode) | ||||
memset(hdr, 0, secsz); | memset(hdr, 0, secsz); | ||||
memcpy(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)); | memcpy(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)); | ||||
le32enc(&hdr->hdr_revision, GPT_HDR_REVISION); | le32enc(&hdr->hdr_revision, GPT_HDR_REVISION); | ||||
le32enc(&hdr->hdr_size, offsetof(struct gpt_hdr, padding)); | le32enc(&hdr->hdr_size, offsetof(struct gpt_hdr, padding)); | ||||
le64enc(&hdr->hdr_lba_start, 2 + tblsz); | le64enc(&hdr->hdr_lba_start, 2 + tblsz); | ||||
le64enc(&hdr->hdr_lba_end, imgsz - tblsz - 2); | le64enc(&hdr->hdr_lba_end, imgsz - tblsz - 2); | ||||
mkimg_uuid(&uuid); | mkimg_uuid(&uuid); | ||||
mkimg_uuid_enc(&hdr->hdr_uuid, &uuid); | mkimg_uuid_enc(&hdr->hdr_uuid, &uuid); | ||||
le32enc(&hdr->hdr_entries, nparts); | le32enc(&hdr->hdr_entries, tblsz * secsz / sizeof(struct gpt_ent)); | ||||
le32enc(&hdr->hdr_entsz, sizeof(struct gpt_ent)); | le32enc(&hdr->hdr_entsz, sizeof(struct gpt_ent)); | ||||
crc = crc32(tbl, nparts * sizeof(struct gpt_ent)); | crc = crc32(tbl, tblsz * secsz); | ||||
le32enc(&hdr->hdr_crc_table, crc); | le32enc(&hdr->hdr_crc_table, crc); | ||||
error = gpt_write_hdr(hdr, 1, imgsz - 1, 2); | error = gpt_write_hdr(hdr, 1, imgsz - 1, 2); | ||||
if (!error) | if (!error) | ||||
error = gpt_write_hdr(hdr, imgsz - 1, 1, imgsz - tblsz - 1); | error = gpt_write_hdr(hdr, imgsz - 1, 1, imgsz - tblsz - 1); | ||||
free(hdr); | free(hdr); | ||||
out: | out: | ||||
free(tbl); | free(tbl); | ||||
Show All 16 Lines |