Changed new API call from iso_image_set_boot_platform_id() to

el_torito_set_boot_platform_id().
Introduced new API call iso_image_set_boot_catalog_weight().
This commit is contained in:
Thomas Schmitt 2010-04-20 16:23:17 +02:00
parent 517f520570
commit da2c0520cc
4 changed files with 48 additions and 16 deletions

View File

@ -56,6 +56,13 @@ struct hard_disc_mbr {
uint8_t sign2; uint8_t sign2;
}; };
/* API */
int el_torito_set_boot_platform_id(ElToritoBootImage *bootimg, uint8_t id)
{
bootimg->platform_id = id;
return 1;
}
/** /**
* Sets the load segment for the initial boot image. This is only for * 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. * no emulation boot images, and is a NOP for other image types.
@ -339,6 +346,7 @@ int create_image(IsoImage *image, const char *image_path,
boot->partition_type = partition_type; boot->partition_type = partition_type;
boot->load_seg = 0; boot->load_seg = 0;
boot->load_size = load_sectors; boot->load_size = load_sectors;
boot->platform_id = 0; /* 80x86 */
if (bootimg) { if (bootimg) {
*bootimg = boot; *bootimg = boot;
@ -418,7 +426,7 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path,
} }
catalog->image = boot_image; catalog->image = boot_image;
catalog->node = cat_node; catalog->node = cat_node;
catalog->platform_id = 0; /* Default is 80x86 */ catalog->sort_weight = 1000; /* slightly high */
iso_node_ref((IsoNode*)cat_node); iso_node_ref((IsoNode*)cat_node);
image->bootcat = catalog; image->bootcat = catalog;
@ -521,11 +529,11 @@ void iso_image_remove_boot_image(IsoImage *image)
} }
/* API */ /* API */
int iso_image_set_boot_platform_id(IsoImage *image, uint8_t id) int iso_image_set_boot_catalog_weight(IsoImage *image, int sort_weight)
{ {
if (image->bootcat == NULL) if (image->bootcat == NULL)
return 0; return 0;
image->bootcat->platform_id = id; image->bootcat->sort_weight = sort_weight;
return 1; return 1;
} }
@ -735,7 +743,7 @@ int catalog_stream_new(Ecma119Image *target, IsoStream **stream)
/* fill data */ /* fill data */
data->target = target; data->target = target;
data->offset = -1; data->offset = -1;
data->platform_id = target->catalog->platform_id; data->platform_id = target->catalog->image->platform_id;
str->refcount = 1; str->refcount = 1;
str->data = data; str->data = data;
@ -777,7 +785,7 @@ int el_torito_catalog_file_src_create(Ecma119Image *target, IsoFileSrc **src)
file->checksum_index = 0; file->checksum_index = 0;
file->nsections = 1; file->nsections = 1;
file->sections = calloc(1, sizeof(struct iso_file_section)); file->sections = calloc(1, sizeof(struct iso_file_section));
file->sort_weight = 1000; /* slightly high */ file->sort_weight = target->catalog->sort_weight;
file->stream = stream; file->stream = stream;
ret = iso_file_src_add(target, file, src); ret = iso_file_src_add(target, file, src);

View File

@ -32,8 +32,8 @@ struct el_torito_boot_catalog {
struct el_torito_boot_image *image; /* default boot image */ struct el_torito_boot_image *image; /* default boot image */
/* ts B00419 */ /* ts B00419 */
/* Byte 1 of Validation Entry: 0= 80x86, 1= PowerPC, 2= Mac, 0xef= EFI */ /* Weight value for image sorting */
uint8_t platform_id; int sort_weight;
/* >>> ts B00419 : List of further boot images */ /* >>> ts B00419 : List of further boot images */
@ -54,6 +54,11 @@ struct el_torito_boot_image {
unsigned char partition_type; /**< type of partition for HD-emul images */ unsigned char partition_type; /**< type of partition for HD-emul images */
short load_seg; /**< Load segment for the initial boot image. */ short load_seg; /**< Load segment for the initial boot image. */
short load_size; /**< Number of sectors to load. */ short load_size; /**< Number of sectors to load. */
/* ts B00419 */
/* Byte 1 of Validation Entry or Section Header Entry:
0= 80x86, 1= PowerPC, 2= Mac, 0xef= EFI */
uint8_t platform_id;
}; };
/** El-Torito, 2.1 */ /** El-Torito, 2.1 */

