Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37691228
en ru br
ALT Linux repos
S:2.1-alt1

Group :: Development/Tools
RPM: dumpet

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064117631253740014523gustar00rootroot0000000000000052 comment=72d3815eed6f9a0bc87d45131758bd9793ed1a09
dumpet-2.1/000075500000000000000000000000001176312537400126615ustar00rootroot00000000000000dumpet-2.1/.gear/000075500000000000000000000000001176312537400136555ustar00rootroot00000000000000dumpet-2.1/.gear/rules000064400000000000000000000001361176312537400147320ustar00rootroot00000000000000copy?: spec_patches/*.patch
copy?: spec_patches/*.diff
spec: spec_patches/dumpet.spec
tar: .

dumpet-2.1/.gitignore000064400000000000000000000000211176312537400146420ustar00rootroot00000000000000dumpet
*.o
*.iso
dumpet-2.1/COPYING000064400000000000000000000430761176312537400137260ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.

We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.

b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.

c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,

b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,

c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

Appendix: How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
dumpet-2.1/Makefile000064400000000000000000000021701176312537400143210ustar00rootroot00000000000000
VERSION=2.1
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)

CFLAGS:=-g3 -O2 -Wall -Werror
LFLAGS:=
CC:=gcc

CFLAGS += $(shell pkg-config --cflags libxml-2.0)
LFLAGS += -lpopt $(shell pkg-config --libs libxml-2.0)

all : dumpet

dumpet : dumpet.o
$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS)

dumpet.o : dumpet.c dumpet.h iso9660.h eltorito.h endian.h
$(CC) $(CFLAGS) -c -o $@ $<

clean :
@rm -vf *.o dumpet

install : all
install -D -m 0755 dumpet ${DESTDIR}/usr/bin/dumpet
install -D -m 0644 dumpet.1 ${DESTDIR}/usr/share/man/man1/dumpet.1

test-archive: clean all dumpet-$(VERSION)-$(GITVERSION).tar.bz2

archive: clean all dumpet-$(VERSION).tar.bz2

dist: tag archive

tag:
git tag $(VERSION) refs/heads/master

dumpet-$(VERSION).tar.bz2:
git archive --format=tar $(VERSION) --prefix=dumpet-$(VERSION)/ |bzip2 > dumpet-$(VERSION).tar.bz2

dumpet-$(VERSION)-$(GITVERSION).tar.bz2:
git archive --format=tar HEAD --prefix=dumpet-$(VERSION)-$(GITVERSION)/ |bzip2 > dumpet-$(VERSION)-$(GITVERSION).tar.bz2

upload: dist
@scp dumpet-$(VERSION).tar.bz2 fedorahosted.org:dumpet

.PHONY : all install clean
dumpet-2.1/README000064400000000000000000000010761176312537400135450ustar00rootroot00000000000000DumpET -- A tool for debugging El Torito boot images.
____
/ \
/ \
/ __ \
| / \ |
| \__/ |
\ /
\ /
\____/

You know, for kids.

Author: Peter Jones <pjones@redhat.com>

Relevant documentation:
ISO 9660:1998 - actually the same as ECMA-119, which is freely available.
ECMA 119:
http://www.ecma-international.org/publications/standards/Ecma-119.htm
"El Torito" Bootable CD-ROM Format Specification Version 1.0:
http://www.phoenix.com/NR/rdonlyres/98D3219C-9CC9-4DF5-B496-A286D893E36A/0/specscdrom.pdf
dumpet-2.1/TODO000064400000000000000000000001731176312537400133520ustar00rootroot00000000000000TODO:
- Support extended section entries. AFAIK, these have never been seen in
the wild.
- Support NeXT blessed images.
dumpet-2.1/dumpet.1000064400000000000000000000020001176312537400142310ustar00rootroot00000000000000.Dd August 25, 2010
.Dt DUMPET 1
.Sh NAME
.Nm dumpet
.Nd dump information about bootable CDs and other similar formats
.Sh SYNOPSIS
.Nm
.Fl Fl iso Ar image
.Op Fl Fl dumpdisks
.Op Fl Fl dumphex Ns | Ns Fl Fl xml
.Sh DESCRIPTION
.Nm
is a tool for debugging El Torito boot images.
.Pp
The following options are available:
.Bl -tag -width 4n
.It Fl ? , Fl Fl help
Display help information.
.It Fl i , Fl Fl iso Ar image
The file name of the input ISO image.
.It Fl d , Fl Fl dumpdisks
Dump each El Torito boot image into a file.
If
.Fl Fl xml
is not given, the files will be named
.Ar image Ns \&.1 ,
.Ar image Ns \&.2 ,
etc. in sequence.
Otherwise,
.Li BootImage
tags will be added to the output XML document with the content of each
boot image in hexadecimal.
.It Fl h , Fl Fl dumphex
Dump each El Torito structure in hexadecimal.
This option has no effect if
.Fl Fl xml
is given.
.It Fl x , Fl Fl xml
Dump the El Torito structure to standard output as an XML document.
.El
.Sh AUTHORS
.An "Peter Jones" Aq pjones@redhat.com
dumpet-2.1/dumpet.c000064400000000000000000000550361176312537400143340ustar00rootroot00000000000000/*
* dumpet -- A dumper for El Torito boot information.
*
* Copyright 2009 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Peter Jones <pjones@redhat.com>
*/

