ReactOS  0.4.14-dev-583-g2a1ba2c
eltorito.c File Reference
#include <schily/mconfig.h>
#include "mkisofs.h"
#include <schily/fcntl.h>
#include <schily/utypes.h>
#include <schily/intcvt.h>
#include "match.h"
#include "diskmbr.h"
#include "bootinfo.h"
#include <schily/schily.h>
Include dependency graph for eltorito.c:

Go to the source code of this file.

Macros

#define MIN(a, b)   (((a) < (b))? (a): (b))
 

Functions

EXPORT void init_boot_catalog __PR ((const char *path))
 
EXPORT void insert_boot_cat __PR ((void))
 
LOCAL void get_torito_desc __PR ((struct eltorito_boot_descriptor *boot_desc))
 
LOCAL void fill_boot_shdr __PR ((struct eltorito_sectionheader_entry *boot_shdr_entry, int arch))
 
LOCAL void fill_boot_desc __PR ((struct eltorito_defaultboot_entry *boot_desc_entry, struct eltorito_boot_entry_info *boot_entry))
 
EXPORT void ex_boot_enoent __PR ((char *msg, char *pname))
 
LOCAL int tvd_write __PR ((FILE *outfile))
 
EXPORT void init_boot_catalog (char *path) const
 
EXPORT void insert_boot_cat ()
 
LOCAL void get_torito_desc (struct eltorito_boot_descriptor *boot_desc)
 
LOCAL void fill_boot_shdr (struct eltorito_sectionheader_entry *boot_shdr_entry, int arch)
 
LOCAL void fill_boot_desc (struct eltorito_defaultboot_entry *boot_desc_entry, struct eltorito_boot_entry_info *boot_entry)
 
EXPORT void get_boot_entry ()
 
EXPORT int new_boot_entry ()
 
EXPORT void ex_boot_enoent (char *msg, char *pname)
 
LOCAL int tvd_write (FILE *outfile)
 

Variables

static UConst char sccsid []
 
LOCAL struct eltorito_validation_entry valid_desc
 
LOCAL struct eltorito_boot_descriptor gboot_desc
 
LOCAL struct disk_master_boot_record disk_mbr
 
LOCAL unsigned int bcat_de_flags
 
LOCAL charbootcat_path
 
struct output_fragment torito_desc = {NULL, oneblock_size, NULL, tvd_write, "Eltorito Volume Descriptor"}
 

Macro Definition Documentation

◆ MIN

#define MIN (   a,
  b 
)    (((a) < (b))? (a): (b))

Definition at line 42 of file eltorito.c.

Function Documentation

◆ __PR() [1/7]

◆ __PR() [2/7]

◆ __PR() [3/7]

◆ __PR() [4/7]

LOCAL void fill_boot_shdr __PR ( (struct eltorito_sectionheader_entry *boot_shdr_entry, int arch)  )

◆ __PR() [5/7]

◆ __PR() [6/7]

◆ __PR() [7/7]

