New API call iso_image_set_boot_platform_id().
Downgraded ISO_WRONG_EL_TORITO and ISO_UNSUPPORTED_EL_TORITO from SORRY to WARN and implemented the tolerance that is promised by their message texts.
This commit is contained in:
parent
98d2b4c996
commit
517f520570
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Vreixo Formoso
|
||||
* Copyright (c) 2010 Thomas Schmitt
|
||||
*
|
||||
* This file is part of the libisofs project; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
@ -19,7 +20,7 @@
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* This table should be written with accuracy values at offset
|
||||
* This table should be written with the actual values at offset
|
||||
* 8 of boot image, when used ISOLINUX boot loader
|
||||
*/
|
||||
struct boot_info_table {
|
||||
@ -417,6 +418,7 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path,
|
||||
}
|
||||
catalog->image = boot_image;
|
||||
catalog->node = cat_node;
|
||||
catalog->platform_id = 0; /* Default is 80x86 */
|
||||
iso_node_ref((IsoNode*)cat_node);
|
||||
image->bootcat = catalog;
|
||||
|
||||
@ -518,6 +520,15 @@ void iso_image_remove_boot_image(IsoImage *image)
|
||||
image->bootcat = NULL;
|
||||
}
|
||||
|
||||
/* API */
|
||||
int iso_image_set_boot_platform_id(IsoImage *image, uint8_t id)
|
||||
{
|
||||
if (image->bootcat == NULL)
|
||||
return 0;
|
||||
image->bootcat->platform_id = id;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void el_torito_boot_catalog_free(struct el_torito_boot_catalog *cat)
|
||||
{
|
||||
struct el_torito_boot_image *image;
|
||||
@ -540,11 +551,16 @@ struct catalog_stream
|
||||
{
|
||||
Ecma119Image *target;
|
||||
uint8_t buffer[BLOCK_SIZE];
|
||||
int offset; /* -1 if stream is not openned */
|
||||
int offset; /* -1 if stream is not opened */
|
||||
|
||||
/* ts B00419 */
|
||||
/* Byte 1 of Validation Entry: 0= 80x86, 1= PowerPC, 2= Mac, 0xef= EFI */
|
||||
uint8_t platform_id;
|
||||
|
||||
};
|
||||
|
||||
static void
|
||||
write_validation_entry(uint8_t *buf)
|
||||
write_validation_entry(uint8_t *buf, uint8_t platform_id)
|
||||
{
|
||||
size_t i;
|
||||
int checksum;
|
||||
@ -552,7 +568,8 @@ write_validation_entry(uint8_t *buf)
|
||||
struct el_torito_validation_entry *ve =
|
||||
(struct el_torito_validation_entry*)buf;
|
||||
ve->header_id[0] = 1;
|
||||
ve->platform_id[0] = 0; /* 0: 80x86, 1: PowerPC, 2: Mac */
|
||||
/* 0: 80x86, 1: PowerPC, 2: Mac, 0xef: EFI */
|
||||
ve->platform_id[0] = platform_id;
|
||||
ve->key_byte1[0] = 0x55;
|
||||
ve->key_byte2[0] = 0xAA;
|
||||
|
||||
@ -601,7 +618,7 @@ int catalog_open(IsoStream *stream)
|
||||
memset(data->buffer, 0, BLOCK_SIZE);
|
||||
|
||||
/* fill the buffer with the catalog contents */
|
||||
write_validation_entry(data->buffer);
|
||||
write_validation_entry(data->buffer, data->platform_id);
|
||||
|
||||
/* write default entry */
|
||||
write_section_entry(data->buffer + 32, data->target);
|
||||
@ -718,6 +735,7 @@ int catalog_stream_new(Ecma119Image *target, IsoStream **stream)
|
||||
/* fill data */
|
||||
data->target = target;
|
||||
data->offset = -1;
|
||||
data->platform_id = target->catalog->platform_id;
|
||||
|
||||
str->refcount = 1;
|
||||
str->data = data;
|
||||
|
@ -30,6 +30,13 @@ struct Iso_Boot
|
||||
struct el_torito_boot_catalog {
|
||||
IsoBoot *node; /* node of the catalog */
|
||||
struct el_torito_boot_image *image; /* default boot image */
|
||||
|
||||
/* ts B00419 */
|
||||
/* Byte 1 of Validation Entry: 0= 80x86, 1= PowerPC, 2= Mac, 0xef= EFI */
|
||||
uint8_t platform_id;
|
||||
|
||||
/* >>> ts B00419 : List of further boot images */
|
||||
|
||||
};
|
||||
|
||||
struct el_torito_boot_image {
|
||||
|
@ -2206,17 +2206,18 @@ int read_el_torito_boot_catalog(_ImageFsData *data, uint32_t block)
|
||||
/* check if it is a valid catalog (TODO: check also the checksum)*/
|
||||
if ( (ve->header_id[0] != 1) || (ve->key_byte1[0] != 0x55)
|
||||
|| (ve->key_byte2[0] != 0xAA) ) {
|
||||
|
||||
return iso_msg_submit(data->msgid, ISO_WRONG_EL_TORITO, 0,
|
||||
iso_msg_submit(data->msgid, ISO_WRONG_EL_TORITO, 0,
|
||||
"Wrong or damaged El-Torito Catalog. El-Torito info "
|
||||
"will be ignored.");
|
||||
return ISO_WRONG_EL_TORITO;
|
||||
}
|
||||
|
||||
/* check for a valid platform */
|
||||
if (ve->platform_id[0] != 0) {
|
||||
return iso_msg_submit(data->msgid, ISO_UNSUPPORTED_EL_TORITO, 0,
|
||||
"Unsupported El-Torito platform. Only 80x86 is "
|
||||
if (ve->platform_id[0] != 0 && ve->platform_id[0] != 0xef) {
|
||||
iso_msg_submit(data->msgid, ISO_UNSUPPORTED_EL_TORITO, 0,
|
||||
"Unsupported El-Torito platform. Only 80x86 and EFI are "
|
||||
"supported. El-Torito info will be ignored.");
|
||||
return ISO_UNSUPPORTED_EL_TORITO;
|
||||
}
|
||||
|
||||
/* ok, once we are here we assume it is a valid catalog */
|
||||
@ -2425,21 +2426,18 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
|
||||
|| vol->vol_desc_version[0] != 1
|
||||
|| strncmp((char*)vol->boot_sys_id,
|
||||
"EL TORITO SPECIFICATION", 23)) {
|
||||
|
||||
ret = iso_msg_submit(data->msgid,
|
||||
iso_msg_submit(data->msgid,
|
||||
ISO_UNSUPPORTED_EL_TORITO, 0,
|
||||
"Unsupported Boot Vol. Desc. Only El-Torito "
|
||||
"Specification, Version 1.0 Volume "
|
||||
"Descriptors are supported. Ignoring boot info");
|
||||
if (ret < 0) {
|
||||
} else {
|
||||
data->catblock = iso_read_lsb(vol->boot_catalog, 4);
|
||||
ret = read_el_torito_boot_catalog(data, data->catblock);
|
||||
if (ret < 0 && ret != ISO_UNSUPPORTED_EL_TORITO &&
|
||||
ret != ISO_WRONG_EL_TORITO) {
|
||||
goto fs_cleanup;
|
||||
}
|
||||
break;
|
||||
}
|
||||
data->catblock = iso_read_lsb(vol->boot_catalog, 4);
|
||||
ret = read_el_torito_boot_catalog(data, data->catblock);
|
||||
if (ret < 0) {
|
||||
goto fs_cleanup;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2489,11 +2487,8 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
ret = iso_msg_submit(data->msgid, ISO_UNSUPPORTED_VD, 0,
|
||||
"Ignoring Volume descriptor %x.", buffer[0]);
|
||||
if (ret < 0) {
|
||||
goto fs_cleanup;
|
||||
}
|
||||
iso_msg_submit(data->msgid, ISO_UNSUPPORTED_VD, 0,
|
||||
"Ignoring Volume descriptor %x.", buffer[0]);
|
||||
break;
|
||||
}
|
||||
block++;
|
||||
|
@ -2377,6 +2377,27 @@ int iso_image_get_boot_image(IsoImage *image, ElToritoBootImage **boot,
|
||||
*/
|
||||
void iso_image_remove_boot_image(IsoImage *image);
|
||||
|
||||
/**
|
||||
* Sets the platform ID of the boot catalog that is attached to an IsoImage.
|
||||
*
|
||||
* A boot catalog gets attached by iso_image_set_boot_image() and removed
|
||||
* by iso_image_remove_boot_image(). It is described in El Torito specs.
|
||||
* Platform ID is byte 1 of the Validation Entry, i.e. byte 1 of the boot
|
||||
* catalog record.
|
||||
*
|
||||
* @param image
|
||||
* The image to manipulate.
|
||||
* @param id
|
||||
* A Platform ID as of
|
||||
* El Torito 1.0 : 0x00= 80x86, 0x01= PowerPC, 0x02= Mac
|
||||
* Others : 0xef= EFI
|
||||
* @return
|
||||
* 0= no boot catalog attached , 1= ok , <0 = error
|
||||
*
|
||||
* @since 0.6.32
|
||||
*/
|
||||
int iso_image_set_boot_platform_id(IsoImage *image, uint8_t id);
|
||||
|
||||
/**
|
||||
* Sets the load segment for the initial boot image. This is only for
|
||||
* no emulation boot images, and is a NOP for other image types.
|
||||
@ -5541,11 +5562,11 @@ int iso_md5_match(char first_md5[16], char second_md5[16]);
|
||||
/** Unsupported ECMA-119 feature (FAILURE,HIGH, -324) */
|
||||
#define ISO_UNSUPPORTED_ECMA119 0xE830FEBC
|
||||
|
||||
/** Wrong or damaged El-Torito catalog (SORRY,HIGH, -325) */
|
||||
#define ISO_WRONG_EL_TORITO 0xE030FEBB
|
||||
/** Wrong or damaged El-Torito catalog (WARN,HIGH, -325) */
|
||||
#define ISO_WRONG_EL_TORITO 0xD030FEBB
|
||||
|
||||
/** Unsupported El-Torito feature (SORRY,HIGH, -326) */
|
||||
#define ISO_UNSUPPORTED_EL_TORITO 0xE030FEBA
|
||||
/** Unsupported El-Torito feature (WARN,HIGH, -326) */
|
||||
#define ISO_UNSUPPORTED_EL_TORITO 0xD030FEBA
|
||||
|
||||
/** Can't patch an isolinux boot image (SORRY,HIGH, -327) */
|
||||
#define ISO_ISOLINUX_CANT_PATCH 0xE030FEB9
|
||||
|
Loading…
Reference in New Issue
Block a user