/[debburn]/cdrkit/trunk/genisoimage/eltorito.c
ViewVC logotype

Contents of /cdrkit/trunk/genisoimage/eltorito.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 449 - (hide annotations) (download)
Thu Nov 23 21:26:50 2006 UTC (6 years, 5 months ago) by blade
Original Path: cdrkit/trunk/mkisoimage/eltorito.c
File MIME type: text/plain
File size: 19499 byte(s)
Mvoing mkisofs nach mkisoimage
1 blade 174 /*
2     * This file has been modified for the cdrkit suite.
3     *
4     * The behaviour and appearence of the program code below can differ to a major
5     * extent from the version distributed by the original author(s).
6     *
7     * For details, see Changelog file distributed with the cdrkit package. If you
8     * received this file from another source then ask the distributing person for
9     * a log of modifications.
10     *
11     */
12    
13 blade 2 /* @(#)eltorito.c 1.33 05/02/27 joerg */
14     #ifndef lint
15     static char sccsid[] =
16     "@(#)eltorito.c 1.33 05/02/27 joerg";
17    
18     #endif
19     /*
20     * Program eltorito.c - Handle El Torito specific extensions to iso9660.
21     *
22     *
23     * Written by Michael Fulbright <msf@redhat.com> (1996).
24     *
25     * Copyright 1996 RedHat Software, Incorporated
26     * Copyright (c) 1999-2004 J. Schilling
27     *
28     * This program is free software; you can redistribute it and/or modify
29     * it under the terms of the GNU General Public License as published by
30     * the Free Software Foundation; either version 2, or (at your option)
31     * any later version.
32     *
33     * This program is distributed in the hope that it will be useful,
34     * but WITHOUT ANY WARRANTY; without even the implied warranty of
35     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36     * GNU General Public License for more details.
37     *
38     * You should have received a copy of the GNU General Public License
39     * along with this program; if not, write to the Free Software
40     * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
41     */
42    
43     #include <mconfig.h>
44     #include "mkisofs.h"
45     #include <fctldefs.h>
46     #include <utypes.h>
47     #include <intcvt.h>
48     #include "match.h"
49     #include "diskmbr.h"
50     #include "bootinfo.h"
51     #include <schily.h>
52    
53     #undef MIN
54     #define MIN(a, b) (((a) < (b))? (a): (b))
55    
56     static struct eltorito_validation_entry valid_desc;
57     static struct eltorito_boot_descriptor gboot_desc;
58     static struct disk_master_boot_record disk_mbr;
59     static unsigned int bcat_de_flags;
60    
61 kaner-guest 368 void init_boot_catalog(const char *path);
62     void insert_boot_cat(void);
63     static void get_torito_desc(struct eltorito_boot_descriptor *boot_desc);
64     static void fill_boot_desc(struct eltorito_defaultboot_entry *boot_desc_entry,
65     struct eltorito_boot_entry_info *boot_entry);
66     void get_boot_entry(void);
67     void new_boot_entry(void);
68     static int tvd_write(FILE *outfile);
69 blade 2
70    
71 kaner-guest 368 static char *bootcat_path; /* filename of boot catalog */
72 blade 2 /*
73     * Make sure any existing boot catalog is excluded
74     */
75     void
76 kaner-guest 368 init_boot_catalog(const char *path)
77 blade 2 {
78     #ifdef SORTING
79     struct eltorito_boot_entry_info * cbe;
80    
81     for (cbe = first_boot_entry;
82     cbe != NULL;
83     cbe = cbe->next) {
84     char *p;
85    
86     if (cbe->boot_image == NULL)
87     comerrno(EX_BAD, "Missing boot image name, use -eltorito-boot option.\n");
88     p = (char *) e_malloc(strlen(cbe->boot_image) + strlen(path) + 2);
89     strcpy(p, path);
90     if (p[strlen(p) - 1] != '/') {
91     strcat(p, "/");
92     }
93     strcat(p, cbe->boot_image);
94     add_sort_match(p, sort_matches(p, 1));
95     free(p);
96     }
97     #endif
98     bootcat_path = (char *) e_malloc(strlen(boot_catalog) + strlen(path) + 2);
99     strcpy(bootcat_path, path);
100     if (bootcat_path[strlen(bootcat_path) - 1] != '/') {
101     strcat(bootcat_path, "/");
102     }
103     strcat(bootcat_path, boot_catalog);
104    
105     /*
106     * we are going to create a virtual catalog file
107     * - so make sure any existing is excluded
108     */
109     add_match(bootcat_path);
110    
111     /* flag the file as a memory file */
112     bcat_de_flags = MEMORY_FILE;
113    
114     /* find out if we want to "hide" this file */
115     if (i_matches(boot_catalog) || i_matches(bootcat_path))
116     bcat_de_flags |= INHIBIT_ISO9660_ENTRY;
117    
118     if (j_matches(boot_catalog) || j_matches(bootcat_path))
119     bcat_de_flags |= INHIBIT_JOLIET_ENTRY;
120    
121     }/* init_boot_catalog(... */
122    
123     /*
124     * Create a boot catalog file in memory - mkisofs already uses this type of
125     * file for the TRANS.TBL files. Therefore the boot catalog is set up in
126     * similar way
127     */
128     void
129     insert_boot_cat()
130     {
131     struct directory_entry *de;
132     struct directory_entry *s_entry;
133     char *p1;
134     char *p2;
135     char *p3;
136     struct directory *this_dir;
137     struct directory *dir;
138     char *buffer;
139    
140     init_fstatbuf();
141    
142     buffer = (char *) e_malloc(SECTOR_SIZE);
143     memset(buffer, 0, SECTOR_SIZE);
144    
145     /*
146     * try to find the directory that will contain the boot.cat file
147     * - not very neat, but I can't think of a better way
148     */
149     p1 = strdup(boot_catalog);
150    
151     /* get dirname (p1) and basename (p2) of boot.cat */
152     if ((p2 = strrchr(p1, '/')) != NULL) {
153     *p2 = '\0';
154     p2++;
155    
156     /* find the dirname directory entry */
157     de = search_tree_file(root, p1);
158     if (!de) {
159     #ifdef USE_LIBSCHILY
160     comerrno(EX_BAD,
161     "Uh oh, I cant find the boot catalog directory '%s'!\n",
162     p1);
163     #else
164     fprintf(stderr,
165     "Uh oh, I cant find the boot catalog directory '%s'!\n",
166     p1);
167     exit(1);
168     #endif
169     }
170     this_dir = 0;
171    
172     /* get the basename (p3) of the directory */
173     if ((p3 = strrchr(p1, '/')) != NULL)
174     p3++;
175     else
176     p3 = p1;
177    
178     /* find the correct sub-directory entry */
179     for (dir = de->filedir->subdir; dir; dir = dir->next)
180     if (!(strcmp(dir->de_name, p3)))
181     this_dir = dir;
182    
183     if (this_dir == 0) {
184     #ifdef USE_LIBSCHILY
185     comerrno(EX_BAD,
186     "Uh oh, I cant find the boot catalog directory '%s'!\n",
187     p3);
188     #else
189     fprintf(stderr,
190     "Uh oh, I cant find the boot catalog directory '%s'!\n",
191     p3);
192     exit(1);
193     #endif
194     }
195     } else {
196     /* boot.cat is in the root directory */
197     this_dir = root;
198     p2 = p1;
199     }
200    
201     /*
202     * make a directory entry in memory (using the same set up as for table
203     * entries
204     */
205     s_entry = (struct directory_entry *)
206     e_malloc(sizeof (struct directory_entry));
207     memset(s_entry, 0, sizeof (struct directory_entry));
208     s_entry->next = this_dir->contents;
209     this_dir->contents = s_entry;
210    
211     #ifdef SORTING
212     /* inherit any sort weight from parent directory */
213     s_entry->sort = this_dir->sort;
214     s_entry->sort += 2;
215    
216     /* see if this entry should have a new weighting */
217     if (do_sort) {
218     s_entry->sort = sort_matches(bootcat_path, s_entry->sort);
219     }
220     #endif /* SORTING */
221    
222     s_entry->isorec.flags[0] = ISO_FILE;
223     s_entry->priority = 32768;
224     iso9660_date(s_entry->isorec.date, fstatbuf.st_mtime);
225     s_entry->inode = TABLE_INODE;
226     s_entry->dev = (dev_t) UNCACHED_DEVICE;
227     set_723(s_entry->isorec.volume_sequence_number,
228     volume_sequence_number);
229     set_733((char *) s_entry->isorec.size, SECTOR_SIZE);
230     s_entry->size = SECTOR_SIZE;
231     s_entry->filedir = this_dir;
232     s_entry->name = strdup(p2);
233     iso9660_file_length(p2, s_entry, 0);
234    
235     /* flag file as necessary */
236     s_entry->de_flags = bcat_de_flags;
237    
238     if ((use_XA || use_RockRidge) &&
239     !(bcat_de_flags & INHIBIT_ISO9660_ENTRY)) {
240     fstatbuf.st_mode = 0444 | S_IFREG;
241     fstatbuf.st_nlink = 1;
242     generate_xa_rr_attributes("",
243     p2, s_entry,
244     &fstatbuf, &fstatbuf, 0);
245     }
246     /*
247     * memory files are stored at s_entry->table
248     * - but this is also used for each s_entry to generate
249     * TRANS.TBL entries. So if we are generating tables,
250     * store the TRANS.TBL data here for the moment
251     */
252     if (generate_tables && !(bcat_de_flags & INHIBIT_ISO9660_ENTRY)) {
253     sprintf(buffer, "F\t%s\n", s_entry->name);
254    
255     /* copy the TRANS.TBL entry info and clear the buffer */
256     s_entry->table = strdup(buffer);
257     memset(buffer, 0, SECTOR_SIZE);
258    
259     /*
260     * store the (empty) file data in the
261     * unused s_entry->whole_name element for the time being
262     * - this will be transferred to s_entry->table after any
263     * TRANS.TBL processing later
264     */
265     s_entry->whole_name = buffer;
266     } else {
267     /* store the (empty) file data in the s_entry->table element */
268     s_entry->table = buffer;
269     s_entry->whole_name = NULL;
270     }
271     }
272    
273     static void
274 kaner-guest 368 get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
275 blade 2 {
276     int checksum;
277     unsigned char *checksum_ptr;
278     struct directory_entry *de2; /* Boot catalog */
279     int i;
280     int offset;
281     struct eltorito_defaultboot_entry boot_desc_record;
282    
283     memset(boot_desc, 0, sizeof (*boot_desc));
284     boot_desc->type[0] = 0;
285     memcpy(boot_desc->id, ISO_STANDARD_ID, sizeof (ISO_STANDARD_ID));
286     boot_desc->version[0] = 1;
287    
288     memcpy(boot_desc->system_id, EL_TORITO_ID, sizeof (EL_TORITO_ID));
289    
290     /*
291     * search from root of iso fs to find boot catalog
292     * - we already know where the boot catalog is
293     * - we created it above - but lets search for it anyway
294     * - good sanity check!
295     */
296     de2 = search_tree_file(root, boot_catalog);
297     if (!de2 || !(de2->de_flags & MEMORY_FILE)) {
298     #ifdef USE_LIBSCHILY
299     comerrno(EX_BAD, "Uh oh, I cant find the boot catalog '%s'!\n",
300     boot_catalog);
301     #else
302     fprintf(stderr, "Uh oh, I cant find the boot catalog '%s'!\n",
303     boot_catalog);
304     exit(1);
305     #endif
306     }
307     set_731(boot_desc->bootcat_ptr,
308     (unsigned int) get_733(de2->isorec.extent));
309    
310     /*
311     * we have the boot image, so write boot catalog information
312     * Next we write out the primary descriptor for the disc
313     */
314     memset(&valid_desc, 0, sizeof (valid_desc));
315     valid_desc.headerid[0] = 1;
316     valid_desc.arch[0] = EL_TORITO_ARCH_x86;
317    
318     /*
319     * we'll shove start of publisher id into id field,
320     * may get truncated but who really reads this stuff!
321     */
322     if (publisher)
323     memcpy_max(valid_desc.id, publisher,
324     MIN(23, strlen(publisher)));
325    
326     valid_desc.key1[0] = (char) 0x55;
327     valid_desc.key2[0] = (char) 0xAA;
328    
329     /* compute the checksum */
330     checksum = 0;
331     checksum_ptr = (unsigned char *) &valid_desc;
332     /* Set checksum to 0 before computing checksum */
333     set_721(valid_desc.cksum, 0);
334     for (i = 0; i < (int)sizeof (valid_desc); i += 2) {
335     checksum += (unsigned int) checksum_ptr[i];
336     checksum += ((unsigned int) checksum_ptr[i + 1]) * 256;
337     }
338    
339     /* now find out the real checksum */
340     checksum = -checksum;
341     set_721(valid_desc.cksum, (unsigned int) checksum);
342    
343     /* now write it to the virtual boot catalog */
344     memcpy(de2->table, &valid_desc, 32);
345    
346     for (current_boot_entry = first_boot_entry, offset = sizeof (valid_desc);
347     current_boot_entry != NULL;
348     current_boot_entry = current_boot_entry->next,
349     offset += sizeof (boot_desc_record)) {
350    
351     if (offset >= SECTOR_SIZE) {
352     #ifdef USE_LIBSCHILY
353     comerrno(EX_BAD,
354     "Too many El Torito boot entries\n");
355     #else
356     fprintf(stderr,
357     "Too many El Torito boot entries\n");
358     exit(1);
359     #endif
360     }
361     fill_boot_desc(&boot_desc_record, current_boot_entry);
362     memcpy(de2->table + offset, &boot_desc_record,
363     sizeof (boot_desc_record));
364     }
365     }/* get_torito_desc(... */
366    
367     static void
368 kaner-guest 368 fill_boot_desc(struct eltorito_defaultboot_entry *boot_desc_entry,
369     struct eltorito_boot_entry_info *boot_entry)
370 blade 2 {
371     struct directory_entry *de; /* Boot file */
372     int bootmbr;
373     int i;
374     int nsectors;
375     int geosec;
376    
377     if (!boot_desc_entry || !boot_entry)
378     return;
379    
380     /* now adjust boot catalog lets find boot image first */
381     de = search_tree_file(root, boot_entry->boot_image);
382     if (!de) {
383     #ifdef USE_LIBSCHILY
384     comerrno(EX_BAD, "Uh oh, I cant find the boot image '%s' !\n",
385     boot_entry->boot_image);
386     #else
387     fprintf(stderr, "Uh oh, I cant find the boot image '%s' !\n",
388     boot_entry->boot_image);
389     exit(1);
390     #endif
391     }
392     /* now make the initial/default entry for boot catalog */
393     memset(boot_desc_entry, 0, sizeof (*boot_desc_entry));
394     boot_desc_entry->boot_id[0] = (char) boot_entry->not_bootable ?
395     EL_TORITO_NOT_BOOTABLE : EL_TORITO_BOOTABLE;
396    
397     /* use default BIOS loadpnt */
398     set_721(boot_desc_entry->loadseg, boot_entry->load_addr);
399    
400     /*
401     * figure out size of boot image in 512-byte sectors.
402     * However, round up to the nearest integral CD (2048-byte) sector.
403     * This is only used for no-emulation booting.
404     */
405     nsectors = boot_entry->load_size ? boot_entry->load_size :
406     ISO_BLOCKS(de->size) * (SECTOR_SIZE/512);
407    
408     if (verbose > 0) {
409     fprintf(stderr,
410     "Size of boot image is %d sectors -> ", nsectors);
411     }
412    
413     if (boot_entry->hard_disk_boot) {
414     /* sanity test hard disk boot image */
415     boot_desc_entry->boot_media[0] = EL_TORITO_MEDIA_HD;
416     if (verbose > 0)
417     fprintf(stderr, "Emulating a hard disk\n");
418    
419     /* read MBR */
420     bootmbr = open(de->whole_name, O_RDONLY | O_BINARY);
421     if (bootmbr == -1) {
422     #ifdef USE_LIBSCHILY
423     comerr("Error opening boot image '%s' for read.\n",
424     de->whole_name);
425     #else
426     fprintf(stderr,
427     "Error opening boot image '%s' for read.\n",
428     de->whole_name);
429     perror("");
430     exit(1);
431     #endif
432     }
433     if (read(bootmbr, &disk_mbr, sizeof (disk_mbr)) !=
434     sizeof (disk_mbr)) {
435     #ifdef USE_LIBSCHILY
436     comerr("Error reading MBR from boot image '%s'.\n",
437     de->whole_name);
438     #else
439     fprintf(stderr,
440     "Error reading MBR from boot image '%s'.\n",
441     de->whole_name);
442     exit(1);
443     #endif
444     }
445     close(bootmbr);
446     if (la_to_u_2_byte(disk_mbr.magic) != MBR_MAGIC) {
447     #ifdef USE_LIBSCHILY
448     errmsgno(EX_BAD,
449     "Warning: boot image '%s' MBR is not a boot sector.\n",
450     de->whole_name);
451     #else
452     fprintf(stderr,
453     "Warning: boot image '%s' MBR is not a boot sector.\n",
454     de->whole_name);
455     #endif
456     }
457     /* find partition type */
458     boot_desc_entry->sys_type[0] = PARTITION_UNUSED;
459     for (i = 0; i < PARTITION_COUNT; ++i) {
460     int s_cyl_sec;
461     int e_cyl_sec;
462    
463     s_cyl_sec =
464     la_to_u_2_byte(disk_mbr.partition[i].s_cyl_sec);
465     e_cyl_sec =
466     la_to_u_2_byte(disk_mbr.partition[i].e_cyl_sec);
467    
468     if (disk_mbr.partition[i].type != PARTITION_UNUSED) {
469     if (boot_desc_entry->sys_type[0] !=
470     PARTITION_UNUSED) {
471     #ifdef USE_LIBSCHILY
472     comerrno(EX_BAD,
473     "Boot image '%s' has multiple partitions.\n",
474     de->whole_name);
475     #else
476     fprintf(stderr,
477     "Boot image '%s' has multiple partitions.\n",
478     de->whole_name);
479     exit(1);
480     #endif
481     }
482     boot_desc_entry->sys_type[0] =
483     disk_mbr.partition[i].type;
484    
485     /* a few simple sanity warnings */
486     if (!boot_entry->not_bootable &&
487     disk_mbr.partition[i].status !=
488     PARTITION_ACTIVE) {
489     fprintf(stderr,
490     "Warning: partition not marked active.\n");
491     }
492     if (MBR_CYLINDER(s_cyl_sec) != 0 ||
493     disk_mbr.partition[i].s_head != 1 ||
494     MBR_SECTOR(s_cyl_sec != 1)) {
495     fprintf(stderr,
496     "Warning: partition does not start at 0/1/1.\n");
497     }
498     geosec = (MBR_CYLINDER(e_cyl_sec) + 1) *
499     (disk_mbr.partition[i].e_head + 1) *
500     MBR_SECTOR(e_cyl_sec);
501     if (geosec != nsectors) {
502     fprintf(stderr,
503     "Warning: image size does not match geometry (%d)\n",
504     geosec);
505     }
506     #ifdef DEBUG_TORITO
507     fprintf(stderr, "Partition start %u/%u/%u\n",
508     MBR_CYLINDER(s_cyl_sec),
509     disk_mbr.partition[i].s_head,
510     MBR_SECTOR(s_cyl_sec));
511     fprintf(stderr, "Partition end %u/%u/%u\n",
512     MBR_CYLINDER(e_cyl_sec),
513     disk_mbr.partition[i].e_head,
514     MBR_SECTOR(e_cyl_sec));
515     #endif
516     }
517     }
518     if (boot_desc_entry->sys_type[0] == PARTITION_UNUSED) {
519     #ifdef USE_LIBSCHILY
520     comerrno(EX_BAD,
521     "Boot image '%s' has no partitions.\n",
522     de->whole_name);
523     #else
524     fprintf(stderr,
525     "Boot image '%s' has no partitions.\n",
526     de->whole_name);
527     exit(1);
528     #endif
529     }
530     #ifdef DEBUG_TORITO
531     fprintf(stderr, "Partition type %u\n",
532     boot_desc_entry->sys_type[0]);
533     #endif
534     /* load single boot sector, in this case the MBR */
535     nsectors = 1;
536    
537     } else if (boot_entry->no_emul_boot) {
538     /*
539     * no emulation is a simple image boot of all the sectors
540     * in the boot image
541     */
542     boot_desc_entry->boot_media[0] = EL_TORITO_MEDIA_NOEMUL;
543     if (verbose > 0)
544     fprintf(stderr, "No emulation\n");
545    
546     } else {
547     /* choose size of emulated floppy based on boot image size */
548     if (nsectors == 2880) {
549     boot_desc_entry->boot_media[0] = EL_TORITO_MEDIA_144FLOP;
550     if (verbose > 0)
551     fprintf(stderr, "Emulating a 1440 kB floppy\n");
552    
553     } else if (nsectors == 5760) {
554     boot_desc_entry->boot_media[0] = EL_TORITO_MEDIA_288FLOP;
555     if (verbose > 0)
556     fprintf(stderr, "Emulating a 2880 kB floppy\n");
557    
558     } else if (nsectors == 2400) {
559     boot_desc_entry->boot_media[0] = EL_TORITO_MEDIA_12FLOP;
560     if (verbose > 0)
561     fprintf(stderr, "Emulating a 1200 kB floppy\n");
562    
563     } else {
564     #ifdef USE_LIBSCHILY
565     comerrno(EX_BAD,
566     "Error - boot image '%s' has not an allowable size.\n",
567     de->whole_name);
568     #else
569     fprintf(stderr,
570     "Error - boot image '%s' has not an allowable size.\n",
571     de->whole_name);
572     exit(1);
573     #endif
574     }
575    
576     /* load single boot sector for floppies */
577     nsectors = 1;
578     }
579    
580     /* fill in boot image details */
581     #ifdef DEBUG_TORITO
582     fprintf(stderr, "Boot %u sectors\n", nsectors);
583     fprintf(stderr, "Extent of boot images is %d\n",
584     get_733(de->isorec.extent));
585     #endif
586     set_721(boot_desc_entry->nsect, (unsigned int) nsectors);
587     set_731(boot_desc_entry->bootoff,
588     (unsigned int) get_733(de->isorec.extent));
589    
590    
591     /* If the user has asked for it, patch the boot image */
592     if (boot_entry->boot_info_table) {
593     int bootimage;
594     unsigned int bi_checksum;
595     unsigned int total_len;
596     static char csum_buffer[SECTOR_SIZE];
597     int len;
598     struct mkisofs_boot_info bi_table;
599    
600     bootimage = open(de->whole_name, O_RDWR | O_BINARY);
601     if (bootimage == -1) {
602     #ifdef USE_LIBSCHILY
603     comerr(
604     "Error opening boot image file '%s' for update.\n",
605     de->whole_name);
606     #else
607     fprintf(stderr,
608     "Error opening boot image file '%s' for update.\n",
609     de->whole_name);
610     perror("");
611     exit(1);
612     #endif
613     }
614     /* Compute checksum of boot image, sans 64 bytes */
615     total_len = 0;
616     bi_checksum = 0;
617     while ((len = read(bootimage, csum_buffer, SECTOR_SIZE)) > 0) {
618     if (total_len & 3) {
619     #ifdef USE_LIBSCHILY
620     comerrno(EX_BAD,
621     "Odd alignment at non-end-of-file in boot image '%s'.\n",
622     de->whole_name);
623     #else
624     fprintf(stderr,
625     "Odd alignment at non-end-of-file in boot image '%s'.\n",
626     de->whole_name);
627     exit(1);
628     #endif
629     }
630     if (total_len < 64)
631     memset(csum_buffer, 0, 64 - total_len);
632     if (len < SECTOR_SIZE)
633     memset(csum_buffer + len, 0, SECTOR_SIZE-len);
634     for (i = 0; i < SECTOR_SIZE; i += 4)
635     bi_checksum += get_731(&csum_buffer[i]);
636     total_len += len;
637     }
638    
639     if (total_len != de->size) {
640     #ifdef USE_LIBSCHILY
641     comerrno(EX_BAD,
642     "Boot image file '%s' changed underneath us!\n",
643     de->whole_name);
644     #else
645     fprintf(stderr,
646     "Boot image file '%s' changed underneath us!\n",
647     de->whole_name);
648     exit(1);
649     #endif
650     }
651     /* End of file, set position to byte 8 */
652     lseek(bootimage, (off_t)8, SEEK_SET);
653     memset(&bi_table, 0, sizeof (bi_table));
654     /* Is it always safe to assume PVD is at session_start+16? */
655     set_731(bi_table.bi_pvd, session_start + 16);
656     set_731(bi_table.bi_file, de->starting_block);
657     set_731(bi_table.bi_length, de->size);
658     set_731(bi_table.bi_csum, bi_checksum);
659    
660     write(bootimage, &bi_table, sizeof (bi_table));
661     close(bootimage);
662     }
663     }/* fill_boot_desc(... */
664    
665     void
666     get_boot_entry()
667     {
668     if (current_boot_entry)
669     return;
670    
671     current_boot_entry = (struct eltorito_boot_entry_info *)
672     e_malloc(sizeof (struct eltorito_boot_entry_info));
673     memset(current_boot_entry, 0, sizeof (*current_boot_entry));
674    
675     if (!first_boot_entry) {
676     first_boot_entry = current_boot_entry;
677     last_boot_entry = current_boot_entry;
678     } else {
679     last_boot_entry->next = current_boot_entry;
680     last_boot_entry = current_boot_entry;
681     }
682     }
683    
684     void
685     new_boot_entry()
686     {
687     current_boot_entry = NULL;
688     }
689    
690     /*
691     * Function to write the EVD for the disc.
692     */
693     static int
694 kaner-guest 368 tvd_write(FILE *outfile)
695 blade 2 {
696     /* check the boot image is not NULL */
697     if (!boot_image) {
698     #ifdef USE_LIBSCHILY
699     comerrno(EX_BAD, "No boot image specified.\n");
700     #else
701     fprintf(stderr, "No boot image specified.\n");
702     exit(1);
703     #endif
704     }
705     /* Next we write out the boot volume descriptor for the disc */
706     get_torito_desc(&gboot_desc);
707 blade 39 jtwrite(&gboot_desc, SECTOR_SIZE, 1, 0, FALSE);
708 blade 2 xfwrite(&gboot_desc, SECTOR_SIZE, 1, outfile, 0, FALSE);
709     last_extent_written++;
710     return (0);
711     }
712    
713     struct output_fragment torito_desc = {NULL, oneblock_size, NULL, tvd_write, "Eltorito Volume Descriptor"};

  ViewVC Help
Powered by ViewVC 1.1.5