LOCAL int tvd_write __PR ( (FILE *outfile )

◆ ex_boot_enoent()

EXPORT void ex_boot_enoent ( char msg,
char pname 
)

Definition at line 660 of file eltorito.c.

663 {
664  comerrno(EX_BAD, _("Uh oh, I cant find the boot %s '%s' inside the target tree.\n"), msg, pname);
665  /* NOTREACHED */
666 }
GLenum pname
Definition: glext.h:5645
#define _(X)
Definition: i386-dis.c:36
EXPORT void comerrno(int err, char *msg, va_alist)
Definition: comerr.c:137
#define msg(x)
Definition: auth_time.c:54
#define EX_BAD
Definition: standard.h:62

Referenced by fill_boot_desc(), get_torito_desc(), and insert_boot_cat().

◆ fill_boot_desc()

LOCAL void fill_boot_desc ( struct eltorito_defaultboot_entry boot_desc_entry,
struct eltorito_boot_entry_info boot_entry 
)

Definition at line 400 of file eltorito.c.

403 {
404  struct directory_entry *de; /* Boot file */
405  int bootmbr;
406  int i;
407  int nsectors;
408  int geosec;
409 
410  if (!boot_desc_entry || !boot_entry)
411  return;
412 
413  /* now adjust boot catalog lets find boot image first */
414  de = search_tree_file(root, boot_entry->boot_image);
415  if (!de) {
416  ex_boot_enoent(_("image"), boot_entry->boot_image);
417  /* NOTREACHED */
418  }
419  /* now make the initial/default entry for boot catalog */
420  memset(boot_desc_entry, 0, sizeof (*boot_desc_entry));
421  boot_desc_entry->boot_id[0] = (char)boot_entry->not_bootable ?
423 
424  /* use default BIOS loadpnt */
425  set_721(boot_desc_entry->loadseg, boot_entry->load_addr);
426 
427  /*
428  * figure out size of boot image in 512-byte sectors.
429  * However, round up to the nearest integral CD (2048-byte) sector.
430  * This is only used for no-emulation booting.
431  */
432  nsectors = boot_entry->load_size ? boot_entry->load_size :
433  ISO_BLOCKS(de->size) * (SECTOR_SIZE/512);
434 
435  if (verbose > 0) {
436  fprintf(stderr,
437  _("Size of boot image is %d sectors -> "), nsectors);
438  }
439 
440  if (boot_entry->hard_disk_boot) {
441  /* sanity test hard disk boot image */
442  boot_desc_entry->boot_media[0] = EL_TORITO_MEDIA_HD;
443  if (verbose > 0)
444  fprintf(stderr, _("Emulating a hard disk\n"));
445 
446  /* read MBR */
447  bootmbr = open(de->whole_name, O_RDONLY | O_BINARY);
448  if (bootmbr == -1) {
449  comerr(_("Error opening boot image '%s' for read.\n"),
450  de->whole_name);
451  }
452  if (read(bootmbr, &disk_mbr, sizeof (disk_mbr)) !=
453  sizeof (disk_mbr)) {
454  comerr(_("Error reading MBR from boot image '%s'.\n"),
455  de->whole_name);
456  }
457  close(bootmbr);
458  if (la_to_u_2_byte(disk_mbr.magic) != MBR_MAGIC) {
460  _("Warning: boot image '%s' MBR is not a boot sector.\n"),
461  de->whole_name);
462  }
463  /* find partition type */
464  boot_desc_entry->sys_type[0] = PARTITION_UNUSED;
465  for (i = 0; i < PARTITION_COUNT; ++i) {
466  int s_cyl_sec;
467  int e_cyl_sec;
468 
469  s_cyl_sec =
470  la_to_u_2_byte(disk_mbr.partition[i].s_cyl_sec);
471  e_cyl_sec =
472  la_to_u_2_byte(disk_mbr.partition[i].e_cyl_sec);
473 
474  if (disk_mbr.partition[i].type != PARTITION_UNUSED) {
475  if (boot_desc_entry->sys_type[0] !=
478  _("Boot image '%s' has multiple partitions.\n"),
479  de->whole_name);
480  }
481  boot_desc_entry->sys_type[0] =
482  disk_mbr.partition[i].type;
483 
484  /* a few simple sanity warnings */
485  if (!boot_entry->not_bootable &&
486  disk_mbr.partition[i].status !=
488  fprintf(stderr,
489  _("Warning: partition not marked active.\n"));
490  }
491  if (MBR_CYLINDER(s_cyl_sec) != 0 ||
492  disk_mbr.partition[i].s_head != 1 ||
493  MBR_SECTOR(s_cyl_sec != 1)) {
494  fprintf(stderr,
495  _("Warning: partition does not start at 0/1/1.\n"));
496  }
497  geosec = (MBR_CYLINDER(e_cyl_sec) + 1) *
498  (disk_mbr.partition[i].e_head + 1) *
499  MBR_SECTOR(e_cyl_sec);
500  if (geosec != nsectors) {
501  fprintf(stderr,
502  _("Warning: image size does not match geometry (%d)\n"),
503  geosec);
504  }
505 #ifdef DEBUG_TORITO
506  fprintf(stderr, "Partition start %u/%u/%u\n",
507  MBR_CYLINDER(s_cyl_sec),
508  disk_mbr.partition[i].s_head,
509  MBR_SECTOR(s_cyl_sec));
510  fprintf(stderr, "Partition end %u/%u/%u\n",
511  MBR_CYLINDER(e_cyl_sec),
512  disk_mbr.partition[i].e_head,
513  MBR_SECTOR(e_cyl_sec));
514 #endif
515  }
516  }
517  if (boot_desc_entry->sys_type[0] == PARTITION_UNUSED) {
519  _("Boot image '%s' has no partitions.\n"),
520  de->whole_name);
521  }
522 #ifdef DEBUG_TORITO
523  fprintf(stderr, "Partition type %u\n",
524  boot_desc_entry->sys_type[0]);
525 #endif
526  /* load single boot sector, in this case the MBR */
527  nsectors = 1;
528 
529  } else if (boot_entry->no_emul_boot) {
530  /*
531  * no emulation is a simple image boot of all the sectors
532  * in the boot image
533  */
534  boot_desc_entry->boot_media[0] = EL_TORITO_MEDIA_NOEMUL;
535  if (verbose > 0)
536  fprintf(stderr, _("No emulation\n"));
537 
538  } else {
539  /* choose size of emulated floppy based on boot image size */
540  if (nsectors == 2880) {
541  boot_desc_entry->boot_media[0] = EL_TORITO_MEDIA_144FLOP;
542  if (verbose > 0)
543  fprintf(stderr, _("Emulating a 1440 kB floppy\n"));
544 
545  } else if (nsectors == 5760) {
546  boot_desc_entry->boot_media[0] = EL_TORITO_MEDIA_288FLOP;
547  if (verbose > 0)
548  fprintf(stderr, _("Emulating a 2880 kB floppy\n"));
549 
550  } else if (nsectors == 2400) {
551  boot_desc_entry->boot_media[0] = EL_TORITO_MEDIA_12FLOP;
552  if (verbose > 0)
553  fprintf(stderr, _("Emulating a 1200 kB floppy\n"));
554 
555  } else {
557  _("Error - boot image '%s' has not an allowable size.\n"),
558  de->whole_name);
559  }
560 
561  /* load single boot sector for floppies */
562  nsectors = 1;
563  }
564 
565  /* fill in boot image details */
566 #ifdef DEBUG_TORITO
567  fprintf(stderr, "Boot %u sectors\n", nsectors);
568  fprintf(stderr, "Extent of boot images is %d\n",
569  get_733(de->isorec.extent));
570 #endif
571  set_721(boot_desc_entry->nsect, (unsigned int) nsectors);
572  set_731(boot_desc_entry->bootoff,
573  (unsigned int) get_733(de->isorec.extent));
574 
575 
576  /* If the user has asked for it, patch the boot image */
577  if (boot_entry->boot_info_table) {
578  int bootimage;
579  unsigned int bi_checksum;
580  unsigned int total_len;
581  static char csum_buffer[SECTOR_SIZE];
582  int len;
583  struct mkisofs_boot_info bi_table;
584 
585  bootimage = open(de->whole_name, O_RDWR | O_BINARY);
586  if (bootimage == -1) {
587  comerr(
588  _("Error opening boot image file '%s' for update.\n"),
589  de->whole_name);
590  }
591  /* Compute checksum of boot image, sans 64 bytes */
592  total_len = 0;
593  bi_checksum = 0;
594  while ((len = read(bootimage, csum_buffer, SECTOR_SIZE)) > 0) {
595  if (total_len & 3) {
597  _("Odd alignment at non-end-of-file in boot image '%s'.\n"),
598  de->whole_name);
599  }
600  if (total_len < 64)
601  memset(csum_buffer, 0, 64 - total_len);
602  if (len < SECTOR_SIZE)
603  memset(csum_buffer + len, 0, SECTOR_SIZE-len);
604  for (i = 0; i < SECTOR_SIZE; i += 4)
605  bi_checksum += get_731(&csum_buffer[i]);
606  total_len += len;
607  }
608 
609  if (total_len != de->size) {
611  _("Boot image file '%s' changed underneath us!\n"),
612  de->whole_name);
613  }
614  /* End of file, set position to byte 8 */
615  lseek(bootimage, (off_t)8, SEEK_SET);
616  memset(&bi_table, 0, sizeof (bi_table));
617  /* Is it always safe to assume PVD is at session_start+16? */
618  set_731(bi_table.bi_pvd, session_start + 16);
619  set_731(bi_table.bi_file, de->starting_block);
620  set_731(bi_table.bi_length, de->size);
621  set_731(bi_table.bi_csum, bi_checksum);
622 
623  write(bootimage, &bi_table, sizeof (bi_table));
624  close(bootimage);
625  }
626 } /* fill_boot_desc(... */
char boot_id[ISODCL(1, 1)]
Definition: iso9660.h:168
EXPORT UInt32_t get_731(void *vp)
Definition: isonum.c:187
EXPORT void comerr(char *msg, va_alist)
Definition: comerr.c:84
#define MBR_CYLINDER(x)
Definition: diskmbr.h:34
Definition: mkisofs.h:107
#define open
Definition: acwin.h:95
#define PARTITION_ACTIVE
Definition: diskmbr.h:29
EXPORT void set_721(void *vp, UInt32_t i)
Definition: isonum.c:46
unsigned int starting_block
Definition: mkisofs.h:111
__kernel_off_t off_t
Definition: linux.h:201
_Check_return_opt_ _CRTIMP long __cdecl lseek(_In_ int _FileHandle, _In_ long _Offset, _In_ int _Origin)
EXPORT void set_731(void *vp, UInt32_t i)
Definition: isonum.c:91
#define MBR_MAGIC
Definition: bootblock.h:210
#define la_to_u_2_byte(a)
Definition: intcvt.h:93
#define EL_TORITO_BOOTABLE
Definition: iso9660.h:55
#define EL_TORITO_MEDIA_NOEMUL
Definition: iso9660.h:58
EXPORT struct directory_entry * search_tree_file(struct directory *node, char *filename)
Definition: tree.c:2885
#define EL_TORITO_MEDIA_288FLOP
Definition: iso9660.h:61
char loadseg[ISODCL(3, 4)]
Definition: iso9660.h:170
#define verbose
Definition: rosglue.h:36
#define write
Definition: acwin.h:97
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define _(X)
Definition: i386-dis.c:36
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
struct iso_directory_record isorec
Definition: mkisofs.h:110
EXPORT UInt32_t get_733(void *vp)
Definition: isonum.c:219
unsigned char
Definition: typeof.h:29
char * whole_name
Definition: mkisofs.h:118
#define ISO_BLOCKS(X)
Definition: mkisofs.h:743
#define SEEK_SET
Definition: jmemansi.c:26
UInt32_t session_start
Definition: mkisofs.c:77
LOCAL struct disk_master_boot_record disk_mbr
Definition: eltorito.c:59
#define EL_TORITO_NOT_BOOTABLE
Definition: iso9660.h:56
char nsect[ISODCL(7, 8)]
Definition: iso9660.h:173
GLenum GLsizei len
Definition: glext.h:6722
off_t size
Definition: mkisofs.h:112
#define close
Definition: acwin.h:98
Definition: cdmake.c:111
#define EL_TORITO_MEDIA_HD
Definition: iso9660.h:62
#define O_RDWR
Definition: fcntl.h:36
EXPORT void ex_boot_enoent(char *msg, char *pname)
Definition: eltorito.c:660
#define PARTITION_UNUSED
Definition: diskmbr.h:28
#define O_BINARY
Definition: acwin.h:109
#define EL_TORITO_MEDIA_12FLOP
Definition: iso9660.h:59
#define PARTITION_COUNT
Definition: diskmbr.h:31
char bootoff[ISODCL(9, 12)]
Definition: iso9660.h:174
EXPORT void comerrno(int err, char *msg, va_alist)
Definition: comerr.c:137
#define MBR_SECTOR(x)
Definition: diskmbr.h:33
char sys_type[ISODCL(5, 5)]
Definition: iso9660.h:171
FILE * stderr
#define EL_TORITO_MEDIA_144FLOP
Definition: iso9660.h:60
#define SECTOR_SIZE
Definition: fs.h:22
#define memset(x, y, z)
Definition: compat.h:39
char boot_media[ISODCL(2, 2)]
Definition: iso9660.h:169
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
EXPORT int errmsgno(int err, char *msg, va_alist)
Definition: comerr.c:219
#define O_RDONLY
Definition: acwin.h:108
#define EX_BAD
Definition: standard.h:62

