xref: /illumos-gate/usr/src/cmd/etdump/output_shell.c (revision 916bf6b9)
1c0455f33SToomas Soome /*
2c0455f33SToomas Soome  * Copyright (c) 2018 iXsystems, Inc.
3c0455f33SToomas Soome  * All rights reserved.
4c0455f33SToomas Soome  *
5c0455f33SToomas Soome  * Redistribution and use in source and binary forms, with or without
6c0455f33SToomas Soome  * modification, are permitted provided that the following conditions
7c0455f33SToomas Soome  * are met:
8c0455f33SToomas Soome  * 1. Redistributions of source code must retain the above copyright
9c0455f33SToomas Soome  *    notice, this list of conditions and the following disclaimer.
10c0455f33SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
11c0455f33SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
12c0455f33SToomas Soome  *    documentation and/or other materials provided with the distribution.
13c0455f33SToomas Soome  *
14c0455f33SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15c0455f33SToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16c0455f33SToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17c0455f33SToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18c0455f33SToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19c0455f33SToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20c0455f33SToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21c0455f33SToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22c0455f33SToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23c0455f33SToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24c0455f33SToomas Soome  * SUCH DAMAGE.
25c0455f33SToomas Soome  */
26c0455f33SToomas Soome 
27c0455f33SToomas Soome #include <stdbool.h>
28c0455f33SToomas Soome #include <stdio.h>
29*916bf6b9SToomas Soome #include <inttypes.h>
30c0455f33SToomas Soome 
31c0455f33SToomas Soome #include "cd9660_eltorito.h"
32c0455f33SToomas Soome 
33c0455f33SToomas Soome #include "etdump.h"
34c0455f33SToomas Soome 
35c0455f33SToomas Soome static void
output_entry(FILE * outfile,const char * filename __unused,boot_catalog_section_entry * bcse,uchar_t platform_id,bool initial)36c0455f33SToomas Soome output_entry(FILE *outfile, const char *filename __unused,
37c0455f33SToomas Soome     boot_catalog_section_entry *bcse, uchar_t platform_id, bool initial)
38c0455f33SToomas Soome {
39c0455f33SToomas Soome 	const char *platform;
40c0455f33SToomas Soome 
41c0455f33SToomas Soome 	switch (bcse->boot_indicator[0]) {
42c0455f33SToomas Soome 	case ET_BOOTABLE:
43c0455f33SToomas Soome 		break;
44c0455f33SToomas Soome 	case ET_NOT_BOOTABLE:
45c0455f33SToomas Soome 	default:
46c0455f33SToomas Soome 		return;
47c0455f33SToomas Soome 	}
48c0455f33SToomas Soome 
49c0455f33SToomas Soome 	if (initial)
50c0455f33SToomas Soome 		platform = "default";
51c0455f33SToomas Soome 	else
52c0455f33SToomas Soome 		platform = system_id_string(platform_id);
53c0455f33SToomas Soome 
54c0455f33SToomas Soome 	fprintf(outfile,
55*916bf6b9SToomas Soome 	    "et_platform=%s;et_system=%s;et_lba=%" PRIu32 ";et_sectors=%"
56*916bf6b9SToomas Soome 	    PRIu16 "\n", platform, system_id_string(bcse->system_type[0]),
57c0455f33SToomas Soome 	    isonum_731(bcse->load_rba), isonum_721(bcse->sector_count));
58c0455f33SToomas Soome }
59c0455f33SToomas Soome 
60c0455f33SToomas Soome static struct outputter _output_shell = {
61c0455f33SToomas Soome 	.output_image = NULL,
62c0455f33SToomas Soome 	.output_section = NULL,
63c0455f33SToomas Soome 	.output_entry = output_entry,
64c0455f33SToomas Soome };
65c0455f33SToomas Soome 
66c0455f33SToomas Soome struct outputter *output_shell = &_output_shell;
67