New AAIP variable isofs.nt records name truncation parameters.

This commit is contained in:
2015-09-25 19:07:53 +02:00
parent 7a3560035a
commit 395128ef5f
7 changed files with 117 additions and 14 deletions

View File

@ -2536,6 +2536,12 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img)
break;
}
ret = iso_root_set_isofsnt((IsoNode *) (src->root),
(uint32_t) src->truncate_mode,
(uint32_t) src->truncate_length, 0);
if (ret < 0)
goto target_cleanup;
/*
* 2. Based on those options, create needed writers: iso, joliet...
* Each writer inits its structures and stores needed info into

View File

@ -310,6 +310,12 @@ 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
*/
@ -1445,12 +1451,16 @@ 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 *cs_value = NULL;
size_t cs_value_length = 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
@ -1841,27 +1851,40 @@ if (name != NULL && !namecont) {
goto ex;
}
if ((flag & 1) && aa_string != NULL) {
if (fsdata->aaip_load && (flag & 1) && aa_string != NULL) {
ret = iso_aa_lookup_attr(aa_string, "isofs.cs",
&cs_value_length, &cs_value, 0);
&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 = cs_value;
fsdata->input_charset = attr_value;
sprintf(msg,
"Learned from ISO image: input character set '%.80s'",
cs_value);
attr_value);
} else {
sprintf(msg,
"Character set name recorded in ISO image: '%.80s'",
cs_value);
free(cs_value);
attr_value);
free(attr_value);
}
iso_msgs_submit(0, msg, 0, "NOTE", 0);
cs_value = NULL;
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;
}
}
@ -3094,6 +3117,8 @@ 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) {
@ -6007,6 +6032,16 @@ 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;

View File

@ -3112,6 +3112,13 @@ void *iso_image_get_attached_data(IsoImage *image);
* exist in the same directory. Best is to only set truncation parameters
* once with an ISO filesystem and to never change them later.
*
* If writing of AAIP is enabled, then the mode and length are recorded in
* 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.
*
* @param image
* The image which shall be manipulated.
* @param mode
@ -8694,6 +8701,10 @@ 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
/* Internal developer note:
Place new error codes directly above this comment.

View File

@ -537,6 +537,8 @@ const char *iso_error_to_msg(int errcode)
return "Boot image to large to buffer for writing boot info";
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";
default:
return "Unknown error";
}

View File

@ -2940,6 +2940,25 @@ ex:;
}
int iso_root_set_isofsnt(IsoNode *node, uint32_t truncate_mode,
uint32_t truncate_length, int flag)
{
char buffer[5 + 5], *wpt = buffer, *valuept = buffer;
int result_len, ret;
static char *names = "isofs.nt";
static size_t value_lengths[1];
iso_util_encode_len_bytes(truncate_mode, wpt, 0, &result_len, 0);
wpt += result_len;
iso_util_encode_len_bytes(truncate_length, wpt, 0, &result_len, 0);
wpt += result_len;
value_lengths[0] = wpt - buffer;
ret = iso_node_set_attrs(node, (size_t) 1,
&names, value_lengths, &valuept, 2 | 8);
return ret;
}
/* API */
int iso_file_get_md5(IsoImage *image, IsoFile *file, char md5[16], int flag)
{

View File

@ -512,6 +512,13 @@ int iso_root_get_isofsca(IsoNode *node, uint32_t *start_lba, uint32_t *end_lba,
int flag);
/**
* Record parameters 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);
/**
* Copy the xinfo list from one node to the another.
*/