Let loaded image adjust truncate length regardless whether larger or

smaller than the current truncate length.
release-1.5.4.branch
Thomas Schmitt 7 years ago
parent 218e26c974
commit 72ef369a40
  1. 109
      libisofs/fs_image.c
  2. 12
      libisofs/libisofs.h
  3. 4
      libisofs/messages.c
  4. 25
      libisofs/node.c
  5. 5
      libisofs/node.h

@ -310,12 +310,6 @@ typedef struct
int truncate_length;
unsigned int ecma119_map : 2;
/**
* Values read from isofs.nt (isofsnt_truncate_mode == -1) means none read.
*/
int isofsnt_truncate_mode;
int isofsnt_truncate_length;
/** Whether AAIP info shall be loaded if it is present.
* 1 = yes , 0 = no
*/
@ -1451,16 +1445,10 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
unsigned char *aa_string = NULL;
size_t aa_size = 0, aa_len = 0, prev_field = 0;
int aa_done = 0;
char *attr_value = NULL;
size_t attr_value_length = 0;
char *msg = NULL;
uint8_t *buffer = NULL;
char *cpt;
int len;
uint32_t truncate_mode, truncate_length;
char *rpt;
int has_px = 0;
#ifdef Libisofs_with_zliB
@ -1851,43 +1839,6 @@ if (name != NULL && !namecont) {
goto ex;
}
if (fsdata->aaip_load && (flag & 1) && aa_string != NULL) {
ret = iso_aa_lookup_attr(aa_string, "isofs.cs",
&attr_value_length, &attr_value, 0);
if (ret == 1) {
LIBISO_FREE_MEM(msg);
LIBISO_ALLOC_MEM(msg, char, 160);
if (fsdata->auto_input_charset & 1) {
if (fsdata->input_charset != NULL)
free(fsdata->input_charset);
fsdata->input_charset = attr_value;
sprintf(msg,
"Learned from ISO image: input character set '%.80s'",
attr_value);
} else {
sprintf(msg,
"Character set name recorded in ISO image: '%.80s'",
attr_value);
free(attr_value);
}
iso_msgs_submit(0, msg, 0, "NOTE", 0);
attr_value = NULL;
}
ret = iso_aa_lookup_attr(aa_string, "isofs.nt",
&attr_value_length, &attr_value, 0);
if (ret == 1) {
rpt = attr_value;
iso_util_decode_len_bytes(&truncate_mode, rpt, &len,
attr_value_length - (rpt - attr_value), 0);
rpt += len + 1;
iso_util_decode_len_bytes(&truncate_length, rpt, &len,
attr_value_length - (rpt - attr_value), 0);
fsdata->isofsnt_truncate_mode = truncate_mode;
fsdata->isofsnt_truncate_length = truncate_length;
}
}
/* convert name to needed charset */
if (strcmp(fsdata->input_charset, fsdata->local_charset) && name) {
/* we need to convert name charset */
@ -3117,8 +3068,6 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
data->truncate_mode = opts->truncate_mode;
data->truncate_length = opts->truncate_length;
data->ecma119_map = opts->ecma119_map;
data->isofsnt_truncate_mode = -1;
data->isofsnt_truncate_length = 0;
if (data->input_charset == NULL) {
if (opts->input_charset != NULL) {
@ -5717,8 +5666,10 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
IsoNode *node;
char *old_checksum_array = NULL;
char checksum_type[81];
uint32_t checksum_size;
size_t size;
uint32_t checksum_size, truncate_mode, truncate_length;
size_t size, attr_value_length;
char *attr_value;
unsigned char *aa_string = NULL;
void *ctx = NULL;
char md5[16];
struct el_torito_boot_catalog *catalog = NULL;
@ -5763,6 +5714,32 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
return ret;
}
/* Lookup character set even if no AAIP loading is enabled */
ret = iso_file_source_get_aa_string(newroot, &aa_string, 2);
if (ret == 1 && aa_string != NULL) {
ret = iso_aa_lookup_attr(aa_string, "isofs.cs",
&attr_value_length, &attr_value, 0);
free(aa_string);
} else {
ret = 0;
}
if (ret == 1) {
if (data->auto_input_charset & 1) {
if (data->input_charset != NULL)
free(data->input_charset);
data->input_charset = attr_value;
iso_msg_submit(image->id, ISO_GENERAL_NOTE, 0,
"Learned from ISO image: input character set '%.80s'",
attr_value);
} else {
iso_msg_submit(image->id, ISO_GENERAL_NOTE, 0,
"Ignored character set name recorded in ISO image: '%.80s'",
attr_value);
free(attr_value);
}
attr_value = NULL;
}
/* backup image filesystem, builder and root */
fsback = image->fs;
blback = image->builder;
@ -5810,6 +5787,22 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
}
}
ret = iso_root_get_isofsnt(&(image->root->node), &truncate_mode,
&truncate_length, 0);
if (ret == 1 && (int) truncate_mode == image->truncate_mode &&
image->truncate_mode == 1 &&
truncate_length >= 64 && truncate_length <= 255 &&
(int) truncate_length != image->truncate_length) {
data->truncate_mode = opts->truncate_mode = image->truncate_mode =
truncate_mode;
data->truncate_length = opts->truncate_length =
image->truncate_length = truncate_length;
iso_msg_submit(image->id, ISO_TRUNCATE_ISOFSNT, 0,
"File name truncation length changed by loaded image info: %d",
(int) truncate_length);
}
/* if old image has el-torito, add a new catalog */
if (data->eltorito) {
@ -6032,16 +6025,6 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
}
}
if (data->isofsnt_truncate_mode == image->truncate_mode &&
image->truncate_mode == 1 &&
image->truncate_length > data->isofsnt_truncate_length &&
data->isofsnt_truncate_length >= 64) {
iso_msg_submit(image->id, ISO_TRUNCATE_ISOFSNT, 0,
"File name truncation length reduced by loaded image info: %d",
data->isofsnt_truncate_length);
image->truncate_length = data->isofsnt_truncate_length;
}
ret = ISO_SUCCESS;
goto import_cleanup;