Referenced by get_torito_desc().

◆ fill_boot_shdr()

LOCAL void fill_boot_shdr ( struct eltorito_sectionheader_entry boot_shdr_entry,
int  arch 
)

Definition at line 390 of file eltorito.c.

393 {
394  memset(boot_shdr_entry, 0, sizeof (struct eltorito_sectionheader_entry));
395  boot_shdr_entry->header_id[0] = EL_TORITO_SHDR_ID_SHDR;
396  boot_shdr_entry->platform_id[0] = arch;
397 }
Definition: iso9660.h:179
#define EL_TORITO_SHDR_ID_SHDR
Definition: iso9660.h:180
char header_id[ISODCL(1, 1)]
Definition: iso9660.h:182
char platform_id[ISODCL(2, 2)]
Definition: iso9660.h:183
#define memset(x, y, z)
Definition: compat.h:39

Referenced by get_torito_desc().

◆ get_boot_entry()

EXPORT void get_boot_entry ( )

Definition at line 629 of file eltorito.c.

630 {
631  if (current_boot_entry)
632  return;
633 
635  e_malloc(sizeof (struct eltorito_boot_entry_info));
637 
638  if (!first_boot_entry) {
641  current_boot_entry->boot_platform = EL_TORITO_ARCH_x86;
642  } else {
643  current_boot_entry->boot_platform = last_boot_entry->boot_platform;
646  }
647 }
struct eltorito_boot_entry_info * last_boot_entry
Definition: mkisofs.c:227
#define EL_TORITO_ARCH_x86
Definition: iso9660.h:50
struct eltorito_boot_entry_info * current_boot_entry
Definition: mkisofs.c:228
struct eltorito_boot_entry_info * first_boot_entry
Definition: mkisofs.c:226
EXPORT void * e_malloc(size_t size)
Definition: mkisofs.c:3921
#define memset(x, y, z)
Definition: compat.h:39
Definition: mkisofs.h:311

