Adjusted new partition offset feature for multi-session and MD5 tags.
This commit is contained in:
parent
08e442a2ab
commit
1d4f26f325
@ -81,9 +81,6 @@ libinclude_HEADERS = \
|
||||
libisofs/libisofs.h
|
||||
|
||||
|
||||
# This is a now obsolete demo filter
|
||||
# libisofs/filters/xor_encrypt.c
|
||||
|
||||
## ========================================================================= ##
|
||||
|
||||
## Build demo applications
|
||||
|
@ -258,6 +258,12 @@ int ecma119_writer_compute_data_blocks(IsoImageWriter *writer)
|
||||
target->curblock += DIV_UP(path_table_size, BLOCK_SIZE);
|
||||
target->path_table_size = path_table_size;
|
||||
|
||||
if (target->md5_session_checksum) {
|
||||
/* Account for first tree checksum tag */
|
||||
target->checksum_tree_tag_pos = target->curblock;
|
||||
target->curblock++;
|
||||
}
|
||||
|
||||
if (target->partition_offset > 0) {
|
||||
/* TWINTREE: take into respect second directory tree */
|
||||
ndirs = target->ndirs;
|
||||
@ -274,12 +280,10 @@ int ecma119_writer_compute_data_blocks(IsoImageWriter *writer)
|
||||
target->curblock += DIV_UP(path_table_size, BLOCK_SIZE);
|
||||
target->partition_m_table_pos = target->curblock;
|
||||
target->curblock += DIV_UP(path_table_size, BLOCK_SIZE);
|
||||
}
|
||||
|
||||
if (target->md5_session_checksum) {
|
||||
/* Account for tree checksum tag */
|
||||
target->checksum_tree_tag_pos = target->curblock;
|
||||
target->curblock++;
|
||||
/* >>> TWINTREE: >>> For now, checksum tags are only for the
|
||||
image start and not for the partition */;
|
||||
|
||||
}
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
@ -757,9 +761,11 @@ int write_path_tables(Ecma119Image *t)
|
||||
static
|
||||
int ecma119_writer_write_dirs(IsoImageWriter *writer)
|
||||
{
|
||||
int ret;
|
||||
int ret, isofs_ca_changed = 0;
|
||||
Ecma119Image *t;
|
||||
Ecma119Node *root;
|
||||
char *value = NULL;
|
||||
size_t value_length;
|
||||
|
||||
t = writer->target;
|
||||
|
||||
@ -767,6 +773,24 @@ int ecma119_writer_write_dirs(IsoImageWriter *writer)
|
||||
/* TWINTREE: t->root -> root */
|
||||
if (t->eff_partition_offset > 0) {
|
||||
root = t->partition_root;
|
||||
|
||||
if ((t->md5_file_checksums & 1) || t->md5_session_checksum) {
|
||||
/* Take into respect the address offset in "isofs.ca" */
|
||||
ret = iso_node_lookup_attr((IsoNode *) t->image->root, "isofs.ca",
|
||||
&value_length, &value, 0);
|
||||
if (value != NULL)
|
||||
free(value);
|
||||
if (ret == 1 && value_length == 20) {
|
||||
/* "isofs.ca" does really exist and has the expected length */
|
||||
ret = iso_root_set_isofsca((IsoNode *) t->image->root,
|
||||
t->checksum_range_start - t->eff_partition_offset,
|
||||
t->checksum_array_pos - t->eff_partition_offset,
|
||||
t->checksum_idx_counter + 2, 16, "MD5", 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
isofs_ca_changed = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
root = t->root;
|
||||
}
|
||||
@ -782,12 +806,21 @@ int ecma119_writer_write_dirs(IsoImageWriter *writer)
|
||||
if (t->md5_session_checksum) {
|
||||
/* Write tree checksum tag */
|
||||
if (t->eff_partition_offset > 0) {
|
||||
/* >>> TWINTREE: >>> For now, checksums and tags are only for the
|
||||
first session */;
|
||||
/* >>> TWINTREE: >>> For now, tags are only for the
|
||||
image start and not for the partition */;
|
||||
} else {
|
||||
ret = iso_md5_write_tag(t, 3);
|
||||
}
|
||||
}
|
||||
if (isofs_ca_changed) {
|
||||
/* Restore old addresses offset in "isofs.ca" of root node */
|
||||
ret = iso_root_set_isofsca((IsoNode *) t->image->root,
|
||||
t->checksum_range_start,
|
||||
t->checksum_array_pos,
|
||||
t->checksum_idx_counter + 2, 16, "MD5", 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -875,15 +908,17 @@ static
|
||||
int pad_writer_compute_data_blocks(IsoImageWriter *writer)
|
||||
{
|
||||
Ecma119Image *target;
|
||||
uint32_t min_size;
|
||||
|
||||
if (writer == NULL) {
|
||||
return ISO_ASSERT_FAILURE;
|
||||
}
|
||||
|
||||
target = writer->target;
|
||||
if (target->curblock < 32) {
|
||||
target->pad_blocks = 32 - target->curblock;
|
||||
target->curblock = 32;
|
||||
/* TWINTREE: */
|
||||
min_size = 32 + target->partition_offset;
|
||||
if (target->curblock < min_size) {
|
||||
target->pad_blocks = min_size - target->curblock;
|
||||
target->curblock = min_size;
|
||||
}
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
@ -1263,7 +1263,7 @@ int iso_write_opts_set_iso1999(IsoWriteOpts *opts, int enable);
|
||||
* Inode numbers get written as "file serial number" with PX entries as of
|
||||
* RRIP-1.12. They may mark families of hardlinks.
|
||||
* RRIP-1.10 prescribes a PX entry without file serial number. If not overriden
|
||||
* by iso_write_opts_set_rrip_1_10_px_ino() there will be no file serial
|
||||
* by iso_write_opts_set_rrip_1_10_px_ino() there will be no file serial number
|
||||
* written into RRIP-1.10 images.
|
||||
*
|
||||
* Inode number generation does not affect IsoNode objects which imported their
|
||||
|
@ -147,6 +147,8 @@ int make_grub_msdos_label(uint32_t img_blocks, uint8_t *buf, int flag)
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0= zeroize partitions entries 2, 3, 4
|
||||
*/
|
||||
static
|
||||
int iso_offset_partition_start(uint32_t img_blocks, uint32_t partition_offset,
|
||||
int sph_in, int hpc_in, uint8_t *buf, int flag)
|
||||
@ -166,6 +168,9 @@ int iso_offset_partition_start(uint32_t img_blocks, uint32_t partition_offset,
|
||||
&end_lba, &end_sec, &end_head, &end_cyl, 0);
|
||||
wpt = buf + 446;
|
||||
|
||||
/* Let pass only legal bootability values */
|
||||
if (*wpt != 0 && *wpt != 0x80)
|
||||
(*wpt) = 0;
|
||||
wpt++;
|
||||
|
||||
/* C/H/S of the start */
|
||||
@ -190,12 +195,15 @@ int iso_offset_partition_start(uint32_t img_blocks, uint32_t partition_offset,
|
||||
for (i = 0; i < 4; i++)
|
||||
*(wpt++) = (end_lba >> (8 * i)) & 0xff;
|
||||
|
||||
/* at 446-462 */
|
||||
if (wpt - buf != 462) {
|
||||
fprintf(stderr,
|
||||
"libisofs: program error in iso_offset_partition_start: \"assert 462\"\n");
|
||||
return ISO_ASSERT_FAILURE;
|
||||
}
|
||||
|
||||
if (flag & 1) /* zeroize the other partition entries */
|
||||
memset(wpt, 0, 3 * 16);
|
||||
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
@ -265,7 +273,7 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
|
||||
img_blocks = t->curblock; /* value might be altered */
|
||||
ret = iso_offset_partition_start(img_blocks, t->partition_offset,
|
||||
t->partition_secs_per_head,
|
||||
t->partition_heads_per_cyl, buf, 0);
|
||||
t->partition_heads_per_cyl, buf, 1);
|
||||
if (ret != ISO_SUCCESS) /* error should never happen */
|
||||
return ISO_ASSERT_FAILURE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user