Now repeating Rock Ridge warnings at most once per loaded image.

This commit is contained in:
Thomas Schmitt 2013-04-10 13:32:53 +02:00
parent 858c5479c8
commit 1a2e1c767e

View File

@ -330,6 +330,30 @@ typedef struct
*/ */
int px_ino_status; int px_ino_status;
/* Which Rock Ridge error messages already have occured
bit0= Invalid PX entry
bit1= Invalid TF entry
bit2= New NM entry found without previous CONTINUE flag
bit3= Invalid NM entry
bit4= New SL entry found without previous CONTINUE flag
bit5= Invalid SL entry
bit6= Invalid SL entry, no child location
bit7= Invalid PN entry
bit8= Sparse files not supported
bit9= SP entry found in a directory entry other than '.' entry of root
bit10= ER entry found in a directory entry other than '.' entry of root
bit11= Invalid AA entry
bit12= Invalid AL entry
bit13= Invalid ZF entry
bit14= Rock Ridge PX entry is not present or invalid
bit15= Incomplete NM
bit16= Incomplete SL
bit17= Charset conversion error
bit18= Link without destination
*/
int rr_err_reported;
int rr_err_repeated;
} _ImageFsData; } _ImageFsData;
typedef struct image_fs_data ImageFileSourceData; typedef struct image_fs_data ImageFileSourceData;
@ -1249,6 +1273,30 @@ char *get_name(_ImageFsData *fsdata, const char *str, size_t len)
} }
static
int iso_rr_msg_submit(_ImageFsData *fsdata, int rr_err_bit,
int errcode, int causedby, const char *msg)
{
int ret;
if ((fsdata->rr_err_reported & (1 << rr_err_bit)) &&
(fsdata->rr_err_repeated & (1 << rr_err_bit))) {
if (iso_msg_is_abort(errcode))
return ISO_CANCELED;
return 0;
}
if (fsdata->rr_err_reported & (1 << rr_err_bit)) {
ret = iso_msg_submit(fsdata->msgid, errcode, causedby,
"MORE THAN ONCE : %s", msg);
fsdata->rr_err_repeated |= (1 << rr_err_bit);
} else {
ret = iso_msg_submit(fsdata->msgid, errcode, causedby, "%s", msg);
fsdata->rr_err_reported |= (1 << rr_err_bit);
}
return ret;
}
/** /**
* *
* @param src * @param src
@ -1439,7 +1487,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
ret = read_rr_PX(sue, &atts); ret = read_rr_PX(sue, &atts);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret, ret = iso_rr_msg_submit(fsdata, 0, ISO_WRONG_RR_WARN, ret,
"Invalid PX entry"); "Invalid PX entry");
fsdata->px_ino_status |= 8; fsdata->px_ino_status |= 8;
} if (ret == 2) { } if (ret == 2) {
@ -1455,13 +1503,13 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
ret = read_rr_TF(sue, &atts); ret = read_rr_TF(sue, &atts);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret, ret = iso_rr_msg_submit(fsdata, 1, ISO_WRONG_RR_WARN, ret,
"Invalid TF entry"); "Invalid TF entry");
} }
} else if (SUSP_SIG(sue, 'N', 'M')) { } else if (SUSP_SIG(sue, 'N', 'M')) {
if (name != NULL && namecont == 0) { if (name != NULL && namecont == 0) {
/* ups, RR standard violation */ /* ups, RR standard violation */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, 0, ret = iso_rr_msg_submit(fsdata, 2, ISO_WRONG_RR_WARN, 0,
"New NM entry found without previous" "New NM entry found without previous"
"CONTINUE flag. Ignored"); "CONTINUE flag. Ignored");
continue; continue;
@ -1469,7 +1517,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
ret = read_rr_NM(sue, &name, &namecont); ret = read_rr_NM(sue, &name, &namecont);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret, ret = iso_rr_msg_submit(fsdata, 3, ISO_WRONG_RR_WARN, ret,
"Invalid NM entry"); "Invalid NM entry");
} }
@ -1514,7 +1562,7 @@ if (name != NULL && !namecont) {
} else if (SUSP_SIG(sue, 'S', 'L')) { } else if (SUSP_SIG(sue, 'S', 'L')) {
if (linkdest != NULL && linkdestcont == 0) { if (linkdest != NULL && linkdestcont == 0) {
/* ups, RR standard violation */ /* ups, RR standard violation */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, 0, ret = iso_rr_msg_submit(fsdata, 4, ISO_WRONG_RR_WARN, 0,
"New SL entry found without previous" "New SL entry found without previous"
"CONTINUE flag. Ignored"); "CONTINUE flag. Ignored");
continue; continue;
@ -1522,7 +1570,7 @@ if (name != NULL && !namecont) {
ret = read_rr_SL(sue, &linkdest, &linkdestcont); ret = read_rr_SL(sue, &linkdest, &linkdestcont);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret, ret = iso_rr_msg_submit(fsdata, 5, ISO_WRONG_RR_WARN, ret,
"Invalid SL entry"); "Invalid SL entry");
} }
} else if (SUSP_SIG(sue, 'R', 'E')) { } else if (SUSP_SIG(sue, 'R', 'E')) {
@ -1543,7 +1591,7 @@ if (name != NULL && !namecont) {
*/ */
relocated_dir = iso_read_bb(sue->data.CL.child_loc, 4, NULL); relocated_dir = iso_read_bb(sue->data.CL.child_loc, 4, NULL);
if (relocated_dir == 0) { if (relocated_dir == 0) {
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0, ret = iso_rr_msg_submit(fsdata, 6, ISO_WRONG_RR, 0,
"Invalid SL entry, no child location"); "Invalid SL entry, no child location");
break; break;
} }
@ -1551,11 +1599,11 @@ if (name != NULL && !namecont) {
ret = read_rr_PN(sue, &atts); ret = read_rr_PN(sue, &atts);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret, ret = iso_rr_msg_submit(fsdata, 7, ISO_WRONG_RR_WARN, ret,
"Invalid PN entry"); "Invalid PN entry");
} }
} else if (SUSP_SIG(sue, 'S', 'F')) { } else if (SUSP_SIG(sue, 'S', 'F')) {
ret = iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_RR, 0, ret = iso_rr_msg_submit(fsdata, 8, ISO_UNSUPPORTED_RR, 0,
"Sparse files not supported."); "Sparse files not supported.");
break; break;
} else if (SUSP_SIG(sue, 'R', 'R')) { } else if (SUSP_SIG(sue, 'R', 'R')) {
@ -1571,7 +1619,7 @@ if (name != NULL && !namecont) {
*/ */
if (!(flag & 1)) { if (!(flag & 1)) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0, ret = iso_rr_msg_submit(fsdata, 9, ISO_WRONG_RR, 0,
"SP entry found in a directory entry other " "SP entry found in a directory entry other "
"than '.' entry of root node"); "than '.' entry of root node");
} }
@ -1583,7 +1631,7 @@ if (name != NULL && !namecont) {
*/ */
if (!(flag & 1)) { if (!(flag & 1)) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0, ret = iso_rr_msg_submit(fsdata, 10, ISO_WRONG_RR, 0,
"ER entry found in a directory entry other " "ER entry found in a directory entry other "
"than '.' entry of root node"); "than '.' entry of root node");
} }
@ -1598,7 +1646,7 @@ if (name != NULL && !namecont) {
&prev_field, &aa_done, 0); &prev_field, &aa_done, 0);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret, ret = iso_rr_msg_submit(fsdata, 11, ISO_WRONG_RR_WARN, ret,
"Invalid AA entry"); "Invalid AA entry");
continue; continue;
} }
@ -1609,7 +1657,7 @@ if (name != NULL && !namecont) {
&prev_field, &aa_done, 0); &prev_field, &aa_done, 0);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret, ret = iso_rr_msg_submit(fsdata, 12, ISO_WRONG_RR_WARN, ret,
"Invalid AL entry"); "Invalid AL entry");
continue; continue;
} }
@ -1622,7 +1670,7 @@ if (name != NULL && !namecont) {
&zisofs_bsl2, &zisofs_usize, 0); &zisofs_bsl2, &zisofs_usize, 0);
if (ret < 0 || zisofs_alg[0] != 'p' || zisofs_alg[1] != 'z') { if (ret < 0 || zisofs_alg[0] != 'p' || zisofs_alg[1] != 'z') {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret, ret = iso_rr_msg_submit(fsdata, 13, ISO_WRONG_RR_WARN, ret,
"Invalid ZF entry"); "Invalid ZF entry");
zisofs_hs4 = 0; zisofs_hs4 = 0;
continue; continue;
@ -1648,17 +1696,17 @@ if (name != NULL && !namecont) {
/* error was already submitted above */ /* error was already submitted above */
iso_msg_debug(fsdata->msgid, "Error parsing RR entries"); iso_msg_debug(fsdata->msgid, "Error parsing RR entries");
} else if (!relocated_dir && atts.st_mode == (mode_t) 0 ) { } else if (!relocated_dir && atts.st_mode == (mode_t) 0 ) {
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0, "Mandatory " ret = iso_rr_msg_submit(fsdata, 14, ISO_WRONG_RR, 0, "Mandatory "
"Rock Ridge PX entry is not present or it " "Rock Ridge PX entry is not present or it "
"contains invalid values."); "contains invalid values.");
} else { } else {
/* ensure both name and link dest are finished */ /* ensure both name and link dest are finished */
if (namecont != 0) { if (namecont != 0) {
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0, ret = iso_rr_msg_submit(fsdata, 15, ISO_WRONG_RR, 0,
"Incomplete RR name, last NM entry continues"); "Incomplete Rock Ridge name, last NM entry continues");
} }
if (linkdestcont != 0) { if (linkdestcont != 0) {
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0, ret = iso_rr_msg_submit(fsdata, 16, ISO_WRONG_RR, 0,
"Incomplete link destination, last SL entry continues"); "Incomplete link destination, last SL entry continues");
} }
} }
@ -1672,6 +1720,7 @@ if (name != NULL && !namecont) {
ret = iso_aa_lookup_attr(aa_string, "isofs.cs", ret = iso_aa_lookup_attr(aa_string, "isofs.cs",
&cs_value_length, &cs_value, 0); &cs_value_length, &cs_value, 0);
if (ret == 1) { if (ret == 1) {
LIBISO_FREE_MEM(msg);
LIBISO_ALLOC_MEM(msg, char, 160); LIBISO_ALLOC_MEM(msg, char, 160);
if (fsdata->auto_input_charset & 1) { if (fsdata->auto_input_charset & 1) {
if (fsdata->input_charset != NULL) if (fsdata->input_charset != NULL)
@ -1699,10 +1748,13 @@ if (name != NULL && !namecont) {
&newname); &newname);
if (ret < 0) { if (ret < 0) {
/* its just a hint message */ /* its just a hint message */
ret = iso_msg_submit(fsdata->msgid, ISO_FILENAME_WRONG_CHARSET, LIBISO_FREE_MEM(msg);
ret, "Charset conversion error. Cannot " LIBISO_ALLOC_MEM(msg, char, 160);
"convert from %s to %s", sprintf(msg,
"Charset conversion error. Cannot convert from %.40s to %.40s",
fsdata->input_charset, fsdata->local_charset); fsdata->input_charset, fsdata->local_charset);
ret = iso_rr_msg_submit(fsdata, 17, ISO_FILENAME_WRONG_CHARSET,
ret, msg);
free(newname); free(newname);
if (ret < 0) { if (ret < 0) {
free(name); free(name);
@ -1721,10 +1773,13 @@ if (name != NULL && !namecont) {
ret = strconv(linkdest, fsdata->input_charset, ret = strconv(linkdest, fsdata->input_charset,
fsdata->local_charset, &newlinkdest); fsdata->local_charset, &newlinkdest);
if (ret < 0) { if (ret < 0) {
ret = iso_msg_submit(fsdata->msgid, ISO_FILENAME_WRONG_CHARSET, LIBISO_FREE_MEM(msg);
ret, "Charset conversion error. Cannot " LIBISO_ALLOC_MEM(msg, char, 160);
"convert from %s to %s", sprintf(msg,
"Charset conversion error. Cannot convert from %.40s to %.40s",
fsdata->input_charset, fsdata->local_charset); fsdata->input_charset, fsdata->local_charset);
ret = iso_rr_msg_submit(fsdata, 17, ISO_FILENAME_WRONG_CHARSET,
ret, msg);
free(newlinkdest); free(newlinkdest);
if (ret < 0) { if (ret < 0) {
free(name); free(name);
@ -1847,7 +1902,7 @@ if (name != NULL && !namecont) {
/* TODO #00014 : more sanity checks to ensure dir record info is valid */ /* TODO #00014 : more sanity checks to ensure dir record info is valid */
if (S_ISLNK(atts.st_mode) && (linkdest == NULL)) { if (S_ISLNK(atts.st_mode) && (linkdest == NULL)) {
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0, ret = iso_rr_msg_submit(fsdata, 18, ISO_WRONG_RR, 0,
"Link without destination."); "Link without destination.");
free(name); free(name);
goto ex; goto ex;
@ -2699,6 +2754,8 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
data->bootblocks[i] = 0; data->bootblocks[i] = 0;
data->inode_counter = 0; data->inode_counter = 0;
data->px_ino_status = 0; data->px_ino_status = 0;
data->rr_err_reported = 0;
data->rr_err_repeated = 0;
data->local_charset = strdup(iso_get_local_charset(0)); data->local_charset = strdup(iso_get_local_charset(0));
@ -3603,7 +3660,7 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
/* warn about hidden images */ /* warn about hidden images */
iso_msg_submit(image->id, ISO_EL_TORITO_HIDDEN, 0, iso_msg_submit(image->id, ISO_EL_TORITO_HIDDEN, 0,
"Found hidden El-Torito image. Its size could not " "Found hidden El-Torito image. Its size could not "
"be figure out, so image modify or boot image " "be figured out, so image modify or boot image "
"patching may lead to bad results."); "patching may lead to bad results.");
} }
if (image->bootcat->node == NULL) { if (image->bootcat->node == NULL) {