Add an option to load a generic boot image into the first 32K of the

cd9660 image.
This commit is contained in:
skrll 2008-05-10 19:00:07 +00:00
parent bd60b91d0a
commit 989d6357d3
4 changed files with 68 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd9660.c,v 1.19 2007/04/07 17:14:58 christos Exp $ */
/* $NetBSD: cd9660.c,v 1.20 2008/05/10 19:00:07 skrll Exp $ */
/*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@ -103,7 +103,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
__RCSID("$NetBSD: cd9660.c,v 1.19 2007/04/07 17:14:58 christos Exp $");
__RCSID("$NetBSD: cd9660.c,v 1.20 2008/05/10 19:00:07 skrll Exp $");
#endif /* !__lint */
#include <string.h>
@ -239,6 +239,9 @@ cd9660_set_defaults(void)
cd9660_defaults_set = 1;
/* Boot support: Initially disabled */
diskStructure.has_generic_bootimage = 0;
diskStructure.generic_bootimage = NULL;
diskStructure.boot_image_directory = 0;
/*memset(diskStructure.boot_descriptor, 0, 2048);*/
@ -381,6 +384,11 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
cd9660_arguments_set_string(val, "Boot Image Directory",
12 , 'd', diskStructure.boot_image_directory);
}
} else if (CD9660_IS_COMMAND_ARG_DUAL(var, "G", "generic-bootimage")) {
if (val == NULL)
warnx("error: The Boot Image parameter requires a valid boot information string");
else
rv = cd9660_add_generic_bootimage(val);
} else if (CD9660_IS_COMMAND_ARG(var, "no-trailing-padding"))
diskStructure.include_padding_areas = 0;
/* RRIP */
@ -2078,3 +2086,39 @@ cd9660_create_special_directory(u_char type, cd9660node *parent)
return temp;
}
int
cd9660_add_generic_bootimage(const char *bootimage)
{
struct stat stbuf;
assert(bootimage != NULL);
if (*bootimage == '\0') {
warnx("Error: Boot image must be a filename");
return 0;
}
if ((diskStructure.generic_bootimage = strdup(bootimage)) == NULL) {
warn("%s: strdup", __func__);
return 0;
}
/* Get information about the file */
if (lstat(diskStructure.generic_bootimage, &stbuf) == -1)
err(EXIT_FAILURE, "%s: lstat(\"%s\")", __func__,
diskStructure.generic_bootimage);
if (stbuf.st_size > 32768) {
warnx("Error: Boot image must be no greater than 32768 bytes");
return 0;
}
if (diskStructure.verbose_level > 0) {
printf("Generic boot image image has size %lld\n",
(long long)stbuf.st_size);
}
diskStructure.has_generic_bootimage = 1;
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd9660.h,v 1.10 2006/02/01 22:19:34 dyoung Exp $ */
/* $NetBSD: cd9660.h,v 1.11 2008/05/10 19:00:07 skrll Exp $ */
/*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@ -294,6 +294,9 @@ typedef struct _iso9660_disk {
u_char omit_trailing_period;
/* BOOT INFORMATION HERE */
int has_generic_bootimage; /* Default to 0 */
char *generic_bootimage;
int is_bootable;/* Default to 0 */
int boot_catalog_sector;
boot_volume_descriptor *boot_descriptor;
@ -325,6 +328,8 @@ void cd9660_time_8426(unsigned char *, time_t);
void cd9660_time_915(unsigned char *, time_t);
/*** Boot Functions ***/
int cd9660_write_generic_bootimage(FILE *);
int cd9660_add_generic_bootimage(const char *);
int cd9660_write_boot(FILE *);
int cd9660_add_boot_disk(const char *);
int cd9660_eltorito_add_boot_option(const char *, const char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd9660_write.c,v 1.8 2006/04/22 17:33:55 christos Exp $ */
/* $NetBSD: cd9660_write.c,v 1.9 2008/05/10 19:00:07 skrll Exp $ */
/*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
__RCSID("$NetBSD: cd9660_write.c,v 1.8 2006/04/22 17:33:55 christos Exp $");
__RCSID("$NetBSD: cd9660_write.c,v 1.9 2008/05/10 19:00:07 skrll Exp $");
#endif /* !__lint */
static int cd9660_write_volume_descriptors(FILE *);
@ -71,6 +71,16 @@ cd9660_write_image(const char* image)
if (diskStructure.verbose_level > 0)
printf("Writing image\n");
if (diskStructure.has_generic_bootimage) {
status = cd9660_copy_file(fd, 0,
diskStructure.generic_bootimage);
if (status == 0) {
warnx("%s: Error writing generic boot image",
__func__);
goto cleanup_bad_image;
}
}
/* Write the volume descriptors */
status = cd9660_write_volume_descriptors(fd);
if (status == 0) {

View File

@ -1,4 +1,4 @@
.\" $NetBSD: makefs.8,v 1.29 2007/12/02 19:19:16 wiz Exp $
.\" $NetBSD: makefs.8,v 1.30 2008/05/10 19:00:07 skrll Exp $
.\"
.\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
.\" All rights reserved.
@ -33,7 +33,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd April 13, 2007
.Dd May 10, 2008
.Dt MAKEFS 8
.Os
.Sh NAME
@ -290,6 +290,8 @@ is one of
.Ql macppc ,
or
.Ql powerpc .
.It Sy generic-bootimage
Load a generic boot image into the first 32K of the cd9660 image.
.It Sy hard-disk-boot
Boot image is a hard disk image.
.It Sy keep-bad-images