Referenced by get_boot_addr(), get_boot_image(), get_boot_platid(), get_boot_size(), get_boot_table(), get_hd_boot(), get_ne_boot(), and get_no_boot().

◆ get_torito_desc()

LOCAL void get_torito_desc ( struct eltorito_boot_descriptor boot_desc)

Definition at line 253 of file eltorito.c.

255 {
256  int checksum;
257  unsigned char *checksum_ptr;
258  struct directory_entry *de2; /* Boot catalog */
259  int i;
260  int offset;
261  int arch = 0;
262  int nentries = 0;
263  struct eltorito_defaultboot_entry boot_desc_record;
264  struct eltorito_sectionheader_entry boot_shdr_record;
265 #ifdef __needed__
266  struct eltorito_section_entry boot_section_record;
267 #endif
268  struct eltorito_sectionheader_entry *last_section_header = 0;
269 
270  memset(boot_desc, 0, sizeof (*boot_desc));
271  boot_desc->type[0] = 0;
272  strncpy(boot_desc->id, ISO_STANDARD_ID, sizeof (boot_desc->id));
273  boot_desc->version[0] = 1;
274 
276 
277  /*
278  * search from root of iso fs to find boot catalog
279  * - we already know where the boot catalog is
280  * - we created it above - but lets search for it anyway
281  * - good sanity check!
282  */
284  if (!de2 || !(de2->de_flags & MEMORY_FILE)) {
285  ex_boot_enoent(_("catalog"), boot_catalog);
286  /* NOTREACHED */
287  }
288  set_731(boot_desc->bootcat_ptr,
289  (unsigned int) get_733(de2->isorec.extent));
290 
291  /*
292  * If the platform id for the first (default) boot entry has not been
293  * explicitly set, we default to EL_TORITO_ARCH_x86
294  */
295  if ((first_boot_entry->type & ELTORITO_BOOT_ID) == 0) {
296  first_boot_entry->boot_platform = EL_TORITO_ARCH_x86;
297  }
298  arch = first_boot_entry->boot_platform;
299 
300  /*
301  * we have the boot image, so write boot catalog information
302  * Next we write out the primary descriptor for the disc
303  */
304  memset(&valid_desc, 0, sizeof (valid_desc));
305  valid_desc.headerid[0] = 1;
306  valid_desc.arch[0] = arch; /* Platform id for the default boot */
307 
308  /*
309  * we'll shove start of publisher id into id field,
310  * may get truncated but who really reads this stuff!
311  */
312  if (publisher)
314  MIN(23, strlen(publisher)));
315 
316  valid_desc.key1[0] = (char)0x55;
317  valid_desc.key2[0] = (char)0xAA;
318 
319  /* compute the checksum */
320  checksum = 0;
321  checksum_ptr = (unsigned char *) &valid_desc;
322  /* Set checksum to 0 before computing checksum */
323  set_721(valid_desc.cksum, 0);
324  for (i = 0; i < (int)sizeof (valid_desc); i += 2) {
325  checksum += (unsigned int) checksum_ptr[i];
326  checksum += ((unsigned int) checksum_ptr[i + 1]) * 256;
327  }
328 
329  /* now find out the real checksum */
330  checksum = -checksum;
331  set_721(valid_desc.cksum, (unsigned int) checksum);
332 
333  /* now write it to the virtual boot catalog */
334  memcpy(de2->table, &valid_desc, 32);
335 
339  offset += sizeof (boot_desc_record)) {
340  int newarch = arch;
341 
343  newarch = current_boot_entry->boot_platform;
344  else
345  current_boot_entry->boot_platform = arch;
346 
347  /*
348  * El Torito has no such limitation but we currently have...
349  */
350  if (offset >= (SECTOR_SIZE - sizeof (boot_desc_record))) {
352  _("Too many El Torito boot entries\n"));
353  }
355  ;
356  /* EMPTY */
357  } else if ((current_boot_entry == first_boot_entry->next) ||
358  (arch != newarch) ||
360  if (last_section_header)
361  set_721(&last_section_header->entry_count, nentries);
362  nentries = 1;
363  last_section_header = (struct eltorito_sectionheader_entry *)
364  (de2->table + offset);
365  fill_boot_shdr(&boot_shdr_record, newarch);
366  memcpy(de2->table + offset, &boot_shdr_record,
367  sizeof (boot_shdr_record));
368  offset += sizeof (boot_desc_record);
369  } else {
370  nentries++; /* Add entry to this section header */
371  }
372  /*
373  * This works because a section entry has the same essential
374  * layout as a default entry (and we do not populate the
375  * selection criteria fields).
376  */
377  fill_boot_desc(&boot_desc_record, current_boot_entry);
378  memcpy(de2->table + offset, &boot_desc_record,
379  sizeof (boot_desc_record));
380  }
381 
382  if (last_section_header) {
383  set_721(&last_section_header->entry_count, nentries);
384  last_section_header->header_id[0] = EL_TORITO_SHDR_ID_LAST_SHDR;
385  }
386 
387 } /* get_torito_desc(... */
unsigned int de_flags
Definition: mkisofs.h:122
Definition: iso9660.h:167
LOCAL void fill_boot_shdr(struct eltorito_sectionheader_entry *boot_shdr_entry, int arch)
Definition: eltorito.c:390
char * table
Definition: mkisofs.h:117
#define ELTORITO_BOOT_ID
Definition: mkisofs.h:321
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
Definition: mkisofs.h:107
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: iso9660.h:189
EXPORT void set_721(void *vp, UInt32_t i)
Definition: isonum.c:46
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
GLintptr offset
Definition: glext.h:5920
char type[ISODCL(1, 1)]
Definition: iso9660.h:141
#define EL_TORITO_ARCH_x86
Definition: iso9660.h:50
char bootcat_ptr[ISODCL(72, 75)]
Definition: iso9660.h:146
EXPORT void set_731(void *vp, UInt32_t i)
Definition: isonum.c:91
#define ISO_STANDARD_ID
Definition: iso9660.h:47
char * publisher
Definition: mkisofs.c:160
EXPORT struct directory_entry * search_tree_file(struct directory *node, char *filename)
Definition: tree.c:2885
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define _(X)
Definition: i386-dis.c:36
struct iso_directory_record isorec
Definition: mkisofs.h:110
EXPORT UInt32_t get_733(void *vp)
Definition: isonum.c:219
smooth NULL
Definition: ftsmooth.c:416
char id[ISODCL(2, 6)]
Definition: iso9660.h:142
unsigned char
Definition: typeof.h:29
char system_id[ISODCL(8, 39)]
Definition: iso9660.h:144
#define EL_TORITO_ID
Definition: iso9660.h:49
#define EL_TORITO_SHDR_ID_LAST_SHDR
Definition: iso9660.h:181
LOCAL void fill_boot_desc(struct eltorito_defaultboot_entry *boot_desc_entry, struct eltorito_boot_entry_info *boot_entry)
Definition: eltorito.c:400
#define ELTORITO_SECTION_HEADER
Definition: mkisofs.h:322
#define MEMORY_FILE
Definition: mkisofs.h:803
char version[ISODCL(7, 7)]
Definition: iso9660.h:143
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
Definition: fdi.c:353
struct eltorito_boot_entry_info * current_boot_entry
Definition: mkisofs.c:228
Definition: iso9660.h:179
struct eltorito_boot_entry_info * first_boot_entry
Definition: mkisofs.c:226
EXPORT void ex_boot_enoent(char *msg, char *pname)
Definition: eltorito.c:660
char header_id[ISODCL(1, 1)]
Definition: iso9660.h:182
EXPORT void memcpy_max(char *to, char *from, int max)
Definition: write.c:1880
#define MIN(a, b)
Definition: eltorito.c:42
char entry_count[ISODCL(3, 4)]
Definition: iso9660.h:184
EXPORT void comerrno(int err, char *msg, va_alist)
Definition: comerr.c:137
LOCAL struct eltorito_validation_entry valid_desc
Definition: eltorito.c:57
char * boot_catalog
Definition: mkisofs.c:168
#define SECTOR_SIZE
Definition: fs.h:22
#define memset(x, y, z)
Definition: compat.h:39
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define EX_BAD
Definition: standard.h:62

