"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libisofs/system_area.c" between
xorriso-1.5.2.tar.gz and xorriso-1.5.4.tar.gz

About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.

system_area.c  (xorriso-1.5.2):system_area.c  (xorriso-1.5.4)
skipping to change at line 548 skipping to change at line 548
name_field = (char *) (buf + (72 + 16 * idx)); name_field = (char *) (buf + (72 + 16 * idx));
strncpy(name_field, namept, 8); strncpy(name_field, namept, 8);
file_lba = ecma_node->info.file->sections[0].block; file_lba = ecma_node->info.file->sections[0].block;
iso_msb(buf + (72 + 16 * idx) + 8, file_lba * 4, 4); iso_msb(buf + (72 + 16 * idx) + 8, file_lba * 4, 4);
stream = iso_file_get_stream((IsoFile *) node); stream = iso_file_get_stream((IsoFile *) node);
file_size = iso_stream_get_size(stream); file_size = iso_stream_get_size(stream);
/* Shall i really round up to 2048 ? Steve says yes.*/ /* genisoimage rounds up to full multiples of 2048.
iso_msb(buf + (72 + 16 * idx) + 12, libisofs did this too until 2020, but the arcload mips boot loader
((file_size + 2047) / 2048 ) * 2048, 4); throws error if the rounded size is stored here.
So now the exact bytecount gets stored.
*/
iso_msb(buf + (72 + 16 * idx) + 12, file_size, 4);
} }
/* 408 - 411 | part_blks | Number of 512 byte blocks in partition */ /* 408 - 411 | part_blks | Number of 512 byte blocks in partition */
blocks = (image_size + bps - 1) / bps; blocks = (image_size + bps - 1) / bps;
iso_msb(buf + 408, blocks, 4); iso_msb(buf + 408, blocks, 4);
/* 416 - 419 | 0 | Partition is volume header */ /* 416 - 419 | 0 | Partition is volume header */
iso_msb(buf + 416, 0, 4); iso_msb(buf + 416, 0, 4);
/* 432 - 435 | part_blks | Number of 512 byte blocks in partition */ /* 432 - 435 | part_blks | Number of 512 byte blocks in partition */
skipping to change at line 775 skipping to change at line 778
} }
return ISO_SUCCESS; return ISO_SUCCESS;
} }
/** /**
* Write SUN Disk Label with ISO in partition 1 and unused 2 to 8 * Write SUN Disk Label with ISO in partition 1 and unused 2 to 8
*/ */
static int make_sun_disk_label(Ecma119Image *t, uint8_t *buf, int flag) static int make_sun_disk_label(Ecma119Image *t, uint8_t *buf, int flag)
{ {
int ret, i; int ret, i, l;
uint64_t blk; uint64_t blk;
/* Bytes 512 to 32767 may come from image or external file */ /* Bytes 512 to 32767 may come from image or external file */
memset(buf, 0, 512); memset(buf, 0, 512);
/* 0 - 127 | label | ASCII Label */ /* 0 - 127 | label | ASCII Label */
if (t->opts->ascii_disc_label[0]) if (t->opts->ascii_disc_label[0]) {
strncpy((char *) buf, t->opts->ascii_disc_label, 128); for (l = 0; l < 128 && t->opts->ascii_disc_label[l] != 0; l++);
else if (l > 0)
memcpy((char *) buf, t->opts->ascii_disc_label, l);
} else {
strcpy((char *) buf, strcpy((char *) buf,
"CD-ROM Disc with Sun sparc boot created by libisofs"); "CD-ROM Disc with Sun sparc boot created by libisofs");
}
/* 128 - 131 | 1 | Layout version */ /* 128 - 131 | 1 | Layout version */
iso_msb(buf + 128, 1, 4); iso_msb(buf + 128, 1, 4);
/* 140 - 141 | 8 | Number of partitions */ /* 140 - 141 | 8 | Number of partitions */
iso_msb(buf + 140, 8, 2); iso_msb(buf + 140, 8, 2);
/* 188 - 191 | 0x600ddeee | vtoc sanity */ /* 188 - 191 | 0x600ddeee | vtoc sanity */
iso_msb(buf + 188, 0x600ddeee, 4); iso_msb(buf + 188, 0x600ddeee, 4);
skipping to change at line 1018 skipping to change at line 1024
} }
/* Convenience frontend for iso_register_apm_entry(). /* Convenience frontend for iso_register_apm_entry().
name and type are 0-terminated strings. name and type are 0-terminated strings.
*/ */
int iso_quick_apm_entry(struct iso_apm_partition_request **req_array, int iso_quick_apm_entry(struct iso_apm_partition_request **req_array,
int *apm_req_count, int *apm_req_count,
uint32_t start_block, uint32_t block_count, uint32_t start_block, uint32_t block_count,
char *name, char *type) char *name, char *type)
{ {
int ret; int ret, l;
struct iso_apm_partition_request *entry; struct iso_apm_partition_request *entry;
entry = calloc(1, sizeof(struct iso_apm_partition_request)); entry = calloc(1, sizeof(struct iso_apm_partition_request));
if (entry == NULL) if (entry == NULL)
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
entry->start_block = start_block; entry->start_block = start_block;
entry->block_count = block_count; entry->block_count = block_count;
strncpy((char *) entry->name, name, 32); for (l = 0; l < 32 && name[l] != 0; l++);
strncpy((char *) entry->type, type, 32); if (l > 0)
memcpy((char *) entry->name, name, l);
for (l = 0; l < 32 && type[l] != 0; l++);
if (l > 0)
memcpy((char *) entry->type, type, l);
entry->req_status = 0; entry->req_status = 0;
ret = iso_register_apm_entry(req_array, apm_req_count, entry, 0); ret = iso_register_apm_entry(req_array, apm_req_count, entry, 0);
free(entry); free(entry);
return ret; return ret;
} }
static int iso_find_gpt_entry(struct iso_gpt_partition_request **req_array, static int iso_find_gpt_entry(struct iso_gpt_partition_request **req_array,
int gpt_req_count, int gpt_req_count,
uint64_t start_block, uint64_t block_count, uint64_t start_block, uint64_t block_count,
int *index, int flag) int *index, int flag)
skipping to change at line 1370 skipping to change at line 1380
} }
if (t->apm_req_flags & 4) if (t->apm_req_flags & 4)
block_fac = 2048 / t->opts->apm_block_size; block_fac = 2048 / t->opts->apm_block_size;
if (!(t->apm_req_flags & 2)) { if (!(t->apm_req_flags & 2)) {
/* Gaps have been filled. Care for the final one */ /* Gaps have been filled. Care for the final one */
/* Adjust last partition to img_size. This size was not known when the /* Adjust last partition to img_size. This size was not known when the
number of APM partitions was determined. number of APM partitions was determined.
*/ */
t->apm_req[t->apm_req_count - 1]->block_count = if (img_blocks * block_fac <
img_blocks * block_fac - t->apm_req[t->apm_req_count - 1]->start_block; t->apm_req[t->apm_req_count - 1]->start_block)
t->apm_req[t->apm_req_count - 1]->block_count = 0;
else
t->apm_req[t->apm_req_count - 1]->block_count =
img_blocks * block_fac -
t->apm_req[t->apm_req_count - 1]->start_block;
/* If it is still empty, remove it */ /* If it is still empty, remove it */
if(t->apm_req[t->apm_req_count - 1]->block_count == 0) { if(t->apm_req[t->apm_req_count - 1]->block_count == 0) {
free(t->apm_req[t->apm_req_count - 1]); free(t->apm_req[t->apm_req_count - 1]);
t->apm_req_count--; t->apm_req_count--;
} }
} }
/* If block size is larger than 512, then not all 63 entries will fit */ /* If block size is larger than 512, then not all 63 entries will fit */
if ((t->apm_req_count + 1) * t->opts->apm_block_size > 32768) if ((t->apm_req_count + 1) * t->opts->apm_block_size > 32768)
return ISO_BOOT_TOO_MANY_APM; return ISO_BOOT_TOO_MANY_APM;
skipping to change at line 1827 skipping to change at line 1842
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (buf[446 + 16 * i + 4] != 0xef) { if (buf[446 + 16 * i + 4] != 0xef) {
buf[446 + 16 * i] |= 0x80; buf[446 + 16 * i] |= 0x80;
return; return;
} }
} }
i = 3; i = 3;
buf[446 + 16 * i] |= 0x80; buf[446 + 16 * i] |= 0x80;
} }
int iso_write_system_area(Ecma119Image *t, uint8_t *buf) /* @param flag
bit0= t->opts->ms_block is not counted in t->total_size
*/
int iso_write_system_area(Ecma119Image *t, uint8_t *buf, int flag)
{ {
int ret, int_img_blocks, sa_type, i, will_append = 0, do_isohybrid = 0; int ret, int_img_blocks, sa_type, i, will_append = 0, do_isohybrid = 0;
int first_partition = 1, last_partition = 4, apm_flag, part_type = 0; int first_partition = 1, last_partition = 4, apm_flag, part_type = 0;
int gpt_count = 0, gpt_idx[128], apm_count = 0, no_boot_mbr = 0; int gpt_count = 0, gpt_idx[128], apm_count = 0, no_boot_mbr = 0;
int offset_flag = 0, risk_of_ee = 0; int offset_flag = 0, risk_of_ee = 0;
uint32_t img_blocks, gpt_blocks, mbrp1_blocks, pml_blocks; uint32_t img_blocks, gpt_blocks, mbrp1_blocks, pml_blocks;
uint64_t blk; uint64_t blk;
uint8_t *wpt; uint8_t *wpt;
if ((t == NULL) || (buf == NULL)) { if ((t == NULL) || (buf == NULL)) {
skipping to change at line 1936 skipping to change at line 1954
"Cannot set up MBR partition table"); "Cannot set up MBR partition table");
return ret; return ret;
} }
if (t->mbr_req_count > 0) { if (t->mbr_req_count > 0) {
if (sa_type != 0) if (sa_type != 0)
return ISO_NON_MBR_SYS_AREA; return ISO_NON_MBR_SYS_AREA;
risk_of_ee = 1; risk_of_ee = 1;
} }
if (t->gpt_backup_outside) if (t->gpt_backup_outside)
gpt_blocks = t->total_size / BLOCK_SIZE + t->opts->ms_block; gpt_blocks = t->total_size / BLOCK_SIZE +
(flag & 1) * t->opts->ms_block;
else else
gpt_blocks = img_blocks; gpt_blocks = img_blocks;
ret = iso_write_gpt(t, gpt_blocks, buf); ret = iso_write_gpt(t, gpt_blocks, buf);
if (ret < 0) { if (ret < 0) {
iso_msg_submit(t->image->id, ret, 0, "Cannot set up GPT"); iso_msg_submit(t->image->id, ret, 0, "Cannot set up GPT");
return ret; return ret;
} }
if (sa_type == 0 && (t->system_area_options & 1)) { if (sa_type == 0 && (t->system_area_options & 1)) {
if (t->mbr_req_count == 0){ if (t->mbr_req_count == 0){
skipping to change at line 2042 skipping to change at line 2061
ret = make_grub_msdos_label(img_blocks, t->partition_secs_per_head, ret = make_grub_msdos_label(img_blocks, t->partition_secs_per_head,
t->partition_heads_per_cyl, t->partition_heads_per_cyl,
(uint8_t) part_type, buf, 2); (uint8_t) part_type, buf, 2);
if (ret != ISO_SUCCESS) /* error should never happen */ if (ret != ISO_SUCCESS) /* error should never happen */
return ISO_ASSERT_FAILURE; return ISO_ASSERT_FAILURE;
risk_of_ee = 1; risk_of_ee = 1;
if (t->opts->appended_as_gpt && t->have_appended_partitions) { if (t->opts->appended_as_gpt && t->have_appended_partitions) {
/* >>> ??? Do this in any case of t->gpt_req_count > ? */; /* >>> ??? Do this in any case of t->gpt_req_count > ? */;
/* Re-write partion entry 1 : protective MBR for GPT */ /* Re-write partition entry 1 : protective MBR for GPT */
part_type = 0xee; part_type = 0xee;
risk_of_ee = 1; risk_of_ee = 1;
ret = write_mbr_partition_entry(1, part_type, ret = write_mbr_partition_entry(1, part_type,
(uint64_t) 1, ((uint64_t) gpt_blocks) * 4 - 1, (uint64_t) 1, ((uint64_t) gpt_blocks) * 4 - 1,
t->partition_secs_per_head, t->partition_heads_per_cyl, t->partition_secs_per_head, t->partition_heads_per_cyl,
buf, 2); buf, 2);
if (ret < 0) if (ret < 0)
return ret; return ret;
} else if (t->opts->partition_offset == 0) { } else if (t->opts->partition_offset == 0) {
/* Re-write partion entry 1 : start at 0, type Linux */ /* Re-write partition entry 1 : start at 0, type Linux */
blk = ((uint64_t) img_blocks) * 4 - t->post_iso_part_pad / 512; blk = ((uint64_t) img_blocks) * 4 - t->post_iso_part_pad / 512;
part_type = 0x83; part_type = 0x83;
if (t->opts->iso_mbr_part_type >= 0 && if (t->opts->iso_mbr_part_type >= 0 &&
t->opts->iso_mbr_part_type <= 255) t->opts->iso_mbr_part_type <= 255)
part_type= t->opts->iso_mbr_part_type; part_type= t->opts->iso_mbr_part_type;
ret = write_mbr_partition_entry(1, part_type, (uint64_t) 0, blk, ret = write_mbr_partition_entry(1, part_type, (uint64_t) 0, blk,
t->partition_secs_per_head, t->partition_heads_per_cyl, t->partition_secs_per_head, t->partition_heads_per_cyl,
buf, 2); buf, 2);
if (ret < 0) if (ret < 0)
return ret; return ret;
skipping to change at line 2098 skipping to change at line 2117
img_blocks = t->curblock; /* value might have been altered */ img_blocks = t->curblock; /* value might have been altered */
#else #else
/* A change of t->curblock does not matter in this case */ /* A change of t->curblock does not matter in this case */
#endif #endif
if (part_type == 0xee && t->gpt_req_count > 0) { if (part_type == 0xee && t->gpt_req_count > 0) {
mbrp1_blocks = t->total_size / BLOCK_SIZE + t->opts->ms_block; mbrp1_blocks = t->total_size / BLOCK_SIZE +
(flag & 1) * t->opts->ms_block;
offset_flag |= 2 | 1; /* protective MBR, no other partitions */ offset_flag |= 2 | 1; /* protective MBR, no other partitions */
} else { } else {
mbrp1_blocks = img_blocks; mbrp1_blocks = img_blocks;
} }
ret = iso_offset_partition_start(mbrp1_blocks, t->post_iso_part_pad, ret = iso_offset_partition_start(mbrp1_blocks, t->post_iso_part_pad,
t->opts->partition_offset, t->opts->partition_offset,
t->partition_secs_per_head, t->partition_secs_per_head,
t->partition_heads_per_cyl, buf, t->partition_heads_per_cyl, buf,
offset_flag); offset_flag);
if (ret != ISO_SUCCESS) /* error should never happen */ if (ret != ISO_SUCCESS) /* error should never happen */
return ISO_ASSERT_FAILURE; return ISO_ASSERT_FAILURE;
} }
/* This possibly overwrites the non-mbr_req partition table entries /* This possibly overwrites the non-mbr_req partition table entries
made so far. Overwriting those from t->mbr_req is not allowed. made so far. Overwriting those from t->mbr_req is not allowed.
*/ */
if (sa_type == 3 || !t->opts->appended_as_gpt) { if (sa_type == 3 ||
!(t->opts->appended_as_gpt || t->opts->appended_as_apm)) {
for (i = first_partition - 1; i <= last_partition - 1; i++) { for (i = first_partition - 1; i <= last_partition - 1; i++) {
if (t->opts->appended_partitions[i] == NULL) if (t->opts->appended_partitions[i] == NULL)
continue; continue;
if (i < t->mbr_req_count) if (i < t->mbr_req_count)
return ISO_BOOT_MBR_COLLISION; return ISO_BOOT_MBR_COLLISION;
if (sa_type == 3) { if (sa_type == 3) {
ret = write_sun_partition_entry(i + 1, ret = write_sun_partition_entry(i + 1,
t->opts->appended_partitions, t->opts->appended_partitions,
t->appended_part_start, t->appended_part_size, t->appended_part_start, t->appended_part_size,
ISO_SUN_CYL_SIZE, ISO_SUN_CYL_SIZE,
skipping to change at line 2593 skipping to change at line 2614
int assess_appended_gpt(Ecma119Image *t, int flag) int assess_appended_gpt(Ecma119Image *t, int flag)
{ {
static uint8_t basic_data_uuid[16] = { static uint8_t basic_data_uuid[16] = {
0xa2, 0xa0, 0xd0, 0xeb, 0xe5, 0xb9, 0x33, 0x44, 0xa2, 0xa0, 0xd0, 0xeb, 0xe5, 0xb9, 0x33, 0x44,
0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7
}; };
static uint8_t efi_sys_uuid[16] = { static uint8_t efi_sys_uuid[16] = {
0x28, 0x73, 0x2a, 0xc1, 0x1f, 0xf8, 0xd2, 0x11, 0x28, 0x73, 0x2a, 0xc1, 0x1f, 0xf8, 0xd2, 0x11,
0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b 0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b
}; };
static uint8_t hfs_plus_uuid[16] = {
0x00, 0x53, 0x46, 0x48, 0x00, 0x00, 0xaa, 0x11,
0xaa, 0x11, 0x00, 0x30, 0x65, 0x43, 0xec, 0xac
};
static uint8_t zero_uuid[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; static uint8_t zero_uuid[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int i, ret, do_apm = 0, do_gpt = 0, index, already_in_gpt = 0; int i, ret, do_apm = 0, do_gpt = 0, index, already_in_gpt = 0;
uint8_t gpt_name[72], *type_uuid; uint8_t gpt_name[72], *type_uuid;
char apm_type[33];
#ifndef Libisofs_appended_partitions_inlinE #ifndef Libisofs_appended_partitions_inlinE
if (!t->gpt_backup_outside) if (!t->gpt_backup_outside)
return 2; return 2;
#endif #endif
if ((t->apm_req_count > 0 && t->opts->part_like_isohybrid) || if ((t->apm_req_count > 0 && t->opts->part_like_isohybrid) ||
(t->have_appended_partitions && t->opts->appended_as_apm)) (t->have_appended_partitions && t->opts->appended_as_apm))
do_apm = 1; do_apm = 1;
if (t->gpt_req_count > 0 || if (t->gpt_req_count > 0 ||
skipping to change at line 2619 skipping to change at line 2645
if (do_apm == 0 && do_gpt == 0) if (do_apm == 0 && do_gpt == 0)
return 2; return 2;
/* Represent appended partitions */ /* Represent appended partitions */
for (i = 0; i <= 3; i++) { for (i = 0; i <= 3; i++) {
if (t->opts->appended_partitions[i] == NULL) if (t->opts->appended_partitions[i] == NULL)
continue; continue;
if (do_apm) { if (do_apm) {
memset(gpt_name, 0, 32); memset(gpt_name, 0, 32);
sprintf((char *) gpt_name, "Appended%d", i + 1); sprintf((char *) gpt_name, "Appended%d", i + 1);
strcpy(apm_type, "Data");
if (t->opts->appended_part_gpt_flags[i] & 1) {
if (memcmp(t->opts->appended_part_type_guids[i], hfs_plus_uuid,
16) == 0)
strcpy(apm_type, "Apple_HFS");
}
ret = iso_quick_apm_entry(t->apm_req, &(t->apm_req_count), ret = iso_quick_apm_entry(t->apm_req, &(t->apm_req_count),
t->appended_part_start[i] * t->hfsp_iso_block_fac, t->appended_part_start[i] * t->hfsp_iso_block_fac,
t->appended_part_size[i] * t->hfsp_iso_block_fac, t->appended_part_size[i] * t->hfsp_iso_block_fac,
(char *) gpt_name, "Data"); (char *) gpt_name, apm_type);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
if (do_gpt) if (do_gpt)
already_in_gpt = iso_find_gpt_entry(t->gpt_req, t->gpt_req_count, already_in_gpt = iso_find_gpt_entry(t->gpt_req, t->gpt_req_count,
((uint64_t) t->appended_part_start[i]) * 4, ((uint64_t) t->appended_part_start[i]) * 4,
((uint64_t) t->appended_part_size[i]) * 4, ((uint64_t) t->appended_part_size[i]) * 4,
&index, 0); &index, 0);
if (do_gpt && !already_in_gpt) { if (do_gpt && !already_in_gpt) {
memset(gpt_name, 0, 72); memset(gpt_name, 0, 72);
skipping to change at line 2704 skipping to change at line 2736
(!(t->system_area_options & 2))) { (!(t->system_area_options & 2))) {
ret = assess_isohybrid_gpt_apm(t, &gpt_count, gpt_idx, &apm_count, ret = assess_isohybrid_gpt_apm(t, &gpt_count, gpt_idx, &apm_count,
1 | ((t->apm_req_count > 0) << 1) | 4); 1 | ((t->apm_req_count > 0) << 1) | 4);
if (ret <= 0) if (ret <= 0)
return ret; return ret;
t->apm_req_flags |= 2; /* Do not fill APM gaps, t->apm_req_flags |= 2; /* Do not fill APM gaps,
do not adjust final APM partition size */ do not adjust final APM partition size */
} }
/* Assess impact of appended partitions on GPT */
ret = assess_appended_gpt(t, 0);
if (ret < 0)
return ret;
/* Rectify APM requests early in order to learn the size of GPT. /* Rectify APM requests early in order to learn the size of GPT.
iso_write_apm() relies on this being already done here. iso_write_apm() relies on this being already done here.
So perform even if no GPT is required. So perform even if no GPT is required.
*/ */
ret = rectify_apm(t); ret = rectify_apm(t);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Assess impact of appended partitions on GPT */
ret = assess_appended_gpt(t, 0);
#ifdef NIX #ifdef NIX
/* Disabled */ /* Disabled */
/* <<< ts B20526 : Dummy mock-up */ /* <<< ts B20526 : Dummy mock-up */
if (t->gpt_req_count <= 0) { if (t->gpt_req_count <= 0) {
/* <<< ??? Move to system_area.h and publish as macro ? /* <<< ??? Move to system_area.h and publish as macro ?
Or to make_isohybrid_mbr.c ? Or to make_isohybrid_mbr.c ?
*/ */
static uint8_t hfs_uuid[16] = { static uint8_t hfs_uuid[16] = {
 End of changes. 19 change blocks. 
22 lines changed or deleted 56 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)