#define _GNU_SOURCE 1
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
#include <ctype.h>

#include <popt.h>

#include <libxml/encoding.h>
#include <libxml/xmlwriter.h>

#include "dumpet.h"
#include "endian.h"

struct context {
int dumpStdOut;
int dumpDiskImage;
int dumpHex;
int dumpXml;

xmlTextWriterPtr writer;
char *filename;
FILE *iso;
};

static uint32_t dump_boot_record(struct context *context)
{
BootRecordVolumeDescriptor br;
int rc;
char BootSystemId[32] = "EL TORITO SPECIFICATION";
uint32_t BootCatalogLBA;

rc = read_sector(context->iso, 17, (Sector *)&br);
if (rc < 0)
exit(3);

if (br.BootRecordIndicator != 0) {
fprintf(stderr, "\"%s\" does not contain an El Torito bootable image.\n", context->filename);
fprintf(stderr, "BootRecordIndicator: %d\n", br.BootRecordIndicator);
exit(5);
}
if (strncmp(br.Iso9660, "CD001", 5)) {
fprintf(stderr, "\"%s\" does not contain an El Torito bootable image.\n", context->filename);
memcpy(BootSystemId, br.Iso9660, 5);
BootSystemId[5] = '\0';
fprintf(stderr, "ISO-9660 Identifier: \"%s\"\n", BootSystemId);
exit(6);
}
if (memcmp(br.BootSystemId, BootSystemId, sizeof(BootSystemId))) {
int i;
fprintf(stderr, "\"%s\" does not contain an El Torito bootable image.\n", context->filename);
fprintf(stderr, "target Boot System Identifier: \"");
for (i = 0; i < sizeof(BootSystemId); i++)
fprintf(stderr, "%02x", BootSystemId[i]);
fprintf(stderr, "\n");
memcpy(BootSystemId, br.BootSystemId, sizeof(BootSystemId));
fprintf(stderr, "actual Boot System Identifier: \"");
for (i = 0; i < sizeof(BootSystemId); i++)
fprintf(stderr, "%02x", BootSystemId[i]);
fprintf(stderr, "\n");

exit(7);
}
memcpy(&BootCatalogLBA, &br.BootCatalogLBA, sizeof(BootCatalogLBA));
return iso731_to_cpu32(BootCatalogLBA);
}

static int checkValidationEntry(struct context *context,
BootCatalogValidationEntry *ValidationEntry)
{
uint16_t sum = 0;
char *ve = (char *)ValidationEntry;
uint16_t checksum;
int i;

memcpy(&checksum, &ValidationEntry->Checksum, sizeof(checksum));
checksum = iso721_to_cpu16(checksum);
ValidationEntry->Checksum = 0;

for (i = 0; i < 32; i+=2) {
sum += ve[i];
sum += ve[i+1] * 256;
}

sum += checksum;
checksum = cpu16_to_iso721(checksum);
memcpy(&ValidationEntry->Checksum, &checksum, sizeof(checksum));
if (sum != 0)
return -1;

return 0;
}

static void snprintPlatformId(char *buf, size_t n, uint16_t platformId)
{
switch (platformId) {
case x86:
snprintf(buf, n, "80x86");
break;
case ppc:
snprintf(buf, n, "PPC");
break;
case m68kmac:
snprintf(buf, n, "m68k Macintosh");
break;
case efi:
snprintf(buf, n, "EFI");
break;
default:
snprintf(buf, n, "Unknown");
break;
}
}

static void dumpHex(void *voiddata, ssize_t length)
{
uint8_t *data = voiddata;
int i, j;
for (i = j = 0; i < length ; i++) {
if (i % 16 == 0) {
j = i;
printf("%08x ", i);
}
printf("%2.2x ", data[i]);
if ((i+1) % 16 == 0) {
printf(" |");
for (; j <= i; j++) {
if (isalnum(data[j]))
printf("%c", data[j]);
else
printf(".");
}
printf("|\n");
}
}
}

static void dumpValidationEntry(BootCatalogValidationEntry *ValidationEntry, struct context *context)
{
char platformbuf[16];
char id_string[25];
uint16_t csum;

snprintPlatformId(platformbuf, 15, ValidationEntry->PlatformId);

memcpy(id_string, ValidationEntry->Id, 24);
id_string[24] = '\0';

memcpy(&csum, &ValidationEntry->Checksum, sizeof(csum));
csum = iso721_to_cpu16(csum);

if (context->dumpStdOut) {
printf("Validation Entry:\n");

if (context->dumpHex)
dumpHex(ValidationEntry, sizeof(*ValidationEntry));

printf("\tHeader Indicator: 0x%02x (Validation Entry)\n",
ValidationEntry->HeaderIndicator);
printf("\tPlatformId: 0x%02x (%s)\n", ValidationEntry->PlatformId, platformbuf);
printf("\tID: \"%s\"\n", id_string);
printf("\tChecksum: 0x%04x\n", csum);
printf("\tKey bytes: 0x%02x%02x\n", ValidationEntry->FiveFive,
ValidationEntry->AA);
} else if (context->dumpXml) {
xmlTextWriterStartElement(context->writer, BAD_CAST "BootCatalogValidationEntry");

xmlTextWriterStartElement(context->writer, BAD_CAST "PlatformId");
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "RawValue", "0x%02x",
ValidationEntry->PlatformId);
xmlTextWriterStartAttribute(context->writer, BAD_CAST "Value");
xmlTextWriterWriteString(context->writer, BAD_CAST platformbuf);
xmlTextWriterEndAttribute(context->writer);
xmlTextWriterEndElement(context->writer);

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "IdString", "%s", id_string);

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "Checksum", "%04x", csum);

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "KeyBytes", "%02x%02x",
ValidationEntry->FiveFive, ValidationEntry->AA);
}
}