Referenced by tvd_write().

◆ init_boot_catalog()

EXPORT void init_boot_catalog ( char path) const

Definition at line 67 of file eltorito.c.

69 {
70 #ifdef SORTING
71  struct eltorito_boot_entry_info *cbe;
72 
73  for (cbe = first_boot_entry;
74  cbe != NULL;
75  cbe = cbe->next) {
76  char *p;
77 
78  if (cbe->boot_image == NULL)
79  comerrno(EX_BAD, _("Missing boot image name, use -eltorito-boot option.\n"));
80  p = (char *)e_malloc(strlen(cbe->boot_image) + strlen(path) + 2);
81  strcpy(p, path);
82  if (p[strlen(p) - 1] != '/') {
83  strcat(p, "/");
84  }
85  strcat(p, cbe->boot_image);
86  add_sort_match(p, sort_matches(p, 1));
87  free(p);
88  }
89 #endif
92  if (bootcat_path[strlen(bootcat_path) - 1] != '/') {
93  strcat(bootcat_path, "/");
94  }
96 
97  /*
98  * we are going to create a virtual catalog file
99  * - so make sure any existing is excluded
100  */
102 
103  /* flag the file as a memory file */
105 
106  /* find out if we want to "hide" this file */
109 
112 
115 
116 } /* init_boot_catalog(... */
LOCAL char * bootcat_path
Definition: eltorito.c:61
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
EXPORT int add_match(char *fn)
Definition: match.c:214
#define free
Definition: debug_ros.c:5
#define _(X)
Definition: i386-dis.c:36
smooth NULL
Definition: ftsmooth.c:416
char * boot_image
Definition: mkisofs.h:313
#define j_matches(FN)
Definition: match.h:77
#define INHIBIT_ISO9660_ENTRY
Definition: mkisofs.h:802
#define INHIBIT_JOLIET_ENTRY
Definition: mkisofs.h:799
#define INHIBIT_UDF_ENTRY
Definition: mkisofs.h:809
LOCAL unsigned int bcat_de_flags
Definition: eltorito.c:60
#define MEMORY_FILE
Definition: mkisofs.h:803
struct eltorito_boot_entry_info * first_boot_entry
Definition: mkisofs.c:226
struct eltorito_boot_entry_info * next
Definition: mkisofs.h:312
#define u_matches(FN)
Definition: match.h:81
EXPORT void comerrno(int err, char *msg, va_alist)
Definition: comerr.c:137
EXPORT void * e_malloc(size_t size)
Definition: mkisofs.c:3921
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
char * boot_catalog
Definition: mkisofs.c:168
GLfloat GLfloat p
Definition: glext.h:8902
Definition: mkisofs.h:311
#define i_matches(FN)
Definition: match.h:73
#define EX_BAD
Definition: standard.h:62

