Index: head/usr.bin/Makefile =================================================================== --- head/usr.bin/Makefile (revision 331948) +++ head/usr.bin/Makefile (revision 331949) @@ -1,305 +1,306 @@ # From: @(#)Makefile 8.3 (Berkeley) 1/7/94 # $FreeBSD$ .include # XXX MISSING: deroff diction graph learn plot # spell spline struct xsend # XXX Use GNU versions: diff ld patch # SUBDIR= alias \ apply \ asa \ awk \ banner \ basename \ brandelf \ bsdcat \ bsdiff \ bzip2 \ bzip2recover \ cap_mkdb \ chat \ chpass \ cksum \ cmp \ col \ colldef \ colrm \ column \ comm \ compress \ cpuset \ csplit \ ctlstat \ cut \ diff \ dirname \ du \ elf2aout \ elfdump \ enigma \ env \ + etdump \ expand \ false \ fetch \ find \ fmt \ fold \ fstat \ fsync \ gcore \ gencat \ getaddrinfo \ getconf \ getent \ getopt \ grep \ gzip \ head \ hexdump \ id \ ident \ ipcrm \ ipcs \ join \ jot \ keylogin \ keylogout \ killall \ ktrace \ ktrdump \ lam \ lastcomm \ ldd \ leave \ less \ lessecho \ lesskey \ limits \ locale \ localedef \ lock \ lockf \ logger \ login \ logins \ logname \ look \ lorder \ lsvfs \ lzmainfo \ m4 \ mandoc \ mesg \ minigzip \ ministat \ mkdep \ mkfifo \ mkimg \ mklocale \ mktemp \ mkuzip \ mt \ ncal \ netstat \ newgrp \ nfsstat \ nice \ nl \ numactl \ nohup \ opieinfo \ opiekey \ opiepasswd \ pagesize \ passwd \ paste \ patch \ pathchk \ perror \ pr \ printenv \ printf \ proccontrol \ procstat \ protect \ rctl \ renice \ resizewin \ rev \ revoke \ rpcinfo \ rs \ rup \ ruptime \ rusers \ rwall \ rwho \ script \ sdiff \ sed \ send-pr \ seq \ shar \ showmount \ sockstat \ soelim \ sort \ split \ stat \ stdbuf \ strings \ su \ systat \ tabs \ tail \ tar \ tcopy \ tee \ time \ timeout \ tip \ top \ touch \ tput \ tr \ true \ truncate \ tset \ tsort \ tty \ uname \ unexpand \ uniq \ unzip \ units \ unvis \ uudecode \ uuencode \ vis \ vmstat \ w \ wall \ wc \ what \ whereis \ which \ whois \ write \ xargs \ xinstall \ xo \ xz \ xzdec \ yes \ zstd # NB: keep these sorted by MK_* knobs SUBDIR.${MK_AT}+= at SUBDIR.${MK_ATM}+= atm SUBDIR.${MK_BLUETOOTH}+= bluetooth SUBDIR.${MK_BSD_CPIO}+= cpio SUBDIR.${MK_CALENDAR}+= calendar SUBDIR.${MK_CLANG}+= clang SUBDIR.${MK_DIALOG}+= dpv SUBDIR.${MK_EE}+= ee SUBDIR.${MK_FILE}+= file SUBDIR.${MK_FINGER}+= finger SUBDIR.${MK_FTP}+= ftp SUBDIR.${MK_GAMES}+= caesar SUBDIR.${MK_GAMES}+= factor SUBDIR.${MK_GAMES}+= fortune SUBDIR.${MK_GAMES}+= grdc SUBDIR.${MK_GAMES}+= morse SUBDIR.${MK_GAMES}+= number SUBDIR.${MK_GAMES}+= pom SUBDIR.${MK_GAMES}+= primes SUBDIR.${MK_GAMES}+= random .if ${MK_GPL_DTC} != "yes" .if ${COMPILER_FEATURES:Mc++11} SUBDIR+= dtc .endif .endif SUBDIR.${MK_HESIOD}+= hesinfo SUBDIR.${MK_ICONV}+= iconv SUBDIR.${MK_ICONV}+= mkcsmapper SUBDIR.${MK_ICONV}+= mkesdb SUBDIR.${MK_ISCSI}+= iscsictl SUBDIR.${MK_KDUMP}+= kdump SUBDIR.${MK_KDUMP}+= truss SUBDIR.${MK_KERBEROS_SUPPORT}+= compile_et SUBDIR.${MK_LDNS_UTILS}+= drill SUBDIR.${MK_LDNS_UTILS}+= host SUBDIR.${MK_LOCATE}+= locate # XXX msgs? SUBDIR.${MK_MAIL}+= biff SUBDIR.${MK_MAIL}+= from SUBDIR.${MK_MAIL}+= mail SUBDIR.${MK_MAIL}+= msgs SUBDIR.${MK_MAKE}+= bmake SUBDIR.${MK_MAN_UTILS}+= man SUBDIR.${MK_NETCAT}+= nc SUBDIR.${MK_NIS}+= ypcat SUBDIR.${MK_NIS}+= ypmatch SUBDIR.${MK_NIS}+= ypwhich SUBDIR.${MK_OPENSSH}+= ssh-copy-id SUBDIR.${MK_OPENSSL}+= bc SUBDIR.${MK_OPENSSL}+= chkey SUBDIR.${MK_OPENSSL}+= dc SUBDIR.${MK_OPENSSL}+= newkey SUBDIR.${MK_QUOTAS}+= quota SUBDIR.${MK_SENDMAIL}+= vacation SUBDIR.${MK_TALK}+= talk SUBDIR.${MK_TELNET}+= telnet SUBDIR.${MK_TESTS}+= tests SUBDIR.${MK_TEXTPROC}+= ul SUBDIR.${MK_TFTP}+= tftp SUBDIR.${MK_TOOLCHAIN}+= addr2line SUBDIR.${MK_TOOLCHAIN}+= ar SUBDIR.${MK_TOOLCHAIN}+= c89 SUBDIR.${MK_TOOLCHAIN}+= c99 SUBDIR.${MK_TOOLCHAIN}+= ctags SUBDIR.${MK_TOOLCHAIN}+= cxxfilt SUBDIR.${MK_TOOLCHAIN}+= elfcopy SUBDIR.${MK_TOOLCHAIN}+= file2c # ARM64TODO gprof does not build # RISCVTODO gprof does not build .if ${MACHINE_ARCH} != "aarch64" && ${MACHINE_CPUARCH} != "riscv" SUBDIR.${MK_TOOLCHAIN}+= gprof .endif SUBDIR.${MK_TOOLCHAIN}+= indent SUBDIR.${MK_TOOLCHAIN}+= lex SUBDIR.${MK_TOOLCHAIN}+= mkstr SUBDIR.${MK_TOOLCHAIN}+= nm SUBDIR.${MK_TOOLCHAIN}+= readelf SUBDIR.${MK_TOOLCHAIN}+= rpcgen SUBDIR.${MK_TOOLCHAIN}+= unifdef SUBDIR.${MK_TOOLCHAIN}+= size SUBDIR.${MK_TOOLCHAIN}+= xstr SUBDIR.${MK_TOOLCHAIN}+= yacc SUBDIR.${MK_VI}+= vi SUBDIR.${MK_VT}+= vtfontcvt SUBDIR.${MK_USB}+= usbhidaction SUBDIR.${MK_USB}+= usbhidctl SUBDIR.${MK_UTMPX}+= last .if ${MK_CXX} != "no" SUBDIR.${MK_UTMPX}+= users .endif SUBDIR.${MK_UTMPX}+= who SUBDIR.${MK_SVN}+= svn SUBDIR.${MK_SVNLITE}+= svn # These are normally only handled for build-tools. .if make(clean*) SUBDIR+= mkcsmapper_static SUBDIR+= mkesdb_static .endif .include SUBDIR_PARALLEL= .include Index: head/usr.bin/etdump/Makefile =================================================================== --- head/usr.bin/etdump/Makefile (nonexistent) +++ head/usr.bin/etdump/Makefile (revision 331949) @@ -0,0 +1,14 @@ +# $FreeBSD$ + +PROG= etdump + +MAKEFS_SRC= ${SRCTOP}/usr.sbin/makefs + +CFLAGS+= -I${SRCTOP}/sys/fs/cd9660 -I${MAKEFS_SRC} \ + -I${MAKEFS_SRC}/cd9660 + +.PATH: ${MAKEFS_SRC}/cd9660 + +SRCS= etdump.c output_shell.c output_text.c cd9660_conversion.c + +.include Property changes on: head/usr.bin/etdump/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/usr.bin/etdump/etdump.1 =================================================================== --- head/usr.bin/etdump/etdump.1 (nonexistent) +++ head/usr.bin/etdump/etdump.1 (revision 331949) @@ -0,0 +1,104 @@ +.\" Copyright (c) 2018 iXsystems, Inc +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd April 3, 2018 +.Dt ETDUMP 8 +.Os +.Sh NAME +.Nm etdump +.Nd Dump El Torito boot catalog information from ISO images +.Sh SYNOPSIS +.Nm +.Op Fl f Ar format +.Op Fl o Ar file +.Ar +.Sh DESCRIPTION +This program reads El Torito boot catalog information from an ISO image and +outputs it in various formats. +It can be used to check the catalog in an image or to output catalog data in +a format that can be used by other tools such as shell scripts. +.Pp +Supported options are: +.Bl -tag -width flag +.It Fl f Ar format Fl -format Ar format +Select the output format. +Supported output formats are: +.Bl -tag -width shell -offset indent +.It Sy text +Human-readable text (default) +.It Sy shell +Each boot entry is emitted as a string suitable for passing to a sh-compatible +eval command. +The variables emitted are: +.Bl -tag -width et_platform -offset indent +.It et_platform +The platform ID from the section header. +Set to 'default' for the initial (default) entry. +.It et_system +The system ID from the boot entry. +.It et_lba +The starting LBA (2048-byte blocks) of the boot image. +.It et_sectors +The number of sectors (512-byte sectors) that comprise the boot image. +.El +.El +.It Fl o Ar file Fl -output Ar file +Write output to +.Ar file . +If '-' is specified then standard out is used. +.El +.Sh EXAMPLES +To see what entries are in a given boot catalog run +.Nm +passing the filename of the image as an argument like so: +.Bd -literal -offset indent +% etdump bootonly.iso +Image in bootonly.iso +Default entry + System i386 + Start LBA 420 (0x1a4), sector count 4 (0x4) + Media type: no emulation + +Section header: efi, final + Section entry + System i386 + Start LBA 20 (0x14), sector count 1600 (0x640) + Media type: no emulation +.Ed +.Pp +To use the output in a shell script a for loop can be used to iterate over the +entries returned using eval: +.Bd -literal -offset indent +for entry in `etdump --format shell bootonly.iso`; do + eval $entry + echo $et_platform $et_system $et_lba $et_sectors +done +.Ed +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 12.0 . Property changes on: head/usr.bin/etdump/etdump.1 ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/usr.bin/etdump/etdump.c =================================================================== --- head/usr.bin/etdump/etdump.c (nonexistent) +++ head/usr.bin/etdump/etdump.c (revision 331949) @@ -0,0 +1,268 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include "cd9660.h" +#include "cd9660_eltorito.h" + +#include "etdump.h" + +const char * +system_id_string(u_char system_id) +{ + + switch (system_id) { + case ET_SYS_X86: + return ("i386"); + case ET_SYS_PPC: + return ("powerpc"); + case ET_SYS_MAC: + return ("mac"); + case ET_SYS_EFI: + return ("efi"); + default: + return ("invalid"); + } +} + +const char * +media_type_string(u_char media_type) +{ + + switch (media_type) { + case ET_MEDIA_NOEM: + return ("no emulation"); + case ET_MEDIA_12FDD: + return ("1.2MB FDD"); + case ET_MEDIA_144FDD: + return ("1.44MB FDD"); + case ET_MEDIA_288FDD: + return ("2.88MB FDD"); + case ET_MEDIA_HDD: + return ("HDD"); + default: + return ("invalid"); + } +} + +static int +read_sector(FILE *iso, daddr_t sector, char *buffer) +{ + + fseek(iso, sector * ISO_DEFAULT_BLOCK_SIZE, SEEK_SET); + if (fread(buffer, ISO_DEFAULT_BLOCK_SIZE, 1, iso) != 1) { + return (errno); + } + return (0); +} + +static bool +boot_catalog_valid(char *entry) +{ + boot_catalog_validation_entry *ve; + int16_t checksum, sum; + unsigned char *csptr; + size_t i; + + ve = (boot_catalog_validation_entry *)entry; + + checksum = isonum_721(ve->checksum); + cd9660_721(0, ve->checksum); + csptr = (unsigned char *)ve; + + for (i = sum = 0; i < sizeof(*ve); i += 2) { + sum += (int16_t)csptr[i]; + sum += 256 * (int16_t)csptr[i + 1]; + } + if (sum + checksum != 0) { + return (false); + } + + cd9660_721(checksum, ve->checksum); + return (true); +} + +static int +dump_section(char *buffer, size_t offset, FILE *outfile, const char *filename, + struct outputter *outputter) +{ + boot_catalog_section_header *sh; + u_char platform_id; + int i; + size_t entry_offset; + boot_catalog_section_entry *entry; + + sh = (boot_catalog_section_header *)&buffer[offset]; + if (outputter->output_section != NULL) { + outputter->output_section(outfile, filename, sh); + } + + platform_id = sh->platform_id[0]; + + if (outputter->output_entry != NULL) { + for (i = 1; i <= (int)sh->num_section_entries[0]; i++) { + entry_offset = offset + i * ET_BOOT_ENTRY_SIZE; + entry = + (boot_catalog_section_entry *)&buffer[entry_offset]; + outputter->output_entry(outfile, filename, entry, + platform_id, false); + } + } + + return (1 + (int)sh->num_section_entries[0]); +} + +static void +dump_eltorito(FILE *iso, const char *filename, FILE *outfile, + struct outputter *outputter) +{ + char buffer[ISO_DEFAULT_BLOCK_SIZE], *entry; + boot_volume_descriptor *bvd; + daddr_t boot_catalog; + size_t offset; + int entry_count; + + if (read_sector(iso, 17, buffer) != 0) + err(1, "failed to read from image"); + + bvd = (boot_volume_descriptor *)buffer; + if (memcmp(bvd->identifier, ISO_VOLUME_DESCRIPTOR_STANDARD_ID, 5) != 0) + warnx("%s: not a valid ISO", filename); + if (bvd->boot_record_indicator[0] != ISO_VOLUME_DESCRIPTOR_BOOT) + warnx("%s: not an El Torito bootable ISO", filename); + if (memcmp(bvd->boot_system_identifier, ET_ID, 23) != 0) + warnx("%s: not an El Torito bootable ISO", filename); + + boot_catalog = isonum_731(bvd->boot_catalog_pointer); + + if (read_sector(iso, boot_catalog, buffer) != 0) + err(1, "failed to read from image"); + + entry = buffer; + offset = 0; + + if (!boot_catalog_valid(entry)) + warnx("%s: boot catalog checksum is invalid", filename); + + if (outputter->output_image != NULL) + outputter->output_image(outfile, filename, bvd); + + offset += ET_BOOT_ENTRY_SIZE; + entry = &buffer[offset]; + if (outputter->output_entry != NULL) + outputter->output_entry(outfile, filename, + (boot_catalog_section_entry *)entry, 0, true); + + offset += ET_BOOT_ENTRY_SIZE; + + while (offset < ISO_DEFAULT_BLOCK_SIZE) { + entry = &buffer[offset]; + + if ((uint8_t)entry[0] != ET_SECTION_HEADER_MORE && + (uint8_t)entry[0] != ET_SECTION_HEADER_LAST) + break; + + entry_count = dump_section(buffer, offset, outfile, filename, + outputter); + + offset += entry_count * ET_BOOT_ENTRY_SIZE; + } +} + +static void +usage(const char *progname) +{ + char *path; + + path = strdup(progname); + + fprintf(stderr, "usage: %s [-f format] [-o filename] filename [...]\n", + basename(path)); + fprintf(stderr, "\tsupported output formats: shell, text\n"); + exit(1); +} + +int +main(int argc, char **argv) +{ + int ch, i; + FILE *outfile, *iso; + struct outputter *outputter; + + outfile = stdout; + outputter = output_text; + + static struct option longopts[] = { + { "format", required_argument, NULL, 'f' }, + { "output", required_argument, NULL, 'o' }, + { NULL, 0, NULL, 0 }, + }; + + while ((ch = getopt_long(argc, argv, "f:o:", longopts, NULL)) != -1) { + switch (ch) { + case 'f': + if (strcmp(optarg, "shell") == 0) + outputter = output_shell; + else if (strcmp(optarg, "text") == 0) + outputter = output_text; + else + usage(argv[0]); + break; + case 'o': + if (strcmp(optarg, "-") == 0) { + outfile = stdout; + } else if ((outfile = fopen(optarg, "w")) == NULL) { + err(1, "unable to open %s for output", optarg); + } + break; + default: + usage(argv[0]); + } + } + + argc -= optind; + argv += optind; + + for (i = 0; i < argc; i++) { + printf("%d %s\n", optind, argv[i]); + if (strcmp(argv[i], "-") == 0) { + iso = stdin; + } else { + iso = fopen(argv[i], "r"); + if (iso == NULL) + err(1, "could not open %s", argv[1]); + } + dump_eltorito(iso, argv[i], outfile, outputter); + } +} Property changes on: head/usr.bin/etdump/etdump.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/usr.bin/etdump/etdump.h =================================================================== --- head/usr.bin/etdump/etdump.h (nonexistent) +++ head/usr.bin/etdump/etdump.h (revision 331949) @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _ETDUMP_H_ +#define _ETDUMP_H_ + +struct outputter { + void (*output_image)(FILE *outfile, const char *filename, + boot_volume_descriptor *bvd); + void (*output_section)(FILE *outfile, const char *filename, + boot_catalog_section_header *bcsh); + void (*output_entry)(FILE *outfile, const char *filename, + boot_catalog_section_entry *bcse, + u_char platform_id, bool initial); +}; + +extern struct outputter *output_text; +extern struct outputter *output_shell; + +const char *system_id_string(u_char system_id); +const char *media_type_string(u_char media_type); + +#endif /* _ETDUMP_H_ */ + Property changes on: head/usr.bin/etdump/etdump.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/usr.bin/etdump/output_shell.c =================================================================== --- head/usr.bin/etdump/output_shell.c (nonexistent) +++ head/usr.bin/etdump/output_shell.c (revision 331949) @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include "cd9660.h" +#include "cd9660_eltorito.h" + +#include "etdump.h" + +static void +output_entry(FILE *outfile, const char *filename __unused, + boot_catalog_section_entry *bcse, u_char platform_id, bool initial) +{ + const char *platform; + + switch (bcse->boot_indicator[0]) { + case ET_BOOTABLE: + break; + case ET_NOT_BOOTABLE: + default: + return; + } + + if (initial) + platform = "default"; + else + platform = system_id_string(platform_id); + + fprintf(outfile, + "et_platform=%s;et_system=%s;et_lba=%d;et_sectors=%d\n", + platform, system_id_string(bcse->system_type[0]), + isonum_731(bcse->load_rba), isonum_721(bcse->sector_count)); +} + +static struct outputter _output_shell = { + .output_image = NULL, + .output_section = NULL, + .output_entry = output_entry, +}; + +struct outputter *output_shell = &_output_shell; Property changes on: head/usr.bin/etdump/output_shell.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/usr.bin/etdump/output_text.c =================================================================== --- head/usr.bin/etdump/output_text.c (nonexistent) +++ head/usr.bin/etdump/output_text.c (revision 331949) @@ -0,0 +1,97 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include "cd9660.h" +#include "cd9660_eltorito.h" + +#include "etdump.h" + +static void +output_image(FILE *outfile, const char *filename, boot_volume_descriptor *bvd __unused) +{ + + fprintf(outfile, "Image in %s\n", filename); +} + +static void +output_section(FILE *outfile, const char *filename __unused, + boot_catalog_section_header *bcsh) +{ + + fprintf(outfile, "\nSection header: %s", + system_id_string(bcsh->platform_id[0])); + + if (bcsh->header_indicator[0] == ET_SECTION_HEADER_LAST) + fprintf(outfile, ", final\n"); + else + fprintf(outfile, "\n"); +} + +static void +output_entry(FILE *outfile, const char *filename __unused, + boot_catalog_section_entry *bcse, u_char platform_id __unused, + bool initial) +{ + const char *indent; + + switch (bcse->boot_indicator[0]) { + case ET_BOOTABLE: + break; + case ET_NOT_BOOTABLE: + default: + return; + } + + if (initial) { + fprintf(outfile, "Default entry\n"); + indent = "\t"; + } else { + fprintf(outfile, "\tSection entry\n"); + indent = "\t\t"; + } + + fprintf(outfile, "%sSystem %s\n", indent, + system_id_string(bcse->system_type[0])); + fprintf(outfile, "%sStart LBA %d (0x%x), sector count %d (0x%x)\n", + indent, isonum_731(bcse->load_rba), isonum_731(bcse->load_rba), + isonum_721(bcse->sector_count), isonum_721(bcse->sector_count)); + fprintf(outfile, "%sMedia type: %s\n", indent, + media_type_string(bcse->media_type[0])); +} + +static struct outputter _output_text = { + .output_image = output_image, + .output_section = output_section, + .output_entry = output_entry, +}; + +struct outputter *output_text = &_output_text; Property changes on: head/usr.bin/etdump/output_text.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property