@ -3116,8 +3116,7 @@ void *iso_image_get_attached_data(IsoImage *image);
* xattr "isofs.nt" of the root node.
* If reading of AAIP is enabled and "isofs.nt" is found, then it gets into
* effect if both, the truncate mode value from "isofs.nt" and the current
* truncate mode of the IsoImage are 1, and if the truncate length from
* "isofs.nt" is smaller than the current truncate length ot the IsoImage.
* truncate mode of the IsoImage are 1, and the length is between 64 and 255.
*
* @param image
* The image which shall be manipulated.
@ -8705,9 +8704,12 @@ int iso_conv_name_chars(IsoWriteOpts *opts, char *name, size_t name_len,
/** File name had to be truncated and MD5 marked (WARNING, HIGH, -412) */
#define ISO_RR_NAME_TRUNCATED 0xD030FE64
/** File name truncation length reduced by loaded image info
(WARNING, HIGH, -413) */
#define ISO_TRUNCATE_ISOFSNT 0xD030FE63
/** File name truncation length changed by loaded image info
(NOTE, HIGH, -413) */
#define ISO_TRUNCATE_ISOFSNT 0xB030FE63
/** General note (NOTE, HIGH, -414) */
#define ISO_GENERAL_NOTE 0xB030FE62
/* Internal developer note:

@ -538,7 +538,9 @@ const char *iso_error_to_msg(int errcode)
case ISO_RR_NAME_TRUNCATED:
return "File name had to be truncated and MD5 marked";
case ISO_TRUNCATE_ISOFSNT:
return "File name truncation length reduced by loaded image info";
return "File name truncation length changed by loaded image info";
case ISO_GENERAL_NOTE:
return "A general note message was issued";
default:
return "Unknown error";
}

@ -2963,6 +2963,31 @@ int iso_root_set_isofsnt(IsoNode *node, uint32_t truncate_mode,
}
int iso_root_get_isofsnt(IsoNode *node, uint32_t *truncate_mode,
uint32_t *truncate_length, int flag)
{
int ret, len;
size_t value_len;
char *value = NULL, *rpt;
ret = iso_node_lookup_attr(node, "isofs.nt", &value_len, &value, 0);
if (ret <= 0)
goto ex;
rpt = value;
iso_util_decode_len_bytes(truncate_mode, rpt, &len,
value_len - (rpt - value), 0);
rpt += len + 1;
iso_util_decode_len_bytes(truncate_length, rpt, &len,
value_len - (rpt - value), 0);
ret= ISO_SUCCESS;
ex:;
if (value != NULL)
free(value);
return ret;
}
/* API */
int iso_file_get_md5(IsoImage *image, IsoFile *file, char md5[16], int flag)
{

@ -513,10 +513,13 @@ int iso_root_get_isofsca(IsoNode *node, uint32_t *start_lba, uint32_t *end_lba,
/**
* Record parameters of iso_image_set_truncate_mode() by "isofs.nt".
* Record and get truncation parameters as of iso_image_set_truncate_mode() by
* "isofs.nt".
*/
int iso_root_set_isofsnt(IsoNode *node, uint32_t truncate_mode,
uint32_t truncate_length, int flag);
int iso_root_get_isofsnt(IsoNode *node, uint32_t *truncate_mode,
uint32_t *truncate_length, int flag);
/**

Loading…
Cancel
Save