static void dumpSectionHeaderEntry(BootCatalogSectionHeaderEntry *SectionHeaderEntry, struct context *context)
{
char platformbuf[16];
char id_string[29];

snprintPlatformId(platformbuf, 15, SectionHeaderEntry->PlatformId);

memcpy(id_string, SectionHeaderEntry->Id, 28);
id_string[28] = '\0';

if (context->dumpStdOut) {
printf("Section Header Entry:\n");

if (context->dumpHex)
dumpHex(SectionHeaderEntry, sizeof(*SectionHeaderEntry));

printf("\tHeader Indicator: 0x%02x ", SectionHeaderEntry->HeaderIndicator);
switch (SectionHeaderEntry->HeaderIndicator) {
case SectionHeaderIndicator:
printf("(Section Header Entry)\n");
break;
case FinalSectionHeaderIndicator:
printf("(Final Section Header Entry)\n");
break;
}

printf("\tPlatformId: 0x%02x (%s)\n", SectionHeaderEntry->PlatformId, platformbuf);
printf("\tSection Entries: %d\n", SectionHeaderEntry->SectionEntryCount);
printf("\tID: \"%s\"\n", id_string);
} else if (context->dumpXml) {
xmlTextWriterStartElement(context->writer, BAD_CAST "BootCatalogSectionHeaderEntry");

xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "FinalSectionHeaderEntry", "%s",
(SectionHeaderEntry->HeaderIndicator == FinalSectionHeaderIndicator ?
"True":"False"));

xmlTextWriterStartElement(context->writer, BAD_CAST "PlatformId");
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "RawValue", "0x%02x",
SectionHeaderEntry->PlatformId);
xmlTextWriterStartAttribute(context->writer, BAD_CAST "Value");
xmlTextWriterWriteString(context->writer, BAD_CAST platformbuf);
xmlTextWriterEndAttribute(context->writer);
xmlTextWriterEndElement(context->writer);

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "IdString", "%s", id_string);

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "SectionEntryCount", "%d",
SectionHeaderEntry->SectionEntryCount);
}
}

static int dumpBootImage(struct context *context,
uint32_t lba, uint32_t sectors,
int filenum)
{
int i;
int rc = 0;

if (context->dumpStdOut) {
FILE *image = NULL;
char *filename = NULL;
char *template = context->filename;
Sector sector;

rc = asprintf(&filename, "%s.%d", template, filenum);
if (rc < 0)
return rc;
printf("Dumping boot image to \"%s\"\n", filename);
image = fopen(filename, "w+");
if (!image) {
int errnum;
fprintf(stderr, "Could not open \"%s\": %m\n", filename);
errnum = errno;
free(filename);
return -errnum;
}
free(filename);
for (i = 0; i<sectors; i++) {
rc = read_sector(context->iso, lba++, &sector);
if (rc < 0) {
fclose(image);
return rc;
}
rc = write_sector(image, i, &sector);
if (rc < 0) {
fclose(image);
return rc;
}
}
} else if (context->dumpXml) {
Sector data[sectors];
xmlTextWriterStartElement(context->writer, BAD_CAST "BootImage");
int n = 0;

for (i = 0; i<sectors; i++) {
rc = read_sector(context->iso, lba++, &data[i]);
if (rc < 0)
break;
n++;
}
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "HeaderSize", "0x%x", sectors * 2048);
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "ActualSize", "0x%x", n * 2048);
xmlTextWriterWriteBinHex(context->writer, (char *)data,
0, n * sizeof data[0]);
xmlTextWriterEndElement(context->writer); /* end BootImage */
}
return 0;
}

static void snprintBootMediaType(char *buf, size_t n, BootMediaType type)
{
switch (type) {
case NoEmulation:
snprintf(buf, n, "no emulation");
break;
case OneTwoDiskette:
snprintf(buf, n, "1.2MB floppy diskette emulation");
break;
case OneFourFourDiskette:
snprintf(buf, n, "1.44MB floppy diskette emulation");
break;
case TwoEightEightDiskette:
snprintf(buf, n, "2.88MB floppy diskette emulation");
break;
case HardDisk:
snprintf(buf, n, "hard disk emulation");
break;
default:
snprintf(buf, n, "invalid boot media emulation type");
break;
}
}

