Issueing warning messages if -boot_image paths currently are unsuitable
This commit is contained in:
parent
87e1d67417
commit
c8fab513c6
@ -2796,3 +2796,86 @@ int Xorriso_is_plain_image_file(struct XorrisO *xorriso, void *in_node,
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Check for existence of a data file at given path. Complain if it is missing.
|
||||
@param prefix is printed directly before purpose, no blank inbetween
|
||||
@param purpose is printed up to first '=' character
|
||||
@param path ISO or disk file path
|
||||
@param flag bit0= check on disk (else in ISO)
|
||||
*/
|
||||
int Xorriso_warn_if_not_exist(struct XorrisO *xorriso, char *prefix,
|
||||
char *purpose, char *path, int flag)
|
||||
{
|
||||
int ret;
|
||||
char *where, *ept;
|
||||
struct stat stbuf;
|
||||
|
||||
if(flag & 1) {
|
||||
where= "on disk";
|
||||
ret= Sfile_type(path, 1 | 4 | 16);
|
||||
if(ret == 1 || ret == 6)
|
||||
return(1);
|
||||
} else {
|
||||
where= "in ISO image";
|
||||
ret= Xorriso_iso_lstat(xorriso, path, &stbuf, 0);
|
||||
if(ret == 0) {
|
||||
if(S_ISREG(stbuf.st_mode) || S_ISBLK(stbuf.st_mode))
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
/* Not found or not data file or block device */
|
||||
sprintf(xorriso->info_text, "%s%s", prefix, purpose);
|
||||
ept= strchr(xorriso->info_text + strlen(prefix), '=');
|
||||
if(ept != NULL)
|
||||
*(ept + 1)= 0;
|
||||
if(ret == -1) {
|
||||
sprintf(xorriso->info_text + strlen(xorriso->info_text),
|
||||
" : path does not yet exist %s : ", where);
|
||||
} else {
|
||||
sprintf(xorriso->info_text + strlen(xorriso->info_text),
|
||||
" : path exists %s but is not a usable file type : ", where);
|
||||
}
|
||||
Text_shellsafe(path, xorriso->info_text, 1);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Check for existence of a file at given path. Complain if it exists but is
|
||||
not a boot catalog file.
|
||||
@param prefix is printed directly before purpose, no blank inbetween
|
||||
@param purpose is printed up to first '=' character
|
||||
@param path ISO file path
|
||||
*/
|
||||
int Xorriso_warn_if_not_bootcat(struct XorrisO *xorriso, char *prefix,
|
||||
char *purpose, char *path, int flag)
|
||||
{
|
||||
int ret;
|
||||
char *where, *ept;
|
||||
IsoImage *volume;
|
||||
IsoNode *node;
|
||||
|
||||
where= "in ISO image";
|
||||
|
||||
ret= Xorriso_get_volume(xorriso, &volume, 0);
|
||||
if(ret <= 0)
|
||||
return(-1);
|
||||
ret= Xorriso_node_from_path(xorriso, volume, path, &node, 1);
|
||||
if(ret <= 0)
|
||||
return(1);
|
||||
if(LIBISO_ISBOOT(node))
|
||||
return(2);
|
||||
sprintf(xorriso->info_text, "%s%s", prefix, purpose);
|
||||
ept= strchr(xorriso->info_text + strlen(prefix), '=');
|
||||
if(ept != NULL)
|
||||
*(ept + 1)= 0;
|
||||
sprintf(xorriso->info_text + strlen(xorriso->info_text),
|
||||
" : path exists %s but is currently not a boot catalog file : ",
|
||||
where);
|
||||
Text_shellsafe(path, xorriso->info_text, 1);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -869,6 +869,8 @@ treatment_patch:;
|
||||
xorriso->boot_image_cat_path, 2);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
Xorriso_warn_if_not_bootcat(xorriso, "-boot_image ", treatment,
|
||||
xorriso->boot_image_cat_path, 0);
|
||||
is_change= 1;
|
||||
|
||||
} else if(strncmp(treatpt, "cat_hidden=", 11) == 0) {
|
||||
@ -912,6 +914,10 @@ treatment_patch:;
|
||||
xorriso->keep_boot_image= 0;
|
||||
xorriso->patch_isolinux_image= (xorriso->patch_isolinux_image & ~3) | 1;
|
||||
strcpy(xorriso->boot_image_bin_form, formpt);
|
||||
Xorriso_warn_if_not_exist(xorriso, "Implicit boot image via -boot_image ",
|
||||
treatment, xorriso->boot_image_bin_path, 0);
|
||||
Xorriso_warn_if_not_bootcat(xorriso, "-boot_image ", treatment,
|
||||
xorriso->boot_image_cat_path, 0);
|
||||
is_change= 1;
|
||||
{ret= 1; goto ex;}
|
||||
|
||||
@ -946,6 +952,8 @@ interval_text_long:;
|
||||
xorriso->boot_image_bin_path, 2);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
Xorriso_warn_if_not_exist(xorriso, "-boot_image ",
|
||||
treatment, xorriso->boot_image_bin_path, 0);
|
||||
}
|
||||
xorriso->keep_boot_image= 0;
|
||||
if(isolinux_grub) {
|
||||
@ -974,6 +982,8 @@ interval_text_long:;
|
||||
xorriso->boot_image_bin_path, 2);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
Xorriso_warn_if_not_exist(xorriso, "-boot_image ",
|
||||
treatment, xorriso->boot_image_bin_path, 0);
|
||||
}
|
||||
xorriso->keep_boot_image= 0;
|
||||
xorriso->boot_efi_default= 1;
|
||||
@ -991,6 +1001,7 @@ interval_text_long:;
|
||||
ret= Xorriso_add_mips_boot_file(xorriso, eff_path, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
Xorriso_warn_if_not_exist(xorriso, "-boot_image ", treatment, eff_path, 0);
|
||||
is_change= 1;
|
||||
|
||||
} else if(strncmp(treatpt, "mipsel_path=", 12) == 0) {
|
||||
@ -1005,6 +1016,7 @@ interval_text_long:;
|
||||
ret= Xorriso_add_mips_boot_file(xorriso, eff_path, 2);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
Xorriso_warn_if_not_exist(xorriso, "-boot_image ", treatment, eff_path, 0);
|
||||
is_change= 1;
|
||||
|
||||
} else if(strcmp(treatpt, "mips_discard") == 0 ||
|
||||
@ -1033,6 +1045,8 @@ interval_text_long:;
|
||||
xorriso->grub2_sparc_core, 2);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
Xorriso_warn_if_not_exist(xorriso, "-boot_image ", treatment,
|
||||
xorriso->grub2_sparc_core, 0);
|
||||
is_change= 1;
|
||||
|
||||
} else if(strncmp(treatpt, "hppa_", 5) == 0) {
|
||||
@ -1059,6 +1073,7 @@ interval_text_long:;
|
||||
ret= Xorriso_set_hppa_boot_parm(xorriso, eqpt + 1, parm, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
/* (needs no file existence check because already done in libisofs) */
|
||||
is_change= 1;
|
||||
|
||||
} else if(strncmp(treatpt, "alpha_boot=", 11) == 0) {
|
||||
@ -1069,6 +1084,8 @@ interval_text_long:;
|
||||
ret = Xorriso_set_alpha_boot(xorriso, treatpt + 11, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
Xorriso_warn_if_not_exist(xorriso, "-boot_image ", treatment,
|
||||
treatpt + 11, 0);
|
||||
is_change= 1;
|
||||
|
||||
} else if(strncmp(treatpt, "boot_info_table=", 16)==0) {
|
||||
@ -1142,6 +1159,7 @@ interval_text_long:;
|
||||
if(strcmp(treatpt + 12, ".") == 0) {
|
||||
ret= Xorriso_set_system_area_path(xorriso, "", 0);
|
||||
} else {
|
||||
/* (checks also for existence of the disk file) */
|
||||
ret= Xorriso_set_system_area_path(xorriso, treatpt + 12, 0);
|
||||
}
|
||||
if(ret <= 0)
|
||||
@ -1393,11 +1411,15 @@ interval_text_long:;
|
||||
} else if(strncmp(treatpt, "efi_boot_part=", 14) == 0) {
|
||||
if(Sfile_str(xorriso->efi_boot_partition, treatpt + 14, 0) <= 0)
|
||||
{ret= -1; goto ex;}
|
||||
Xorriso_warn_if_not_exist(xorriso, "-boot_image ", treatment,
|
||||
treatpt + 14, 1);
|
||||
is_change= 1;
|
||||
|
||||
} else if(strncmp(treatpt, "prep_boot_part=", 15) == 0) {
|
||||
if(Sfile_str(xorriso->prep_partition, treatpt + 15, 0) <= 0)
|
||||
{ret= -1; goto ex;}
|
||||
Xorriso_warn_if_not_exist(xorriso, "-boot_image ", treatment,
|
||||
treatpt + 15, 1);
|
||||
is_change= 1;
|
||||
|
||||
} else if(strncmp(treatpt, "chrp_boot_part=", 15) == 0) {
|
||||
@ -1462,6 +1484,7 @@ interval_text_long:;
|
||||
if(strcmp(treatpt + 10, ".") == 0) {
|
||||
ret= Xorriso_set_system_area_path(xorriso, "", 0);
|
||||
} else {
|
||||
/* (checks also for existence of the disk file) */
|
||||
ret= Xorriso_set_system_area_path(xorriso, treatpt + 10, 0);
|
||||
}
|
||||
if(ret <= 0)
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2024.04.27.165316"
|
||||
#define Xorriso_timestamP "2024.05.12.153800"
|
||||
|
@ -686,5 +686,12 @@ int Xorriso_conv_name_chars(struct XorrisO *xorriso, char *name,
|
||||
char **result, size_t *result_len,
|
||||
int name_space, int flag);
|
||||
|
||||
int Xorriso_warn_if_not_exist(struct XorrisO *xorriso, char *prefix,
|
||||
char *purpose, char *path, int flag);
|
||||
|
||||
int Xorriso_warn_if_not_bootcat(struct XorrisO *xorriso, char *prefix,
|
||||
char *purpose, char *path, int flag);
|
||||
|
||||
|
||||
#endif /* Xorrisoburn_includeD */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user