1*158d2fcdSBenno Rice /*-
2*158d2fcdSBenno Rice * Copyright (c) 2018 iXsystems, Inc.
3*158d2fcdSBenno Rice * All rights reserved.
4*158d2fcdSBenno Rice *
5*158d2fcdSBenno Rice * Redistribution and use in source and binary forms, with or without
6*158d2fcdSBenno Rice * modification, are permitted provided that the following conditions
7*158d2fcdSBenno Rice * are met:
8*158d2fcdSBenno Rice * 1. Redistributions of source code must retain the above copyright
9*158d2fcdSBenno Rice * notice, this list of conditions and the following disclaimer.
10*158d2fcdSBenno Rice * 2. Redistributions in binary form must reproduce the above copyright
11*158d2fcdSBenno Rice * notice, this list of conditions and the following disclaimer in the
12*158d2fcdSBenno Rice * documentation and/or other materials provided with the distribution.
13*158d2fcdSBenno Rice *
14*158d2fcdSBenno Rice * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*158d2fcdSBenno Rice * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*158d2fcdSBenno Rice * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*158d2fcdSBenno Rice * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*158d2fcdSBenno Rice * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*158d2fcdSBenno Rice * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*158d2fcdSBenno Rice * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*158d2fcdSBenno Rice * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*158d2fcdSBenno Rice * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*158d2fcdSBenno Rice * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*158d2fcdSBenno Rice * SUCH DAMAGE.
25*158d2fcdSBenno Rice */
26*158d2fcdSBenno Rice
27*158d2fcdSBenno Rice #include <sys/cdefs.h>
28*158d2fcdSBenno Rice #include <stdbool.h>
29*158d2fcdSBenno Rice #include <stdio.h>
30*158d2fcdSBenno Rice
31*158d2fcdSBenno Rice #include "cd9660.h"
32*158d2fcdSBenno Rice #include "cd9660_eltorito.h"
33*158d2fcdSBenno Rice
34*158d2fcdSBenno Rice #include "etdump.h"
35*158d2fcdSBenno Rice
36*158d2fcdSBenno Rice static void
output_image(FILE * outfile,const char * filename,boot_volume_descriptor * bvd __unused)37*158d2fcdSBenno Rice output_image(FILE *outfile, const char *filename, boot_volume_descriptor *bvd __unused)
38*158d2fcdSBenno Rice {
39*158d2fcdSBenno Rice
40*158d2fcdSBenno Rice fprintf(outfile, "Image in %s\n", filename);
41*158d2fcdSBenno Rice }
42*158d2fcdSBenno Rice
43*158d2fcdSBenno Rice static void
output_section(FILE * outfile,const char * filename __unused,boot_catalog_section_header * bcsh)44*158d2fcdSBenno Rice output_section(FILE *outfile, const char *filename __unused,
45*158d2fcdSBenno Rice boot_catalog_section_header *bcsh)
46*158d2fcdSBenno Rice {
47*158d2fcdSBenno Rice
48*158d2fcdSBenno Rice fprintf(outfile, "\nSection header: %s",
49*158d2fcdSBenno Rice system_id_string(bcsh->platform_id[0]));
50*158d2fcdSBenno Rice
51*158d2fcdSBenno Rice if (bcsh->header_indicator[0] == ET_SECTION_HEADER_LAST)
52*158d2fcdSBenno Rice fprintf(outfile, ", final\n");
53*158d2fcdSBenno Rice else
54*158d2fcdSBenno Rice fprintf(outfile, "\n");
55*158d2fcdSBenno Rice }
56*158d2fcdSBenno Rice
57*158d2fcdSBenno Rice static void
output_entry(FILE * outfile,const char * filename __unused,boot_catalog_section_entry * bcse,u_char platform_id __unused,bool initial)58*158d2fcdSBenno Rice output_entry(FILE *outfile, const char *filename __unused,
59*158d2fcdSBenno Rice boot_catalog_section_entry *bcse, u_char platform_id __unused,
60*158d2fcdSBenno Rice bool initial)
61*158d2fcdSBenno Rice {
62*158d2fcdSBenno Rice const char *indent;
63*158d2fcdSBenno Rice
64*158d2fcdSBenno Rice switch (bcse->boot_indicator[0]) {
65*158d2fcdSBenno Rice case ET_BOOTABLE:
66*158d2fcdSBenno Rice break;
67*158d2fcdSBenno Rice case ET_NOT_BOOTABLE:
68*158d2fcdSBenno Rice default:
69*158d2fcdSBenno Rice return;
70*158d2fcdSBenno Rice }
71*158d2fcdSBenno Rice
72*158d2fcdSBenno Rice if (initial) {
73*158d2fcdSBenno Rice fprintf(outfile, "Default entry\n");
74*158d2fcdSBenno Rice indent = "\t";
75*158d2fcdSBenno Rice } else {
76*158d2fcdSBenno Rice fprintf(outfile, "\tSection entry\n");
77*158d2fcdSBenno Rice indent = "\t\t";
78*158d2fcdSBenno Rice }
79*158d2fcdSBenno Rice
80*158d2fcdSBenno Rice fprintf(outfile, "%sSystem %s\n", indent,
81*158d2fcdSBenno Rice system_id_string(bcse->system_type[0]));
82*158d2fcdSBenno Rice fprintf(outfile, "%sStart LBA %d (0x%x), sector count %d (0x%x)\n",
83*158d2fcdSBenno Rice indent, isonum_731(bcse->load_rba), isonum_731(bcse->load_rba),
84*158d2fcdSBenno Rice isonum_721(bcse->sector_count), isonum_721(bcse->sector_count));
85*158d2fcdSBenno Rice fprintf(outfile, "%sMedia type: %s\n", indent,
86*158d2fcdSBenno Rice media_type_string(bcse->media_type[0]));
87*158d2fcdSBenno Rice }
88*158d2fcdSBenno Rice
89*158d2fcdSBenno Rice static struct outputter _output_text = {
90*158d2fcdSBenno Rice .output_image = output_image,
91*158d2fcdSBenno Rice .output_section = output_section,
92*158d2fcdSBenno Rice .output_entry = output_entry,
93*158d2fcdSBenno Rice };
94*158d2fcdSBenno Rice
95*158d2fcdSBenno Rice struct outputter *output_text = &_output_text;
96