static int dumpEntry(FILE *iso, BootCatalogEntry *bc, int header_num,
int entry_num, int *next_header_num,
int file_num, struct context *context)
{
BootCatalogValidationEntry *ValidationEntry =
(BootCatalogValidationEntry *)&bc[header_num];
BootCatalogSectionHeaderEntry *SectionHeaderEntry =
(BootCatalogSectionHeaderEntry *)&bc[header_num];
unsigned char platform_id;

switch (ValidationEntry->HeaderIndicator) {
case ValidationIndicator:
platform_id = ValidationEntry->PlatformId;
dumpValidationEntry(ValidationEntry, context);
break;
case SectionHeaderIndicator:
case FinalSectionHeaderIndicator:
platform_id = SectionHeaderEntry->PlatformId;
dumpSectionHeaderEntry(SectionHeaderEntry, context);
break;
default:
/* almost always x86 anyway -- if it's broken, it's
* probably still x86. */
platform_id = 0;
if (context->dumpStdOut) {
fprintf(stderr,
"Invalid Header Indicator (0x%04x), skipping\n",
ValidationEntry->HeaderIndicator);
}
return -1;
}

if (ValidationEntry->HeaderIndicator == ValidationIndicator) {
BootCatalogDefaultEntry *DefaultEntry =
(BootCatalogDefaultEntry *)&bc[entry_num];

uint16_t loadseg;
uint16_t sectors;
uint32_t lba;
char bmtype[64];

snprintBootMediaType(bmtype, 63, DefaultEntry->BootMediaType);

memcpy(&loadseg, &DefaultEntry->LoadSegment, sizeof(loadseg));
loadseg = iso721_to_cpu16(loadseg);

memcpy(&sectors, &DefaultEntry->SectorCount, sizeof(sectors));
sectors = iso721_to_cpu16(sectors);

memcpy(&lba, &DefaultEntry->LoadLBA, sizeof(lba));
lba = iso731_to_cpu32(lba);

if (context->dumpStdOut) {
uint16_t loadseg;
uint16_t sectors;
uint32_t lba;
char bmtype[64];

snprintBootMediaType(bmtype, 63, DefaultEntry->BootMediaType);

memcpy(&loadseg, &DefaultEntry->LoadSegment, sizeof(loadseg));
loadseg = iso721_to_cpu16(loadseg);

memcpy(&sectors, &DefaultEntry->SectorCount, sizeof(sectors));
sectors = iso721_to_cpu16(sectors);

memcpy(&lba, &DefaultEntry->LoadLBA, sizeof(lba));
lba = iso731_to_cpu32(lba);

printf("Boot Catalog Default Entry:\n");

if (context->dumpHex)
dumpHex(DefaultEntry, sizeof(*DefaultEntry));

switch (DefaultEntry->BootIndicator) {
case NotBootable:
printf("\tEntry is not bootable\n");
break;
case Bootable:
printf("\tEntry is bootable\n");
break;
default:
printf("\tInvalid boot indicator\n");
break;
}

printf("\tBoot Media emulation type: %s\n", bmtype);

switch (platform_id) {
case x86:
printf("\tMedia load segment: ");
if (loadseg == 0)
printf("0x0 (0000:7c00)\n");
else
printf("0x%04x (%04x:0000)\n", loadseg,
loadseg);
break;
case ppc:
case m68kmac:
case efi:
printf("\tMedia load address: %d (0x%04x)\n",
loadseg * 0x10, loadseg * 0x10);
break;
default:
printf("\tMedia load address: %d (0x%04x) (raw value)\n",
loadseg, loadseg);
break;
}

printf("\tSystem type: %d (0x%02x)\n", DefaultEntry->SystemType,
DefaultEntry->SystemType);

printf("\tLoad Sectors: %d (0x%04x)\n", sectors, sectors);

printf("\tLoad LBA: %d (0x%08x)\n", lba, lba);

} else if (context->dumpXml) {
xmlTextWriterStartElement(context->writer,
BAD_CAST "BootCatalogDefaultEntry");

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "Bootable", "%s",
DefaultEntry->BootIndicator ? "True" : "False");

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "BootMediaEmulationType", "%s", bmtype);

xmlTextWriterStartElement(context->writer,
BAD_CAST "MediaLoadSegment");
switch (platform_id) {
case x86:
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "RawValue",
"0x%04x", loadseg);
if (loadseg == 0) {
xmlTextWriterWriteFormatAttribute(
context->writer,
BAD_CAST "Value",
"0000:7c00");
} else {
xmlTextWriterWriteFormatAttribute(
context->writer,
BAD_CAST "Value",
"%04x:0000", loadseg);
}
xmlTextWriterWriteFormatAttribute(
context->writer, BAD_CAST "ValueType",
"Interpreted");
break;
case ppc:
case m68kmac:
case efi:
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "RawValue",
"0x%04x", loadseg);
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "Value",
"0x%04x", loadseg * 0x10);
xmlTextWriterWriteFormatAttribute(
context->writer, BAD_CAST "ValueType",
"Interpreted");
break;
default:
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "RawValue",
"0x%04x", loadseg);
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "Value",
"0x%04x", loadseg);
xmlTextWriterWriteFormatAttribute(
context->writer, BAD_CAST "ValueType",
"Raw");
break;
}
xmlTextWriterEndElement(context->writer); /* end MediaLoadSegment */

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "SystemType", "0x%02x",
DefaultEntry->SystemType);

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "LoadSectors", "0x%04x", sectors);

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "LoadLBA", "0x%08x", lba);
}

if (context->dumpDiskImage)
dumpBootImage(context, lba, sectors, file_num++);

if (context->dumpXml)
xmlTextWriterEndElement(context->writer); /* end BootCatalogDefaultEntry */