View File

@ -2378,25 +2378,42 @@ int iso_image_get_boot_image(IsoImage *image, ElToritoBootImage **boot,
void iso_image_remove_boot_image(IsoImage *image); void iso_image_remove_boot_image(IsoImage *image);
/** /**
* Sets the platform ID of the boot catalog that is attached to an IsoImage. * Sets the sort weight of the boot catalog that is attached to an IsoImage.
* *
* A boot catalog gets attached by iso_image_set_boot_image() and removed * For the meaning of sort weights see iso_node_set_sort_weight().
* by iso_image_remove_boot_image(). It is described in El Torito specs. * That function cannot be applied to the emerging boot catalog because
* Platform ID is byte 1 of the Validation Entry, i.e. byte 1 of the boot * it is not represented by an IsoNode.
* catalog record.
* *
* @param image * @param image
* The image to manipulate. * The image to manipulate.
* @param sort_weight
* The larger this value, the lower will be the block address of the
* boot catalog record.
* @return
* 0= no boot catalog attached , 1= ok , <0 = error
*
* @since 0.6.32
*/
int iso_image_set_boot_catalog_weight(IsoImage *image, int sort_weight);
/**
* Sets the platform ID of the boot image.
*
* The Platform ID gets written into the boot catalog at byte 1 of the
* Validation Entry, or at byte 1 of a Section Header Entry.
*
* @param bootimg
* The image to manipulate.
* @param id * @param id
* A Platform ID as of * A Platform ID as of
* El Torito 1.0 : 0x00= 80x86, 0x01= PowerPC, 0x02= Mac * El Torito 1.0 : 0x00= 80x86, 0x01= PowerPC, 0x02= Mac
* Others : 0xef= EFI * Others : 0xef= EFI
* @return * @return
* 0= no boot catalog attached , 1= ok , <0 = error * 1 ok , <=0 error
* *
* @since 0.6.32 * @since 0.6.32
*/ */
int iso_image_set_boot_platform_id(IsoImage *image, uint8_t id); int el_torito_set_boot_platform_id(ElToritoBootImage *bootimg, uint8_t id);
/** /**
* Sets the load segment for the initial boot image. This is only for * Sets the load segment for the initial boot image. This is only for
@ -3173,8 +3190,8 @@ const char *iso_symlink_get_dest(const IsoSymlink *link);
int iso_symlink_set_dest(IsoSymlink *link, const char *dest); int iso_symlink_set_dest(IsoSymlink *link, const char *dest);
/** /**
* Sets the order in which a node will be written on image. High weihted files * Sets the order in which a node will be written on image. The data content
* will be written first, so in a disc them will be written near the center. * of files with high weight will be written to low block addresses.
* *
* @param node * @param node
* The node which weight will be changed. If it's a dir, this function * The node which weight will be changed. If it's a dir, this function
@ -3183,6 +3200,7 @@ int iso_symlink_set_dest(IsoSymlink *link, const char *dest);
* @param w * @param w
* The weight as a integer number, the greater this value is, the * The weight as a integer number, the greater this value is, the
* closer from the begining of image the file will be written. * closer from the begining of image the file will be written.
* Default value at IsoNode creation is 0.
* *
* @since 0.6.2 * @since 0.6.2
*/ */

View File

@ -1284,6 +1284,7 @@ int iso_node_new_file(char *name, IsoStream *stream, IsoFile **file)
new->node.type = LIBISO_FILE; new->node.type = LIBISO_FILE;
new->node.name = name; new->node.name = name;
new->node.mode = S_IFREG; new->node.mode = S_IFREG;
new->sort_weight = 0;
new->stream = stream; new->stream = stream;
*file = new; *file = new;