Compare commits
2 Commits
98aea0c18a
...
9e389186f7
Author | SHA1 | Date |
---|---|---|
Thomas Schmitt | 9e389186f7 | |
Thomas Schmitt | 7d248c46e1 |
|
@ -3800,17 +3800,18 @@ void iso_get_hc_sh(uint8_t *matches, uint32_t iso_image_size,
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int iso_analyze_mbr_ptable(IsoImage *image, int flag)
|
int iso_analyze_mbr_ptable(IsoImage *image, IsoDataSource *src, int flag)
|
||||||
{
|
{
|
||||||
int i, j, ret, cyl_align_mode, part_after_image = 0;
|
int i, j, ret, cyl_align_mode, part_after_image = 0, ignore_part;
|
||||||
uint32_t start_h, start_s, start_c, end_h, end_s, end_c, sph = 0, hpc = 0;
|
uint32_t start_h, start_s, start_c, end_h, end_s, end_c, sph = 0, hpc = 0;
|
||||||
uint32_t start_lba, num_blocks, end_chs_lba, image_size, lba, cyl_size;
|
uint32_t start_lba, num_blocks, end_chs_lba, image_size, lba, cyl_size;
|
||||||
uint8_t *data, pstatus, ptype, *hc_sh = NULL;
|
uint8_t *data, pstatus, ptype, *hc_sh = NULL, *buf = NULL;
|
||||||
struct iso_imported_sys_area *sai;
|
struct iso_imported_sys_area *sai;
|
||||||
|
|
||||||
/* Bitmap for finding head_per_cyl and sectors_per_head. */
|
/* Bitmap for finding head_per_cyl and sectors_per_head. */
|
||||||
LIBISO_ALLOC_MEM(hc_sh, uint8_t, 32 * 63);
|
LIBISO_ALLOC_MEM(hc_sh, uint8_t, 32 * 63);
|
||||||
memset(hc_sh, 0xff, 32 * 63);
|
memset(hc_sh, 0xff, 32 * 63);
|
||||||
|
LIBISO_ALLOC_MEM(buf, uint8_t, 2048);
|
||||||
|
|
||||||
sai = image->imported_sa_info;
|
sai = image->imported_sa_info;
|
||||||
image_size = sai->image_size;
|
image_size = sai->image_size;
|
||||||
|
@ -3833,6 +3834,30 @@ int iso_analyze_mbr_ptable(IsoImage *image, int flag)
|
||||||
num_blocks = iso_read_lsb(data + 12, 4);
|
num_blocks = iso_read_lsb(data + 12, 4);
|
||||||
if (num_blocks <= 0)
|
if (num_blocks <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* Check whether the partition fits into size of medium */
|
||||||
|
ignore_part= ((off_t) num_blocks + (off_t) start_lba - (off_t) 1 >
|
||||||
|
(off_t) 0xffffffff);
|
||||||
|
if (!ignore_part) {
|
||||||
|
ret= src->read_block(src, start_lba / 4, buf);
|
||||||
|
if (ret != 1)
|
||||||
|
ignore_part = 1;
|
||||||
|
}
|
||||||
|
if (!ignore_part) {
|
||||||
|
lba = (start_lba + num_blocks - 1) / 4;
|
||||||
|
/* make sure not to ignore because of incomplete last 2048 block */
|
||||||
|
if (lba > 0 && (off_t) lba * (off_t) 4 + (off_t) 3 !=
|
||||||
|
(off_t) (start_lba + num_blocks - 1))
|
||||||
|
lba--;
|
||||||
|
ret= src->read_block(src, lba, buf);
|
||||||
|
if (ret != 1)
|
||||||
|
ignore_part = 1;
|
||||||
|
}
|
||||||
|
if (ignore_part) {
|
||||||
|
iso_msg_submit(image->id, ISO_GENERAL_NOTE, 0,
|
||||||
|
"Ignored non-empty MBR partition outside of medium capacity");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (sph > 0) {
|
if (sph > 0) {
|
||||||
if (end_s != sph)
|
if (end_s != sph)
|
||||||
sph = 0xffffffff;
|
sph = 0xffffffff;
|
||||||
|
@ -3902,6 +3927,7 @@ int iso_analyze_mbr_ptable(IsoImage *image, int flag)
|
||||||
sai->system_area_options |= (cyl_align_mode << 8);
|
sai->system_area_options |= (cyl_align_mode << 8);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
ex:
|
ex:
|
||||||
|
LIBISO_FREE_MEM(buf);
|
||||||
LIBISO_FREE_MEM(hc_sh);
|
LIBISO_FREE_MEM(hc_sh);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -4016,7 +4042,7 @@ int iso_analyze_mbr(IsoImage *image, IsoDataSource *src, int flag)
|
||||||
((unsigned char *) sad)[511] != 0xaa)
|
((unsigned char *) sad)[511] != 0xaa)
|
||||||
{ret = 0; goto ex;}
|
{ret = 0; goto ex;}
|
||||||
|
|
||||||
ret = iso_analyze_mbr_ptable(image, 0);
|
ret = iso_analyze_mbr_ptable(image, src, 0);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
goto ex;
|
goto ex;
|
||||||
|
|
||||||
|
|
|
@ -930,27 +930,6 @@ int susp_add_ES(Ecma119Image *t, struct susp_info *susp, int to_ce, int seqno)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A field beginning by 0 causes rrip_write_ce_fields() to pad up to the
|
|
||||||
* next block.
|
|
||||||
*/
|
|
||||||
static
|
|
||||||
int pseudo_susp_add_PAD(Ecma119Image *t, struct susp_info *susp)
|
|
||||||
{
|
|
||||||
unsigned char *pad;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
pad = malloc(1);
|
|
||||||
if (pad == NULL)
|
|
||||||
return ISO_OUT_OF_MEM;
|
|
||||||
pad[0] = 0;
|
|
||||||
ret = susp_append_ce(t, susp, pad);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
return ISO_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* see doc/zisofs_format.txt : "ZF System Use Entry Format"
|
* see doc/zisofs_format.txt : "ZF System Use Entry Format"
|
||||||
* see doc/zisofs2_format.txt : "ZF System Use Entry Format", "Z2 ..."
|
* see doc/zisofs2_format.txt : "ZF System Use Entry Format", "Z2 ..."
|
||||||
|
@ -1166,7 +1145,7 @@ int susp_calc_nm_sl_al(Ecma119Image *t, Ecma119Node *n, size_t space,
|
||||||
size_t *su_size, size_t *ce, size_t base_ce, int flag)
|
size_t *su_size, size_t *ce, size_t base_ce, int flag)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
size_t namelen, su_mem, ce_mem, ce_prepad = 0;
|
size_t namelen, su_mem, ce_mem;
|
||||||
void *xipt;
|
void *xipt;
|
||||||
size_t num_aapt = 0, sua_free = 0;
|
size_t num_aapt = 0, sua_free = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -1185,21 +1164,8 @@ int susp_calc_nm_sl_al(Ecma119Image *t, Ecma119Node *n, size_t space,
|
||||||
if (*ce > 0 && !(flag & 1))
|
if (*ce > 0 && !(flag & 1))
|
||||||
goto unannounced_ca;
|
goto unannounced_ca;
|
||||||
|
|
||||||
if (flag & 2) {
|
if (flag & 2)
|
||||||
flag |= 1;
|
flag |= 1;
|
||||||
if (base_ce % BLOCK_SIZE) {
|
|
||||||
|
|
||||||
#ifdef Libisofs_ce_calc_debuG
|
|
||||||
|
|
||||||
fprintf(stderr,
|
|
||||||
"\nlibburn_DEBUG: Accounting for %d bytes CE padding : %s\n\n",
|
|
||||||
(int) (BLOCK_SIZE - (base_ce % BLOCK_SIZE)), n->node->name);
|
|
||||||
|
|
||||||
#endif /* Libisofs_ce_calc_debuG */
|
|
||||||
|
|
||||||
ce_prepad = BLOCK_SIZE - (base_ce % BLOCK_SIZE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namelen = 0;
|
namelen = 0;
|
||||||
name = get_rr_fname(t, n->node->name);
|
name = get_rr_fname(t, n->node->name);
|
||||||
|
@ -1210,10 +1176,8 @@ int susp_calc_nm_sl_al(Ecma119Image *t, Ecma119Node *n, size_t space,
|
||||||
|
|
||||||
if (flag & 1) {
|
if (flag & 1) {
|
||||||
/* Account for 28 bytes of CE field */
|
/* Account for 28 bytes of CE field */
|
||||||
if (*su_size + 28 > space) {
|
if (*su_size + 28 > space)
|
||||||
*ce += ce_prepad;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
*su_size += 28;
|
*su_size += 28;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1244,10 +1208,8 @@ int susp_calc_nm_sl_al(Ecma119Image *t, Ecma119Node *n, size_t space,
|
||||||
int cew = (*ce != 0); /* are we writing to CA ? */
|
int cew = (*ce != 0); /* are we writing to CA ? */
|
||||||
|
|
||||||
dest = get_rr_fname(t, ((IsoSymlink*)n->node)->dest);
|
dest = get_rr_fname(t, ((IsoSymlink*)n->node)->dest);
|
||||||
if (dest == NULL) {
|
if (dest == NULL)
|
||||||
*ce += ce_prepad;
|
|
||||||
return -2;
|
return -2;
|
||||||
}
|
|
||||||
prev = dest;
|
prev = dest;
|
||||||
cur = strchr(prev, '/');
|
cur = strchr(prev, '/');
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -1357,9 +1319,6 @@ int susp_calc_nm_sl_al(Ecma119Image *t, Ecma119Node *n, size_t space,
|
||||||
if (*ce > 0 && !(flag & 1))
|
if (*ce > 0 && !(flag & 1))
|
||||||
goto unannounced_ca;
|
goto unannounced_ca;
|
||||||
|
|
||||||
*ce += ce_prepad;
|
|
||||||
ce_prepad = 0;
|
|
||||||
|
|
||||||
/* obtain num_aapt from node */
|
/* obtain num_aapt from node */
|
||||||
xipt = NULL;
|
xipt = NULL;
|
||||||
num_aapt = 0;
|
num_aapt = 0;
|
||||||
|
@ -1412,7 +1371,6 @@ int susp_calc_nm_sl_al(Ecma119Image *t, Ecma119Node *n, size_t space,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*ce += ce_prepad;
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
unannounced_ca:;
|
unannounced_ca:;
|
||||||
|
@ -1997,26 +1955,6 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ce_is_predicted) {
|
if (ce_is_predicted) {
|
||||||
if ((info->ce_len % BLOCK_SIZE) &&
|
|
||||||
(info->ce_len + ce_len_pd - 1 ) / BLOCK_SIZE !=
|
|
||||||
info->ce_len / BLOCK_SIZE) {
|
|
||||||
/* Linux fs/isofs wants byte_offset + ce_len <= BLOCK_SIZE
|
|
||||||
* Insert padding to shift CE offset to next block start
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef Libisofs_ce_calc_debuG
|
|
||||||
|
|
||||||
fprintf(stderr,
|
|
||||||
"\nlibburn_DEBUG: Inserting %d bytes of CE padding : %s\n\n",
|
|
||||||
(int) (BLOCK_SIZE - (info->ce_len % BLOCK_SIZE)),
|
|
||||||
n->node->name);
|
|
||||||
|
|
||||||
#endif /* Libisofs_ce_calc_debuG */
|
|
||||||
|
|
||||||
ret = pseudo_susp_add_PAD(t, info);
|
|
||||||
if (ret < 0)
|
|
||||||
goto add_susp_cleanup;
|
|
||||||
}
|
|
||||||
/* Add the CE entry */
|
/* Add the CE entry */
|
||||||
ret = susp_add_CE(t, ce_len_pd, info);
|
ret = susp_add_CE(t, ce_len_pd, info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
Loading…
Reference in New Issue