*next_header_num = entry_num + 1;
} else {
int i;

for (i = 0; i < SectionHeaderEntry->SectionEntryCount; i++) {
BootCatalogSectionEntry *SectionEntry =
(BootCatalogSectionEntry *)&bc[entry_num + i];

uint16_t loadseg;
uint16_t sectors;
uint32_t lba;
char bmtype[64];

snprintBootMediaType(bmtype, 63, SectionEntry->BootMediaType);

memcpy(&loadseg, &SectionEntry->LoadSegment, sizeof(loadseg));
loadseg = iso721_to_cpu16(loadseg);

memcpy(&sectors, &SectionEntry->SectorCount, sizeof(sectors));
sectors = iso721_to_cpu16(sectors);

memcpy(&lba, &SectionEntry->LoadLBA, sizeof(lba));
lba = iso731_to_cpu32(lba);

if (context->dumpStdOut) {
printf("Boot Catalog Section Entry:\n");

if (context->dumpHex)
dumpHex(SectionEntry, sizeof(*SectionEntry));

switch (SectionEntry->BootIndicator) {
case NotBootable:
printf("\tEntry is not bootable\n");
break;
case Bootable:
printf("\tEntry is bootable\n");
break;
default:
printf("\tInvalid boot indicator\n");
break;
}
printf("\tBoot Media emulation type: %s\n", bmtype);

switch (platform_id) {
case x86:
printf("\tMedia load segment: 0x%04x\n",
loadseg == 0 ? 0x7c0 : loadseg);
break;
case ppc:
case m68kmac:
case efi:
printf("\tMedia load address: %d (0x%04x)\n",
loadseg * 0x10, loadseg * 0x10);
break;
default:
printf("\tMedia load address: %d (0x%04x) (raw value)\n",
loadseg, loadseg);
break;
}

printf("\tSystem type: %d (0x%02x)\n", SectionEntry->SystemType,
SectionEntry->SystemType);
printf("\tLoad Sectors: %d (0x%04x)\n", sectors, sectors);
printf("\tLoad LBA: %d (0x%08x)\n", lba, lba);

} else if (context->dumpXml) {
xmlTextWriterStartElement(context->writer,
BAD_CAST "BootCatalogSectionEntry");

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "Bootable", "%s",
SectionEntry->BootIndicator ? "True" : "False");

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "BootMediaEmulationType", "%s", bmtype);

xmlTextWriterStartElement(context->writer,
BAD_CAST "MediaLoadSegment");
switch (platform_id) {
case x86:
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "RawValue",
"0x%04x", loadseg);
if (loadseg == 0) {
xmlTextWriterWriteFormatAttribute(
context->writer,
BAD_CAST "Value",
"0000:7c00");
} else {
xmlTextWriterWriteFormatAttribute(
context->writer,
BAD_CAST "Value",
"%04x:0000", loadseg);
}
xmlTextWriterWriteFormatAttribute(
context->writer, BAD_CAST "ValueType",
"Interpreted");
break;
case ppc:
case m68kmac:
case efi:
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "RawValue",
"0x%04x", loadseg);
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "Value",
"0x%04x", loadseg * 0x10);
xmlTextWriterWriteFormatAttribute(
context->writer, BAD_CAST "ValueType",
"Interpreted");
break;
default:
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "RawValue",
"0x%04x", loadseg);
xmlTextWriterWriteFormatAttribute(context->writer,
BAD_CAST "Value",
"0x%04x", loadseg);
xmlTextWriterWriteFormatAttribute(
context->writer, BAD_CAST "ValueType",
"Raw");
break;
}
xmlTextWriterEndElement(context->writer); /* end MediaLoadSegment */

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "SystemType", "0x%02x",
SectionEntry->SystemType);

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "LoadSectors", "0x%04x", sectors);

xmlTextWriterWriteFormatElement(context->writer,
BAD_CAST "LoadLBA", "0x%08x", lba);
}

if (context->dumpDiskImage)
dumpBootImage(context, lba, sectors, file_num++);

if (context->dumpXml)
xmlTextWriterEndElement(context->writer); /* end BootCatalogSectionEntry */
}
*next_header_num = entry_num + i;
}

if (context->dumpXml) {
/* Either A ValidationEntry or a SectionHeaderEntry is open here */
xmlTextWriterEndElement(context->writer);
}

return 0;
}

static int dumpet(struct context *context)
{
BootCatalog bc;
uint32_t bootCatLba;
int filenum = 0;
int next_header_num = 0;
int rc;

bootCatLba = dump_boot_record(context);

rc = read_sector(context->iso, bootCatLba, (Sector *)&bc);
if (rc < 0)
exit(4);

rc = checkValidationEntry(context, &bc.Catalog[0].ValidationEntry);
if (rc < 0) {
if (context->dumpStdOut)
printf("Validation Entry Checksum is incorrect\n");
return -1;
}
rc = dumpEntry(context->iso, &bc.Catalog[0],
next_header_num, next_header_num+1, &next_header_num,
filenum++, context);

while (1) {
BootCatalogSectionHeaderEntry *SectionHeader =
(BootCatalogSectionHeaderEntry *)&bc.Catalog[next_header_num];

if (SectionHeader->HeaderIndicator == SectionHeaderIndicator ||
SectionHeader->HeaderIndicator == FinalSectionHeaderIndicator) {
rc = dumpEntry(context->iso, &bc.Catalog[0], next_header_num, next_header_num+1,
&next_header_num, filenum++, context);
} else {
break;
}
}

//write(STDOUT_FILENO, &bc, sizeof(bc));

return 0;
}

