Giving sort weight 2 as default to El Torito boot images.

This commit is contained in:
Thomas Schmitt 2013-09-07 21:37:27 +02:00
parent 7aa2582129
commit b95e1bb85c
3 changed files with 22 additions and 3 deletions

View File

@ -312,7 +312,8 @@ int iso_tree_add_boot_node(IsoDir *parent, const char *name, IsoBoot **boot)
static static
int create_image(IsoImage *image, const char *image_path, int create_image(IsoImage *image, const char *image_path,
enum eltorito_boot_media_type type, enum eltorito_boot_media_type type,
struct el_torito_boot_image **bootimg) struct el_torito_boot_image **bootimg,
IsoFile **bootnode)
{ {
int ret; int ret;
struct el_torito_boot_image *boot; struct el_torito_boot_image *boot;
@ -323,6 +324,7 @@ int create_image(IsoImage *image, const char *image_path,
IsoNode *imgfile; IsoNode *imgfile;
IsoStream *stream; IsoStream *stream;
*bootnode = NULL;
ret = iso_tree_path_to_node(image, image_path, &imgfile); ret = iso_tree_path_to_node(image, image_path, &imgfile);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
@ -337,6 +339,7 @@ int create_image(IsoImage *image, const char *image_path,
if (imgfile->type != LIBISO_FILE) { if (imgfile->type != LIBISO_FILE) {
return ISO_BOOT_IMAGE_NOT_VALID; return ISO_BOOT_IMAGE_NOT_VALID;
} }
*bootnode = (IsoFile *) imgfile;
stream = ((IsoFile*)imgfile)->stream; stream = ((IsoFile*)imgfile)->stream;
@ -461,6 +464,7 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path,
struct el_torito_boot_catalog *catalog; struct el_torito_boot_catalog *catalog;
ElToritoBootImage *boot_image= NULL; ElToritoBootImage *boot_image= NULL;
IsoBoot *cat_node= NULL; IsoBoot *cat_node= NULL;
IsoFile *boot_node;
if (image == NULL || image_path == NULL || catalog_path == NULL) { if (image == NULL || image_path == NULL || catalog_path == NULL) {
return ISO_NULL_POINTER; return ISO_NULL_POINTER;
@ -513,7 +517,7 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path,
} }
/* create the boot image */ /* create the boot image */
ret = create_image(image, image_path, type, &boot_image); ret = create_image(image, image_path, type, &boot_image, &boot_node);
if (ret < 0) { if (ret < 0) {
goto boot_image_cleanup; goto boot_image_cleanup;
} }
@ -530,6 +534,8 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path,
catalog->bootimages[i] = NULL; catalog->bootimages[i] = NULL;
catalog->node = cat_node; catalog->node = cat_node;
catalog->sort_weight = 1000; /* slightly high */ catalog->sort_weight = 1000; /* slightly high */
if (!boot_node->explicit_weight)
boot_node->sort_weight = 2;
iso_node_ref((IsoNode*)cat_node); iso_node_ref((IsoNode*)cat_node);
image->bootcat = catalog; image->bootcat = catalog;
@ -700,14 +706,17 @@ int iso_image_add_boot_image(IsoImage *image, const char *image_path,
int ret; int ret;
struct el_torito_boot_catalog *catalog = image->bootcat; struct el_torito_boot_catalog *catalog = image->bootcat;
ElToritoBootImage *boot_img; ElToritoBootImage *boot_img;
IsoFile *boot_node;
if(catalog == NULL) if(catalog == NULL)
return ISO_BOOT_NO_CATALOG; return ISO_BOOT_NO_CATALOG;
if (catalog->num_bootimages >= Libisofs_max_boot_imageS) if (catalog->num_bootimages >= Libisofs_max_boot_imageS)
return ISO_BOOT_IMAGE_OVERFLOW; return ISO_BOOT_IMAGE_OVERFLOW;
ret = create_image(image, image_path, type, &boot_img); ret = create_image(image, image_path, type, &boot_img, &boot_node);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (!boot_node->explicit_weight)
boot_node->sort_weight = 2;
catalog->bootimages[catalog->num_bootimages] = boot_img; catalog->bootimages[catalog->num_bootimages] = boot_img;
catalog->num_bootimages++; catalog->num_bootimages++;
if (boot != NULL) if (boot != NULL)

View File

@ -1048,6 +1048,7 @@ void iso_node_set_sort_weight(IsoNode *node, int w)
} }
} else if (node->type == LIBISO_FILE) { } else if (node->type == LIBISO_FILE) {
((IsoFile*)node)->sort_weight = w; ((IsoFile*)node)->sort_weight = w;
((IsoFile*)node)->explicit_weight = 1;
} }
} }
@ -1430,6 +1431,8 @@ 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->from_old_session = 0;
new->explicit_weight = 0;
new->sort_weight = 0; new->sort_weight = 0;
new->stream = stream; new->stream = stream;

View File

@ -149,8 +149,15 @@ struct Iso_File
{ {
IsoNode node; IsoNode node;
/* 1 = The node was loaded from an existing ISO image and still refers
to its data content there.
*/
unsigned int from_old_session : 1; unsigned int from_old_session : 1;
/* 1 = The node got attributed a weight by iso_node_set_sort_weight().
*/
unsigned int explicit_weight : 1;
/** /**
* It sorts the order in which the file data is written to the CD image. * It sorts the order in which the file data is written to the CD image.
* Higher weighting files are written at the beginning of image * Higher weighting files are written at the beginning of image