Referenced by main().

◆ insert_boot_cat()

EXPORT void insert_boot_cat ( )

Definition at line 124 of file eltorito.c.

125 {
126  struct directory_entry *de;
127  struct directory_entry *s_entry;
128  char *p1;
129  char *p2;
130  char *p3;
131  struct directory *this_dir;
132  struct directory *dir;
133  char *buffer;
134 
135  init_fstatbuf();
136 
137  buffer = (char *)e_malloc(SECTOR_SIZE);
139 
140  /*
141  * try to find the directory that will contain the boot.cat file
142  * - not very neat, but I can't think of a better way
143  */
144  p1 = e_strdup(boot_catalog);
145 
146  /* get dirname (p1) and basename (p2) of boot.cat */
147  if ((p2 = strrchr(p1, '/')) != NULL) {
148  *p2 = '\0';
149  p2++;
150 
151  /* find the dirname directory entry */
152  de = search_tree_file(root, p1);
153  if (!de) {
154  ex_boot_enoent(_("catalog directory"), p1);
155  /* NOTREACHED */
156  }
157  this_dir = 0;
158 
159  /* get the basename (p3) of the directory */
160  if ((p3 = strrchr(p1, '/')) != NULL)
161  p3++;
162  else
163  p3 = p1;
164 
165  /* find the correct sub-directory entry */
166  for (dir = de->filedir->subdir; dir; dir = dir->next)
167  if (strcmp(dir->de_name, p3) == 0)
168  this_dir = dir;
169 
170  if (this_dir == 0) {
171  ex_boot_enoent(_("catalog directory"), p3);
172  /* NOTREACHED */
173  }
174  } else {
175  /* boot.cat is in the root directory */
176  this_dir = root;
177  p2 = p1;
178  }
179 
180  /*
181  * make a directory entry in memory (using the same set up as for table
182  * entries
183  */
184  s_entry = (struct directory_entry *)
185  e_malloc(sizeof (struct directory_entry));
186  memset(s_entry, 0, sizeof (struct directory_entry));
187  s_entry->next = this_dir->contents;
188  this_dir->contents = s_entry;
189 
190 #ifdef SORTING
191  /* inherit any sort weight from parent directory */
192  s_entry->sort = this_dir->sort;
193  s_entry->sort += 2;
194 
195  /* see if this entry should have a new weighting */
196  if (do_sort) {
197  s_entry->sort = sort_matches(bootcat_path, s_entry->sort);
198  }
199 #endif /* SORTING */
200 
201  s_entry->isorec.flags[0] = ISO_FILE;
202  s_entry->priority = 32768;
203  iso9660_date(s_entry->isorec.date, fstatbuf.st_mtime);
204  s_entry->inode = TABLE_INODE;
205  s_entry->dev = (dev_t)UNCACHED_DEVICE;
206  set_723(s_entry->isorec.volume_sequence_number,
208  set_733((char *)s_entry->isorec.size, SECTOR_SIZE);
209  s_entry->size = SECTOR_SIZE;
210  s_entry->filedir = this_dir;
211  s_entry->name = e_strdup(p2);
212  iso9660_file_length(p2, s_entry, 0);
213 
214  /* flag file as necessary */
215  s_entry->de_flags = bcat_de_flags;
216 
217  if ((use_XA || use_RockRidge) &&
219  fstatbuf.st_mode = 0444 | S_IFREG;
220  fstatbuf.st_nlink = 1;
222  p2, s_entry,
223  &fstatbuf, &fstatbuf, 0);
224  }
225  /*
226  * memory files are stored at s_entry->table
227  * - but this is also used for each s_entry to generate
228  * TRANS.TBL entries. So if we are generating tables,
229  * store the TRANS.TBL data here for the moment
230  */
232  sprintf(buffer, "F\t%s\n", s_entry->name);
233 
234  /* copy the TRANS.TBL entry info and clear the buffer */
235  s_entry->table = e_strdup(buffer);
237 
238  /*
239  * store the (empty) file data in the
240  * unused s_entry->whole_name element for the time being
241  * - this will be transferred to s_entry->table after any
242  * TRANS.TBL processing later
243  */
244  s_entry->whole_name = buffer;
245  } else {
246  /* store the (empty) file data in the s_entry->table element */
247  s_entry->table = buffer;
248  s_entry->whole_name = NULL;
249  }
250 }
LOCAL char * bootcat_path
Definition: eltorito.c:61
#define ISO_FILE
Definition: iso9660.h:263
unsigned int de_flags
Definition: mkisofs.h:122
char * table
Definition: mkisofs.h:117
Definition: mkisofs.h:107
struct stat fstatbuf
Definition: tree.c:108
struct _root root
struct directory * filedir
Definition: mkisofs.h:119
GLuint buffer
Definition: glext.h:5915
#define S_IFREG
Definition: ext2fs.h:356
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
EXPORT char * e_strdup(char *s) const
Definition: mkisofs.c:3941
#define TABLE_INODE
Definition: mkisofs.h:763
EXPORT struct directory_entry * search_tree_file(struct directory *node, char *filename)
Definition: tree.c:2885
char * name
Definition: mkisofs.h:116
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define UNCACHED_DEVICE
Definition: mkisofs.h:765
#define _(X)
Definition: i386-dis.c:36
struct iso_directory_record isorec
Definition: mkisofs.h:110
dev_t dev
Definition: mkisofs.h:133
smooth NULL
Definition: ftsmooth.c:416
char * whole_name
Definition: mkisofs.h:118
EXPORT int iso9660_date(char *result, time_t crtime)
Definition: mkisofs.c:1868
unsigned int dir
Definition: maze.c:112
#define INHIBIT_ISO9660_ENTRY
Definition: mkisofs.h:802
struct directory_entry * contents
Definition: mkisofs.h:270
int iso9660_file_length(char *name, struct directory_entry *sresult, int dirflag) const
Definition: name.c:105
int use_RockRidge
Definition: mkisofs.c:110
LOCAL unsigned int bcat_de_flags
Definition: eltorito.c:60
int volume_sequence_number
Definition: mkisofs.c:173
ino_t inode
Definition: mkisofs.h:132
struct directory_entry * next
Definition: mkisofs.h:108
unsigned short priority
Definition: mkisofs.h:114
off_t size
Definition: mkisofs.h:112
EXPORT void init_fstatbuf()
Definition: tree.c:2974
EXPORT int generate_xa_rr_attributes(char *whole_name, char *name, struct directory_entry *s_entry, struct stat *statbuf, struct stat *lstatbuf, int deep_opt)
Definition: rock.c:236
__kernel_dev_t dev_t
Definition: linux.h:197
EXPORT void ex_boot_enoent(char *msg, char *pname)
Definition: eltorito.c:660
EXPORT void * e_malloc(size_t size)
Definition: mkisofs.c:3921
char * boot_catalog
Definition: mkisofs.c:168
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int use_XA
Definition: mkisofs.c:111
#define SECTOR_SIZE
Definition: fs.h:22
int generate_tables
Definition: mkisofs.c:153
#define memset(x, y, z)
Definition: compat.h:39
EXPORT void set_723(void *vp, UInt32_t i)
Definition: isonum.c:76
EXPORT void set_733(void *vp, UInt32_t i)
Definition: isonum.c:125