static void usage(int error)
{
FILE *outfile = error ? stderr : stdout;

fprintf(outfile, "usage: dumpet --help\n"
" dumpet -i <file> [-d] [-h|-x]\n");
exit(error);
}

int main(int argc, char *argv[])
{
int rc;

int help = 0;
struct context context = { 0 };
xmlBufferPtr xml = NULL;

poptContext optCon;
struct poptOption optionTable[] = {
{ "help", '?', POPT_ARG_NONE, &help, 0, NULL, "help"},
{ "dumpdisks", 'd', POPT_ARG_NONE, &context.dumpDiskImage, 0, NULL, "dump each El Torito boot image into a file"},
{ "dumphex", 'h', POPT_ARG_NONE, &context.dumpHex, 0, NULL, "dump each El Torito structure in hex"},
{ "iso", 'i', POPT_ARG_STRING, &context.filename, 0, NULL, "input ISO image"},
{ "xml", 'x', POPT_ARG_NONE, &context.dumpXml, 0, NULL, "dump the El Torito structure as an XML document"},
{0}
};

optCon = poptGetContext(NULL, argc, (const char **)argv, optionTable, 0);

if ((rc = poptGetNextOpt(optCon)) < -1) {
fprintf(stderr, "dumpet: bad option \"%s\": %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(rc));
usage(2);
exit(2);
}

if (help)
usage(0);
else if (!context.filename)
usage(3);

context.iso = fopen(context.filename, "r");
if (!context.iso) {
fprintf(stderr, "Could not open \"%s\": %m\n", context.filename);
exit(2);
}

if (context.dumpXml) {
xml = xmlBufferCreate();
if (!xml) {
fprintf(stderr, "Error creating XML buffer: %m\n");
exit(3);
}
context.writer = xmlNewTextWriterMemory(xml, 0);
if (!context.writer) {
fprintf(stderr, "Error creating XML writer\n");
exit(3);
}
rc = xmlTextWriterStartDocument(context.writer, NULL, "UTF-8", NULL);
if (rc < 0) {
fprintf(stderr, "Error starting new XML document\n");
exit(3);
}
rc = xmlTextWriterStartElement(context.writer, BAD_CAST "ElToritoBootCatalog");
if (rc < 0) {
fprintf(stderr, "Error creating element \"El-Torito\"\n");
exit(3);
}
} else {
context.dumpStdOut = 1;
}

rc = dumpet(&context);

fclose(context.iso);
free(context.filename);

poptFreeContext(optCon);

if (context.dumpXml) {
rc = xmlTextWriterEndElement(context.writer);
rc = xmlTextWriterEndDocument(context.writer);
xmlFreeTextWriter(context.writer);
printf("%s", xml->content);
xmlBufferFree(xml);
}

return rc;
}

/* vim:set shiftwidth=8 softtabstop=8: */
dumpet-2.1/dumpet.h000064400000000000000000000032371176312537400143350ustar00rootroot00000000000000/*
* Copyright 2009 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Peter Jones <pjones@redhat.com>
*/

#ifndef DUMPET_H
#define DUMPET_H

#include <errno.h>

#include "iso9660.h"
#include "eltorito.h"

static inline off_t get_sector_offset(int sector_number)
{
Sector sector;
return sector_number * sizeof(sector);
}

static inline int read_sector(FILE *iso, int sector_number, Sector *sector)
{
size_t n;
fseek(iso, get_sector_offset(sector_number), SEEK_SET);
n = fread(sector, sizeof(*sector), 1, iso);

if (n != 1) {
int errnum = errno;
fprintf(stderr, "dumpet: Error reading image: %m\n");
errno = errnum;
return -errno;
}
return 0;
}

static inline int write_sector(FILE *iso, int sector_number, Sector *sector)
{
size_t n;
fseek(iso, get_sector_offset(sector_number), SEEK_SET);
n = fwrite(sector, sizeof(*sector), 1, iso);

if (n != 1) {
int errnum = errno;
fprintf(stderr, "dumpet: Error writing image: %m\n");
errno = errnum;
return -errno;
}
return 0;

}

#endif /* DUMPET_H */
/* vim:set shiftwidth=8 softtabstop=8: */
dumpet-2.1/eltorito.h000064400000000000000000000105341176312537400146760ustar00rootroot00000000000000/*
* Copyright 2009 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Peter Jones <pjones@redhat.com>
*/
#ifndef ELTORITO_H
#define ELTORITO_H

#include "iso9660.h"

typedef union {
Sector Raw;
struct {
uint8_t BootRecordIndicator;
char Iso9660[5];
uint8_t Version;
char BootSystemId[32];
uint8_t Reserved0[32];
uint32_t BootCatalogLBA;
} __attribute__((packed));
} BootRecordVolumeDescriptor;

typedef enum {
ValidationIndicator = 0x01,
SectionHeaderIndicator = 0x90,
FinalSectionHeaderIndicator = 0x91,
ExtensionIndicator = 0x44,
} SectionHeaderIndicatorType;

typedef enum {
x86 = 0,
ppc = 1,
m68kmac = 2,
efi=0xef
} PlatformId;

typedef enum {
NotBootable,
Bootable = 0x88
} BootIndicator;

typedef enum {
NoEmulation,
OneTwoDiskette,
OneFourFourDiskette,
TwoEightEightDiskette,
HardDisk
} BootMediaType;

/* A typical boot catalog validation entry looks like this:
* 00000000 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
* 00000010 00 00 00 00 00 00 00 00 00 00 00 00 aa 55 55 aa |.............UU.|
*/
typedef struct {
uint8_t HeaderIndicator;
uint8_t PlatformId;
uint8_t Reserved0[2];
char Id[24];
uint16_t Checksum;
uint8_t FiveFive;
uint8_t AA;
} __attribute__((packed)) BootCatalogValidationEntry;

/* A an Initial/Default Entry looks like this:
* 00000020 88 00 00 00 00 00 1c 00 91 01 00 00 00 00 00 00 |................|
* 00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*/
typedef struct {
uint8_t BootIndicator;
uint8_t BootMediaType;
uint16_t LoadSegment;
uint8_t SystemType;
uint8_t Reserved0;
uint16_t SectorCount;
uint32_t LoadLBA;
char Reserved1[20];
} BootCatalogDefaultEntry;

/* An EFI Section Header Entry looks like this:
* 00000040 91 ef 01 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
* 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*/
typedef struct {
uint8_t HeaderIndicator;
uint8_t PlatformId;
uint16_t SectionEntryCount;
char Id[28];
} BootCatalogSectionHeaderEntry;

typedef enum {
NoSelectionCriteria,
LanguageAndVersionInformation
} SelectionCriteriaType;

/* An EFI Section Entry looks like this:
* 00000060 88 00 00 00 00 00 04 00 b1 00 00 00 00 00 00 00 |................|
* 00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*/
typedef struct {
uint8_t BootIndicator;
uint8_t BootMediaType;
uint16_t LoadSegment;
uint8_t SystemType;
uint8_t Reserved0;
uint16_t SectorCount;
uint32_t LoadLBA;
uint8_t SelectionCriteriaType;
uint8_t VendorUniqueSelectionCriteria[18];
} BootCatalogSectionEntry;

typedef union {
uint8_t Raw[32];
BootCatalogValidationEntry ValidationEntry;
BootCatalogDefaultEntry DefaultEntry;
BootCatalogSectionHeaderEntry SectionHeaderEntry;
BootCatalogSectionEntry SectionEntry;
} BootCatalogEntry;

/* A(n a)typical boot catalog looks like this:
* Validation Entry:
* 00000000 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
* 00000010 00 00 00 00 00 00 00 00 00 00 00 00 aa 55 55 aa |.............UU.|
* Initial/Default Entry:
* 00000020 88 00 00 00 00 00 1c 00 91 01 00 00 00 00 00 00 |................|
* 00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
* Section Header Entry:
* 00000040 91 ef 01 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
* 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
* Section Entry:
* 00000060 88 00 00 00 00 00 04 00 b1 00 00 00 00 00 00 00 |................|
* 00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*/
typedef union {
Sector Raw;
BootCatalogEntry Catalog[64];
} BootCatalog;

#endif /* ELTORITO_H */
/* vim:set shiftwidth=8 softtabstop=8: */
dumpet-2.1/endian.h000064400000000000000000000032111176312537400142650ustar00rootroot00000000000000/*
* Copyright 2009 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Peter Jones <pjones@redhat.com>
*/
#ifndef ENDIAN_H
#define ENDIAN_H

#include <endian.h>

#if __BYTE_ORDER == __LITTLE_ENDIAN
#define cpu_to_le16(x) (x)
#define cpu_to_le32(x) (x)
#define cpu_to_le64(x) (x)
#define le16_to_cpu(x) (x)
#define le32_to_cpu(x) (x)
#define le64_to_cpu(x) (x)
#define cpu_to_be16(x) __bswap_16(x)
#define cpu_to_be32(x) __bswap_32(x)
#define cpu_to_be64(x) __bswap_64(x)
#define be16_to_cpu(x) __bswap_16(x)
#define be32_to_cpu(x) __bswap_32(x)
#define be64_to_cpu(x) __bswap_64(x)
#else
#define cpu_to_be16(x) (x)
#define cpu_to_be32(x) (x)
#define cpu_to_be64(x) (x)
#define be16_to_cpu(x) (x)
#define be32_to_cpu(x) (x)
#define be64_to_cpu(x) (x)
#define cpu_to_le16(x) __bswap_16(x)
#define cpu_to_le32(x) __bswap_32(x)
#define cpu_to_le64(x) __bswap_64(x)
#define le16_to_cpu(x) __bswap_16(x)
#define le32_to_cpu(x) __bswap_32(x)
#define le64_to_cpu(x) __bswap_64(x)
#endif

#endif /* ENDIAN_H */
/* vim:set shiftwidth=8 softtabstop=8: */
dumpet-2.1/iso9660.h000064400000000000000000000073721176312537400141620ustar00rootroot00000000000000/*
* Copyright 2009 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Peter Jones <pjones@redhat.com>
*/
#ifndef ISO9660_H
#define ISO9660_H

#include "endian.h"

typedef char Sector[0x800];

/* ISO 9660 section 7.2.1 = 16 bit little endian */
#define cpu16_to_iso721(x) cpu_to_le16(x)
#define iso721_to_cpu16(x) le16_to_cpu(x)

/* ISO 9660 section 7.2.2 = 16 bit big endian */
#define cpu16_to_iso722(x) cpu_to_be16(x)
#define iso722_to_cpu16(x) be16_to_cpu(x)

/* ISO 9660 section 7.2.3 = Both endians! */
#define cpu16_to_iso723(x) ((uint32_t)(cpu_to_be16(x) | (cpu_to_le16(x) << 16)))
#define iso723_to_cpu16(x) be16_to_cpu((uint16_t)((x) & 0xffff))

/* ISO 9660 section 7.3.1 = 32 bit little endian */
#define cpu32_to_iso731(x) cpu_to_le32(x)
#define iso731_to_cpu32(x) le32_to_cpu(x)

/* ISO 9660 section 7.3.2 = 32 bit big endian */
#define cpu32_to_iso732(x) cpu_to_be32(x)
#define iso732_to_cpu32(x) be32_to_cpu(x)

/* ISO9660 section 7.3.3 = 32-bit both endians! */
#define cpu32_to_iso733(x) ((uint64_t)(cpu_to_be32(x) | ( ((uint64_t)cpu_to_le32(x)) << 32)))
#define iso733_to_cpu32(x) be32_to_cpu((uint32_t)((x) & 0xffffffff))

#if 0
static void test_iso_functions(void)
{
char input[] = "\x01\x23\x45\x67\x89\xab\xcd\xef";
uint16_t input16;
uint32_t input32;
uint64_t input64;

uint16_t output16;
uint32_t output32;
uint64_t output64;

memcpy(&input16, input, sizeof(input16));
output16 = cpu16_to_iso721(input16);
fprintf(stdout, "cpu16_to_iso721(0x%04x) = 0x%04x\n", input16, output16);
input16 = output16;
output16 = iso721_to_cpu16(input16);
fprintf(stdout, "iso721_to_cpu16(0x%04x) = 0x%04x\n", input16, output16);

memcpy(&input16, input, sizeof(input16));
output16 = cpu16_to_iso722(input16);
fprintf(stdout, "cpu16_to_iso722(0x%04x) = 0x%04x\n", input16, output16);
input16 = output16;
output16 = iso722_to_cpu16(input16);
fprintf(stdout, "iso722_to_cpu16(0x%04x) = 0x%04x\n", input16, output16);

memcpy(&input16, input, sizeof(input16));
output32 = cpu16_to_iso723(input16);
fprintf(stdout, "cpu16_to_iso723(0x%04x) = 0x%08x\n", input16, output32);
input32 = output32;
output16 = iso723_to_cpu16(input32);
fprintf(stdout, "iso723_to_cpu16(0x%08x) = 0x%04x\n", input32, output16);

memcpy(&input32, input, sizeof(input32));
output32 = cpu32_to_iso731(input32);
fprintf(stdout, "cpu32_to_iso731(0x%08x) = 0x%08x\n", input32, output32);
input32 = output32;
output32 = iso731_to_cpu32(input32);
fprintf(stdout, "iso731_to_cpu32(0x%08x) = 0x%08x\n", input32, output32);

memcpy(&input32, input, sizeof(input32));
output32 = cpu32_to_iso732(input32);
fprintf(stdout, "cpu32_to_iso732(0x%08x) = 0x%08x\n", input32, output32);
input32 = output32;
output32 = iso732_to_cpu32(input32);
fprintf(stdout, "iso732_to_cpu32(0x%08x) = 0x%08x\n", input32, output32);

memcpy(&input32, input, sizeof(input32));
output64 = cpu32_to_iso733(input32);
fprintf(stdout, "cpu32_to_iso733(0x%04x) = 0x%0" PRIx64 "\n", input32, output64);
input64 = output64;
output32 = iso733_to_cpu32(input64);
fprintf(stdout, "iso733_to_cpu32(0x%0" PRIx64") = 0x%04x\n", input64, output32);

exit(0);
}
#endif


#endif /* ISO9660_H */
/* vim:set shiftwidth=8 softtabstop=8: */
dumpet-2.1/spec_patches/000075500000000000000000000000001176312537400153225ustar00rootroot00000000000000dumpet-2.1/spec_patches/dumpet.spec000064400000000000000000000012411176312537400174720ustar00rootroot00000000000000Name: dumpet
Version: 2.1
Release: alt1
Summary: A tool to dump and debug bootable CD images
Packager: Mike Pluzhnikov <amike@altlinux.ru>
License: GPLv2+
Group: Development/Tools
Url: https://fedorahosted.org/dumpet/
Source0: https://fedorahosted.org/releases/d/u/dumpet/dumpet-%version.tar
BuildRequires: libpopt-devel libxml2-devel

%description
DumpET is a utility to aid in the debugging of bootable CD-ROM images.

%prep
%setup

%build
%make_build

%install
mkdir -p %buildroot/%_bindir
%makeinstall_std

%files
%doc README TODO COPYING
%_man1dir/dumpet.1*
%_bindir/dumpet

%changelog
* Fri Jun 01 2012 Mikhail Pluzhnikov <amike@altlinux.ru> 2.1-alt1
- First build

 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin