Issueing warning messages if -boot_image paths currently are unsuitable
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user