gpt.c (266176) | gpt.c (268236) |
---|---|
1/*- 2 * Copyright (c) 2014 Juniper Networks, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2014 Juniper Networks, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/usr.bin/mkimg/gpt.c 266176 2014-05-15 19:19:57Z marcel $"); | 28__FBSDID("$FreeBSD: head/usr.bin/mkimg/gpt.c 268236 2014-07-03 20:31:43Z marcel $"); |
29 30#include <sys/types.h> 31#include <sys/diskmbr.h> 32#include <sys/endian.h> 33#include <sys/errno.h> 34#include <sys/gpt.h> 35#include <stddef.h> 36#include <stdint.h> --- 169 unchanged lines hidden (view full) --- 206 207 tbl = calloc(tblsz, secsz); 208 if (tbl == NULL) 209 return (NULL); 210 211 STAILQ_FOREACH(part, &partlist, link) { 212 ent = tbl + part->index; 213 gpt_uuid_enc(&ent->ent_type, ALIAS_TYPE2PTR(part->type)); | 29 30#include <sys/types.h> 31#include <sys/diskmbr.h> 32#include <sys/endian.h> 33#include <sys/errno.h> 34#include <sys/gpt.h> 35#include <stddef.h> 36#include <stdint.h> --- 169 unchanged lines hidden (view full) --- 206 207 tbl = calloc(tblsz, secsz); 208 if (tbl == NULL) 209 return (NULL); 210 211 STAILQ_FOREACH(part, &partlist, link) { 212 ent = tbl + part->index; 213 gpt_uuid_enc(&ent->ent_type, ALIAS_TYPE2PTR(part->type)); |
214 uuidgen(&uuid, 1); | 214 mkimg_uuid(&uuid); |
215 gpt_uuid_enc(&ent->ent_uuid, &uuid); 216 le64enc(&ent->ent_lba_start, part->block); 217 le64enc(&ent->ent_lba_end, part->block + part->size - 1); 218 if (part->label != NULL) { 219 idx = 0; 220 while ((c = part->label[idx]) != '\0') { 221 le16enc(ent->ent_name + idx, c); 222 idx++; --- 51 unchanged lines hidden (view full) --- 274 goto out; 275 } 276 memset(hdr, 0, secsz); 277 memcpy(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)); 278 le32enc(&hdr->hdr_revision, GPT_HDR_REVISION); 279 le32enc(&hdr->hdr_size, offsetof(struct gpt_hdr, padding)); 280 le64enc(&hdr->hdr_lba_start, 2 + tblsz); 281 le64enc(&hdr->hdr_lba_end, imgsz - tblsz - 2); | 215 gpt_uuid_enc(&ent->ent_uuid, &uuid); 216 le64enc(&ent->ent_lba_start, part->block); 217 le64enc(&ent->ent_lba_end, part->block + part->size - 1); 218 if (part->label != NULL) { 219 idx = 0; 220 while ((c = part->label[idx]) != '\0') { 221 le16enc(ent->ent_name + idx, c); 222 idx++; --- 51 unchanged lines hidden (view full) --- 274 goto out; 275 } 276 memset(hdr, 0, secsz); 277 memcpy(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)); 278 le32enc(&hdr->hdr_revision, GPT_HDR_REVISION); 279 le32enc(&hdr->hdr_size, offsetof(struct gpt_hdr, padding)); 280 le64enc(&hdr->hdr_lba_start, 2 + tblsz); 281 le64enc(&hdr->hdr_lba_end, imgsz - tblsz - 2); |
282 uuidgen(&uuid, 1); | 282 mkimg_uuid(&uuid); |
283 gpt_uuid_enc(&hdr->hdr_uuid, &uuid); 284 le32enc(&hdr->hdr_entries, nparts); 285 le32enc(&hdr->hdr_entsz, sizeof(struct gpt_ent)); 286 crc = crc32(tbl, nparts * sizeof(struct gpt_ent)); 287 le32enc(&hdr->hdr_crc_table, crc); 288 error = gpt_write_hdr(hdr, 1, imgsz - 1, 2); 289 if (!error) 290 error = gpt_write_hdr(hdr, imgsz - 1, 1, imgsz - tblsz - 1); --- 20 unchanged lines hidden --- | 283 gpt_uuid_enc(&hdr->hdr_uuid, &uuid); 284 le32enc(&hdr->hdr_entries, nparts); 285 le32enc(&hdr->hdr_entsz, sizeof(struct gpt_ent)); 286 crc = crc32(tbl, nparts * sizeof(struct gpt_ent)); 287 le32enc(&hdr->hdr_crc_table, crc); 288 error = gpt_write_hdr(hdr, 1, imgsz - 1, 2); 289 if (!error) 290 error = gpt_write_hdr(hdr, imgsz - 1, 1, imgsz - tblsz - 1); --- 20 unchanged lines hidden --- |