tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Generic boot image support in makefs(8)
Hi,
I added an option to makefs(8) to write a file into the first 32K of a cd9660
image. This can be used to create bootable NetBSD/hp700 CDs.
Any comments before I commit?
Nick
? usr.sbin/makefs/.gdbinit
? usr.sbin/makefs/cscope.out
Index: usr.sbin/makefs/cd9660.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/makefs/cd9660.c,v
retrieving revision 1.19
diff -u -p -u -r1.19 cd9660.c
--- usr.sbin/makefs/cd9660.c 7 Apr 2007 17:14:58 -0000 1.19
+++ usr.sbin/makefs/cd9660.c 13 Jan 2008 16:38:06 -0000
@@ -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, fs
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 t
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;
+}
Index: usr.sbin/makefs/cd9660.h
===================================================================
RCS file: /cvsroot/src/usr.sbin/makefs/cd9660.h,v
retrieving revision 1.10
diff -u -p -u -r1.10 cd9660.h
--- usr.sbin/makefs/cd9660.h 1 Feb 2006 22:19:34 -0000 1.10
+++ usr.sbin/makefs/cd9660.h 13 Jan 2008 16:38:07 -0000
@@ -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
*,
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 *);
Index: usr.sbin/makefs/makefs.8
===================================================================
RCS file: /cvsroot/src/usr.sbin/makefs/makefs.8,v
retrieving revision 1.29
diff -u -p -u -r1.29 makefs.8
--- usr.sbin/makefs/makefs.8 2 Dec 2007 19:19:16 -0000 1.29
+++ usr.sbin/makefs/makefs.8 13 Jan 2008 16:38:07 -0000
@@ -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 January 13, 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
Index: usr.sbin/makefs/cd9660/cd9660_write.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/makefs/cd9660/cd9660_write.c,v
retrieving revision 1.8
diff -u -p -u -r1.8 cd9660_write.c
--- usr.sbin/makefs/cd9660/cd9660_write.c 22 Apr 2006 17:33:55 -0000
1.8
+++ usr.sbin/makefs/cd9660/cd9660_write.c 13 Jan 2008 16:38:07 -0000
@@ -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) {
Home |
Main Index |
Thread Index |
Old Index