Referenced by main().

◆ new_boot_entry()

EXPORT int new_boot_entry ( )

Definition at line 650 of file eltorito.c.

651 {
653  return (1);
654 }
smooth NULL
Definition: ftsmooth.c:416
struct eltorito_boot_entry_info * current_boot_entry
Definition: mkisofs.c:228

Referenced by get_boot_platid().

◆ tvd_write()

LOCAL int tvd_write ( FILE outfile)

Definition at line 672 of file eltorito.c.

674 {
675  /* check the boot image is not NULL */
676  if (!boot_image) {
677  comerrno(EX_BAD, _("No boot image specified.\n"));
678  }
679  /* Next we write out the boot volume descriptor for the disc */
683  return (0);
684 }
char * boot_image
Definition: mkisofs.c:169
EXPORT void xfwrite(void *buffer, int size, int count, FILE *file, int submode, BOOL islast)
Definition: write.c:168
static FILE * outfile
Definition: wrjpgcom.c:81
LOCAL struct eltorito_boot_descriptor gboot_desc
Definition: eltorito.c:58
LOCAL void get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
Definition: eltorito.c:253
#define _(X)
Definition: i386-dis.c:36
UInt32_t last_extent_written
Definition: write.c:303
EXPORT void comerrno(int err, char *msg, va_alist)
Definition: comerr.c:137
#define SECTOR_SIZE
Definition: fs.h:22
#define EX_BAD
Definition: standard.h:62

Variable Documentation

◆ bcat_de_flags

LOCAL unsigned int bcat_de_flags

Definition at line 60 of file eltorito.c.

Referenced by init_boot_catalog(), and insert_boot_cat().

◆ bootcat_path

LOCAL char* bootcat_path

Definition at line 61 of file eltorito.c.

Referenced by init_boot_catalog(), and insert_boot_cat().

◆ disk_mbr

Definition at line 59 of file eltorito.c.

Referenced by fill_boot_desc().

◆ gboot_desc

Definition at line 58 of file eltorito.c.

Referenced by tvd_write().

◆ sccsid

UConst char sccsid[]
static
Initial value:
=
"@(#)eltorito.c 1.52 15/11/23 joerg"

Definition at line 4 of file eltorito.c.

◆ torito_desc

Definition at line 686 of file eltorito.c.

Referenced by main().

◆ valid_desc

Definition at line 57 of file eltorito.c.

Referenced by get_torito_desc().