101a0f853SOlivier Houchard /* $NetBSD: cd9660_debug.c,v 1.11 2010/10/27 18:51:35 christos Exp $ */
201a0f853SOlivier Houchard
31de7b4b8SPedro F. Giffuni /*-
4*b61a5730SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
51de7b4b8SPedro F. Giffuni *
601a0f853SOlivier Houchard * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
701a0f853SOlivier Houchard * Perez-Rathke and Ram Vedam. All rights reserved.
801a0f853SOlivier Houchard *
901a0f853SOlivier Houchard * This code was written by Daniel Watt, Walter Deignan, Ryan Gabrys,
1001a0f853SOlivier Houchard * Alan Perez-Rathke and Ram Vedam.
1101a0f853SOlivier Houchard *
1201a0f853SOlivier Houchard * Redistribution and use in source and binary forms, with or
1301a0f853SOlivier Houchard * without modification, are permitted provided that the following
1401a0f853SOlivier Houchard * conditions are met:
1501a0f853SOlivier Houchard * 1. Redistributions of source code must retain the above copyright
1601a0f853SOlivier Houchard * notice, this list of conditions and the following disclaimer.
1701a0f853SOlivier Houchard * 2. Redistributions in binary form must reproduce the above
1801a0f853SOlivier Houchard * copyright notice, this list of conditions and the following
1901a0f853SOlivier Houchard * disclaimer in the documentation and/or other materials provided
2001a0f853SOlivier Houchard * with the distribution.
2101a0f853SOlivier Houchard *
2201a0f853SOlivier Houchard * THIS SOFTWARE IS PROVIDED BY DANIEL WATT, WALTER DEIGNAN, RYAN
2301a0f853SOlivier Houchard * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM ``AS IS'' AND ANY EXPRESS OR
2401a0f853SOlivier Houchard * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2501a0f853SOlivier Houchard * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2601a0f853SOlivier Houchard * DISCLAIMED. IN NO EVENT SHALL DANIEL WATT, WALTER DEIGNAN, RYAN
2701a0f853SOlivier Houchard * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM BE LIABLE FOR ANY DIRECT, INDIRECT,
2801a0f853SOlivier Houchard * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2901a0f853SOlivier Houchard * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
3001a0f853SOlivier Houchard * USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3101a0f853SOlivier Houchard * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3201a0f853SOlivier Houchard * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3301a0f853SOlivier Houchard * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
3401a0f853SOlivier Houchard * OF SUCH DAMAGE.
3501a0f853SOlivier Houchard */
3601a0f853SOlivier Houchard
3701a0f853SOlivier Houchard #include <sys/param.h>
3801a0f853SOlivier Houchard
3901a0f853SOlivier Houchard #include <sys/mount.h>
4001a0f853SOlivier Houchard
4101a0f853SOlivier Houchard #include "makefs.h"
4201a0f853SOlivier Houchard #include "cd9660.h"
4301a0f853SOlivier Houchard #include "iso9660_rrip.h"
4401a0f853SOlivier Houchard
4501a0f853SOlivier Houchard static void debug_print_susp_attrs(cd9660node *, int);
46fe41c64bSAlex Richardson static void debug_dump_to_xml_padded_hex_output(const char *, const char *,
4701a0f853SOlivier Houchard int);
4801a0f853SOlivier Houchard
4901a0f853SOlivier Houchard static inline void
print_n_tabs(int n)5001a0f853SOlivier Houchard print_n_tabs(int n)
5101a0f853SOlivier Houchard {
5201a0f853SOlivier Houchard int i;
5301a0f853SOlivier Houchard
5401a0f853SOlivier Houchard for (i = 1; i <= n; i ++)
5501a0f853SOlivier Houchard printf("\t");
5601a0f853SOlivier Houchard }
5701a0f853SOlivier Houchard
5801a0f853SOlivier Houchard #if 0
5901a0f853SOlivier Houchard void
60ab6f27aaSEd Maste debug_print_rrip_info(cd9660node *n)
6101a0f853SOlivier Houchard {
6201a0f853SOlivier Houchard struct ISO_SUSP_ATTRIBUTES *t;
6301a0f853SOlivier Houchard TAILQ_FOREACH(t, &node->head, rr_ll) {
6401a0f853SOlivier Houchard
6501a0f853SOlivier Houchard }
6601a0f853SOlivier Houchard }
6701a0f853SOlivier Houchard #endif
6801a0f853SOlivier Houchard
6901a0f853SOlivier Houchard static void
debug_print_susp_attrs(cd9660node * n,int indent)7001a0f853SOlivier Houchard debug_print_susp_attrs(cd9660node *n, int indent)
7101a0f853SOlivier Houchard {
7201a0f853SOlivier Houchard struct ISO_SUSP_ATTRIBUTES *t;
7301a0f853SOlivier Houchard
7401a0f853SOlivier Houchard TAILQ_FOREACH(t, &n->head, rr_ll) {
7501a0f853SOlivier Houchard print_n_tabs(indent);
7601a0f853SOlivier Houchard printf("-");
7701a0f853SOlivier Houchard printf("%c%c: L:%i",t->attr.su_entry.SP.h.type[0],
7801a0f853SOlivier Houchard t->attr.su_entry.SP.h.type[1],
7901a0f853SOlivier Houchard (int)t->attr.su_entry.SP.h.length[0]);
8001a0f853SOlivier Houchard printf("\n");
8101a0f853SOlivier Houchard }
8201a0f853SOlivier Houchard }
8301a0f853SOlivier Houchard
8401a0f853SOlivier Houchard void
debug_print_tree(iso9660_disk * diskStructure,cd9660node * node,int level)851631d42aSEd Maste debug_print_tree(iso9660_disk *diskStructure, cd9660node *node, int level)
8601a0f853SOlivier Houchard {
8701a0f853SOlivier Houchard #if !HAVE_NBTOOL_CONFIG_H
8801a0f853SOlivier Houchard cd9660node *cn;
8901a0f853SOlivier Houchard
9001a0f853SOlivier Houchard print_n_tabs(level);
9101a0f853SOlivier Houchard if (node->type & CD9660_TYPE_DOT) {
9201a0f853SOlivier Houchard printf(". (%i)\n",
9301a0f853SOlivier Houchard isonum_733(node->isoDirRecord->extent));
9401a0f853SOlivier Houchard } else if (node->type & CD9660_TYPE_DOTDOT) {
9501a0f853SOlivier Houchard printf("..(%i)\n",
9601a0f853SOlivier Houchard isonum_733(node->isoDirRecord->extent));
9701a0f853SOlivier Houchard } else if (node->isoDirRecord->name[0]=='\0') {
9801a0f853SOlivier Houchard printf("(ROOT) (%" PRIu32 " to %" PRId64 ")\n",
9901a0f853SOlivier Houchard node->fileDataSector,
10001a0f853SOlivier Houchard node->fileDataSector +
10101a0f853SOlivier Houchard node->fileSectorsUsed - 1);
10201a0f853SOlivier Houchard } else {
10301a0f853SOlivier Houchard printf("%s (%s) (%" PRIu32 " to %" PRId64 ")\n",
10401a0f853SOlivier Houchard node->isoDirRecord->name,
10501a0f853SOlivier Houchard (node->isoDirRecord->flags[0]
10601a0f853SOlivier Houchard & ISO_FLAG_DIRECTORY) ? "DIR" : "FILE",
10701a0f853SOlivier Houchard node->fileDataSector,
10801a0f853SOlivier Houchard (node->fileSectorsUsed == 0) ?
10901a0f853SOlivier Houchard node->fileDataSector :
11001a0f853SOlivier Houchard node->fileDataSector
11101a0f853SOlivier Houchard + node->fileSectorsUsed - 1);
11201a0f853SOlivier Houchard }
1131631d42aSEd Maste if (diskStructure->rock_ridge_enabled)
11401a0f853SOlivier Houchard debug_print_susp_attrs(node, level + 1);
11501a0f853SOlivier Houchard TAILQ_FOREACH(cn, &node->cn_children, cn_next_child)
1161631d42aSEd Maste debug_print_tree(diskStructure, cn, level + 1);
11701a0f853SOlivier Houchard #else
11801a0f853SOlivier Houchard printf("Sorry, debugging is not supported in host-tools mode.\n");
11901a0f853SOlivier Houchard #endif
12001a0f853SOlivier Houchard }
12101a0f853SOlivier Houchard
12201a0f853SOlivier Houchard void
debug_print_path_tree(cd9660node * n)12301a0f853SOlivier Houchard debug_print_path_tree(cd9660node *n)
12401a0f853SOlivier Houchard {
12501a0f853SOlivier Houchard cd9660node *iterator = n;
12601a0f853SOlivier Houchard
12701a0f853SOlivier Houchard /* Only display this message when called with the root node */
12801a0f853SOlivier Houchard if (n->parent == NULL)
12901a0f853SOlivier Houchard printf("debug_print_path_table: Dumping path table contents\n");
13001a0f853SOlivier Houchard
13101a0f853SOlivier Houchard while (iterator != NULL) {
13201a0f853SOlivier Houchard if (iterator->isoDirRecord->name[0] == '\0')
13301a0f853SOlivier Houchard printf("0) (ROOT)\n");
13401a0f853SOlivier Houchard else
13501a0f853SOlivier Houchard printf("%i) %s\n", iterator->level,
13601a0f853SOlivier Houchard iterator->isoDirRecord->name);
13701a0f853SOlivier Houchard
13801a0f853SOlivier Houchard iterator = iterator->ptnext;
13901a0f853SOlivier Houchard }
14001a0f853SOlivier Houchard }
14101a0f853SOlivier Houchard
14201a0f853SOlivier Houchard void
debug_print_volume_descriptor_information(iso9660_disk * diskStructure)1431631d42aSEd Maste debug_print_volume_descriptor_information(iso9660_disk *diskStructure)
14401a0f853SOlivier Houchard {
1451631d42aSEd Maste volume_descriptor *tmp = diskStructure->firstVolumeDescriptor;
14601a0f853SOlivier Houchard char temp[CD9660_SECTOR_SIZE];
14701a0f853SOlivier Houchard
14801a0f853SOlivier Houchard printf("==Listing Volume Descriptors==\n");
14901a0f853SOlivier Houchard
15001a0f853SOlivier Houchard while (tmp != NULL) {
15101a0f853SOlivier Houchard memset(temp, 0, CD9660_SECTOR_SIZE);
15201a0f853SOlivier Houchard memcpy(temp, tmp->volumeDescriptorData + 1, 5);
15301a0f853SOlivier Houchard printf("Volume descriptor in sector %" PRId64
15401a0f853SOlivier Houchard ": type %i, ID %s\n",
15501a0f853SOlivier Houchard tmp->sector, tmp->volumeDescriptorData[0], temp);
15601a0f853SOlivier Houchard switch(tmp->volumeDescriptorData[0]) {
15701a0f853SOlivier Houchard case 0:/*boot record*/
15801a0f853SOlivier Houchard break;
15901a0f853SOlivier Houchard
16001a0f853SOlivier Houchard case 1: /* PVD */
16101a0f853SOlivier Houchard break;
16201a0f853SOlivier Houchard
16301a0f853SOlivier Houchard case 2: /* SVD */
16401a0f853SOlivier Houchard break;
16501a0f853SOlivier Houchard
16601a0f853SOlivier Houchard case 3: /* Volume Partition Descriptor */
16701a0f853SOlivier Houchard break;
16801a0f853SOlivier Houchard
16901a0f853SOlivier Houchard case 255: /* terminator */
17001a0f853SOlivier Houchard break;
17101a0f853SOlivier Houchard }
17201a0f853SOlivier Houchard tmp = tmp->next;
17301a0f853SOlivier Houchard }
17401a0f853SOlivier Houchard
17501a0f853SOlivier Houchard printf("==Done Listing Volume Descriptors==\n");
17601a0f853SOlivier Houchard }
17701a0f853SOlivier Houchard
17801a0f853SOlivier Houchard void
debug_dump_to_xml_ptentry(path_table_entry * pttemp,int num,int mode)17901a0f853SOlivier Houchard debug_dump_to_xml_ptentry(path_table_entry *pttemp, int num, int mode)
18001a0f853SOlivier Houchard {
18101a0f853SOlivier Houchard printf("<ptentry num=\"%i\">\n" ,num);
18201a0f853SOlivier Houchard printf("<length>%i</length>\n", pttemp->length[0]);
18301a0f853SOlivier Houchard printf("<extended_attribute_length>%i</extended_attribute_length>\n",
18401a0f853SOlivier Houchard pttemp->extended_attribute_length[0]);
18501a0f853SOlivier Houchard printf("<parent_number>%i</parent_number>\n",
18601a0f853SOlivier Houchard debug_get_encoded_number(pttemp->parent_number,mode));
18701a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("name",
18801a0f853SOlivier Houchard pttemp->name, pttemp->length[0]);
18901a0f853SOlivier Houchard printf("</ptentry>\n");
19001a0f853SOlivier Houchard }
19101a0f853SOlivier Houchard
19201a0f853SOlivier Houchard void
debug_dump_to_xml_path_table(FILE * fd,off_t sector,int size,int mode)19301a0f853SOlivier Houchard debug_dump_to_xml_path_table(FILE *fd, off_t sector, int size, int mode)
19401a0f853SOlivier Houchard {
19501a0f853SOlivier Houchard path_table_entry pttemp;
19601a0f853SOlivier Houchard int t = 0;
19701a0f853SOlivier Houchard int n = 0;
19801a0f853SOlivier Houchard
19901a0f853SOlivier Houchard if (fseeko(fd, CD9660_SECTOR_SIZE * sector, SEEK_SET) == -1)
20001a0f853SOlivier Houchard err(1, "fseeko");
20101a0f853SOlivier Houchard
20201a0f853SOlivier Houchard while (t < size) {
20301a0f853SOlivier Houchard /* Read fixed data first */
20401a0f853SOlivier Houchard fread(&pttemp, 1, 8, fd);
20501a0f853SOlivier Houchard t += 8;
20601a0f853SOlivier Houchard /* Read variable */
20701a0f853SOlivier Houchard fread(((unsigned char*)&pttemp) + 8, 1, pttemp.length[0], fd);
20801a0f853SOlivier Houchard t += pttemp.length[0];
20901a0f853SOlivier Houchard debug_dump_to_xml_ptentry(&pttemp, n, mode);
21001a0f853SOlivier Houchard n++;
21101a0f853SOlivier Houchard }
21201a0f853SOlivier Houchard
21301a0f853SOlivier Houchard }
21401a0f853SOlivier Houchard
21501a0f853SOlivier Houchard /*
21601a0f853SOlivier Houchard * XML Debug output functions
21701a0f853SOlivier Houchard * Dump hierarchy of CD, as well as volume info, to XML
21801a0f853SOlivier Houchard * Can be used later to diff against a standard,
21901a0f853SOlivier Houchard * or just provide easy to read detailed debug output
22001a0f853SOlivier Houchard */
22101a0f853SOlivier Houchard void
debug_dump_to_xml(FILE * fd)22201a0f853SOlivier Houchard debug_dump_to_xml(FILE *fd)
22301a0f853SOlivier Houchard {
22401a0f853SOlivier Houchard unsigned char buf[CD9660_SECTOR_SIZE];
22501a0f853SOlivier Houchard off_t sector;
22601a0f853SOlivier Houchard int t, t2;
22701a0f853SOlivier Houchard struct iso_primary_descriptor primaryVD;
22801a0f853SOlivier Houchard struct _boot_volume_descriptor bootVD;
22901a0f853SOlivier Houchard
23001a0f853SOlivier Houchard printf("<cd9660dump>\n");
23101a0f853SOlivier Houchard
23201a0f853SOlivier Houchard /* Display Volume Descriptors */
23301a0f853SOlivier Houchard sector = 16;
23401a0f853SOlivier Houchard do {
23501a0f853SOlivier Houchard if (fseeko(fd, CD9660_SECTOR_SIZE * sector, SEEK_SET) == -1)
23601a0f853SOlivier Houchard err(1, "fseeko");
23701a0f853SOlivier Houchard fread(buf, 1, CD9660_SECTOR_SIZE, fd);
23801a0f853SOlivier Houchard t = (int)((unsigned char)buf[0]);
23901a0f853SOlivier Houchard switch (t) {
24001a0f853SOlivier Houchard case 0:
24101a0f853SOlivier Houchard memcpy(&bootVD, buf, CD9660_SECTOR_SIZE);
24201a0f853SOlivier Houchard break;
24301a0f853SOlivier Houchard case 1:
24401a0f853SOlivier Houchard memcpy(&primaryVD, buf, CD9660_SECTOR_SIZE);
24501a0f853SOlivier Houchard break;
24601a0f853SOlivier Houchard }
24701a0f853SOlivier Houchard debug_dump_to_xml_volume_descriptor(buf, sector);
24801a0f853SOlivier Houchard sector++;
24901a0f853SOlivier Houchard } while (t != 255);
25001a0f853SOlivier Houchard
25101a0f853SOlivier Houchard t = debug_get_encoded_number((u_char *)primaryVD.type_l_path_table,
25201a0f853SOlivier Houchard 731);
25301a0f853SOlivier Houchard t2 = debug_get_encoded_number((u_char *)primaryVD.path_table_size, 733);
25401a0f853SOlivier Houchard printf("Path table 1 located at sector %i and is %i bytes long\n",
25501a0f853SOlivier Houchard t,t2);
25601a0f853SOlivier Houchard debug_dump_to_xml_path_table(fd, t, t2, 721);
25701a0f853SOlivier Houchard
25801a0f853SOlivier Houchard t = debug_get_encoded_number((u_char *)primaryVD.type_m_path_table,
25901a0f853SOlivier Houchard 731);
26001a0f853SOlivier Houchard debug_dump_to_xml_path_table(fd, t, t2, 722);
26101a0f853SOlivier Houchard
26201a0f853SOlivier Houchard printf("</cd9660dump>\n");
26301a0f853SOlivier Houchard }
26401a0f853SOlivier Houchard
26501a0f853SOlivier Houchard static void
debug_dump_to_xml_padded_hex_output(const char * element,const char * buf,int len)266fe41c64bSAlex Richardson debug_dump_to_xml_padded_hex_output(const char *element, const char *buf,
26701a0f853SOlivier Houchard int len)
26801a0f853SOlivier Houchard {
26901a0f853SOlivier Houchard int i;
27001a0f853SOlivier Houchard int t;
27101a0f853SOlivier Houchard
27201a0f853SOlivier Houchard printf("<%s>",element);
27301a0f853SOlivier Houchard for (i = 0; i < len; i++) {
27401a0f853SOlivier Houchard t = (unsigned char)buf[i];
27501a0f853SOlivier Houchard if (t >= 32 && t < 127)
27601a0f853SOlivier Houchard printf("%c",t);
27701a0f853SOlivier Houchard }
27801a0f853SOlivier Houchard printf("</%s>\n",element);
27901a0f853SOlivier Houchard
28001a0f853SOlivier Houchard printf("<%s:hex>",element);
28101a0f853SOlivier Houchard for (i = 0; i < len; i++) {
28201a0f853SOlivier Houchard t = (unsigned char)buf[i];
28301a0f853SOlivier Houchard printf(" %x",t);
28401a0f853SOlivier Houchard }
28501a0f853SOlivier Houchard printf("</%s:hex>\n",element);
28601a0f853SOlivier Houchard }
28701a0f853SOlivier Houchard
28801a0f853SOlivier Houchard int
debug_get_encoded_number(const unsigned char * buf,int mode)289fe41c64bSAlex Richardson debug_get_encoded_number(const unsigned char* buf, int mode)
29001a0f853SOlivier Houchard {
29101a0f853SOlivier Houchard #if !HAVE_NBTOOL_CONFIG_H
29201a0f853SOlivier Houchard switch (mode) {
29301a0f853SOlivier Houchard /* 711: Single bite */
29401a0f853SOlivier Houchard case 711:
29501a0f853SOlivier Houchard return isonum_711(buf);
29601a0f853SOlivier Houchard
29701a0f853SOlivier Houchard /* 712: Single signed byte */
29801a0f853SOlivier Houchard case 712:
299fe41c64bSAlex Richardson return isonum_712(buf);
30001a0f853SOlivier Houchard
30101a0f853SOlivier Houchard /* 721: 16 bit LE */
30201a0f853SOlivier Houchard case 721:
30301a0f853SOlivier Houchard return isonum_721(buf);
30401a0f853SOlivier Houchard
30501a0f853SOlivier Houchard /* 731: 32 bit LE */
30601a0f853SOlivier Houchard case 731:
30701a0f853SOlivier Houchard return isonum_731(buf);
30801a0f853SOlivier Houchard
30901a0f853SOlivier Houchard /* 722: 16 bit BE */
31001a0f853SOlivier Houchard case 722:
31101a0f853SOlivier Houchard return isonum_722(buf);
31201a0f853SOlivier Houchard
31301a0f853SOlivier Houchard /* 732: 32 bit BE */
31401a0f853SOlivier Houchard case 732:
31501a0f853SOlivier Houchard return isonum_732(buf);
31601a0f853SOlivier Houchard
31701a0f853SOlivier Houchard /* 723: 16 bit bothE */
31801a0f853SOlivier Houchard case 723:
31901a0f853SOlivier Houchard return isonum_723(buf);
32001a0f853SOlivier Houchard
32101a0f853SOlivier Houchard /* 733: 32 bit bothE */
32201a0f853SOlivier Houchard case 733:
32301a0f853SOlivier Houchard return isonum_733(buf);
32401a0f853SOlivier Houchard }
32501a0f853SOlivier Houchard #endif
32601a0f853SOlivier Houchard return 0;
32701a0f853SOlivier Houchard }
32801a0f853SOlivier Houchard
32901a0f853SOlivier Houchard void
debug_dump_integer(const char * element,const unsigned char * buf,int mode)330fe41c64bSAlex Richardson debug_dump_integer(const char *element, const unsigned char* buf, int mode)
33101a0f853SOlivier Houchard {
332fe41c64bSAlex Richardson printf("<%s>%i</%s>\n", element, debug_get_encoded_number(buf, mode),
333fe41c64bSAlex Richardson element);
33401a0f853SOlivier Houchard }
33501a0f853SOlivier Houchard
33601a0f853SOlivier Houchard void
debug_dump_string(const char * element __unused,const unsigned char * buf __unused,int len __unused)337fe41c64bSAlex Richardson debug_dump_string(const char *element __unused, const unsigned char *buf __unused, int len __unused)
33801a0f853SOlivier Houchard {
33901a0f853SOlivier Houchard
34001a0f853SOlivier Houchard }
34101a0f853SOlivier Houchard
34201a0f853SOlivier Houchard void
debug_dump_directory_record_9_1(unsigned char * buf)34301a0f853SOlivier Houchard debug_dump_directory_record_9_1(unsigned char* buf)
34401a0f853SOlivier Houchard {
345fe41c64bSAlex Richardson struct iso_directory_record *rec = (struct iso_directory_record *)buf;
34601a0f853SOlivier Houchard printf("<directoryrecord>\n");
347fe41c64bSAlex Richardson debug_dump_integer("length", rec->length, 711);
348fe41c64bSAlex Richardson debug_dump_integer("ext_attr_length", rec->ext_attr_length, 711);
349fe41c64bSAlex Richardson debug_dump_integer("extent", rec->extent, 733);
350fe41c64bSAlex Richardson debug_dump_integer("size", rec->size, 733);
351fe41c64bSAlex Richardson debug_dump_integer("flags", rec->flags, 711);
352fe41c64bSAlex Richardson debug_dump_integer("file_unit_size", rec->file_unit_size, 711);
353fe41c64bSAlex Richardson debug_dump_integer("interleave", rec->interleave, 711);
35401a0f853SOlivier Houchard debug_dump_integer("volume_sequence_number",
355fe41c64bSAlex Richardson rec->volume_sequence_number, 723);
356fe41c64bSAlex Richardson debug_dump_integer("name_len", rec->name_len, 711);
357fe41c64bSAlex Richardson debug_dump_to_xml_padded_hex_output("name", rec->name,
358fe41c64bSAlex Richardson debug_get_encoded_number(rec->length, 711));
35901a0f853SOlivier Houchard printf("</directoryrecord>\n");
36001a0f853SOlivier Houchard }
36101a0f853SOlivier Houchard
36201a0f853SOlivier Houchard
36301a0f853SOlivier Houchard void
debug_dump_to_xml_volume_descriptor(unsigned char * buf,int sector)36401a0f853SOlivier Houchard debug_dump_to_xml_volume_descriptor(unsigned char* buf, int sector)
36501a0f853SOlivier Houchard {
366fe41c64bSAlex Richardson struct iso_primary_descriptor *desc =
367fe41c64bSAlex Richardson (struct iso_primary_descriptor *)buf;
368fe41c64bSAlex Richardson
36901a0f853SOlivier Houchard printf("<volumedescriptor sector=\"%i\">\n", sector);
37001a0f853SOlivier Houchard printf("<vdtype>");
37101a0f853SOlivier Houchard switch(buf[0]) {
37201a0f853SOlivier Houchard case 0:
37301a0f853SOlivier Houchard printf("boot");
37401a0f853SOlivier Houchard break;
37501a0f853SOlivier Houchard
37601a0f853SOlivier Houchard case 1:
37701a0f853SOlivier Houchard printf("primary");
37801a0f853SOlivier Houchard break;
37901a0f853SOlivier Houchard
38001a0f853SOlivier Houchard case 2:
38101a0f853SOlivier Houchard printf("supplementary");
38201a0f853SOlivier Houchard break;
38301a0f853SOlivier Houchard
38401a0f853SOlivier Houchard case 3:
38501a0f853SOlivier Houchard printf("volume partition descriptor");
38601a0f853SOlivier Houchard break;
38701a0f853SOlivier Houchard
38801a0f853SOlivier Houchard case 255:
38901a0f853SOlivier Houchard printf("terminator");
39001a0f853SOlivier Houchard break;
39101a0f853SOlivier Houchard }
39201a0f853SOlivier Houchard
39301a0f853SOlivier Houchard printf("</vdtype>\n");
39401a0f853SOlivier Houchard switch(buf[0]) {
39501a0f853SOlivier Houchard case 1:
396fe41c64bSAlex Richardson debug_dump_integer("type", desc->type, 711);
397fe41c64bSAlex Richardson debug_dump_to_xml_padded_hex_output("id", desc->id,
39801a0f853SOlivier Houchard ISODCL(2, 6));
399fe41c64bSAlex Richardson debug_dump_integer("version", (u_char *)desc->version, 711);
40001a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("system_id",
401fe41c64bSAlex Richardson desc->system_id, ISODCL(9, 40));
40201a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("volume_id",
403fe41c64bSAlex Richardson desc->volume_id, ISODCL(41, 72));
40401a0f853SOlivier Houchard debug_dump_integer("volume_space_size",
405fe41c64bSAlex Richardson (u_char *)desc->volume_space_size, 733);
40601a0f853SOlivier Houchard debug_dump_integer("volume_set_size",
407fe41c64bSAlex Richardson (u_char *)desc->volume_set_size, 733);
40801a0f853SOlivier Houchard debug_dump_integer("volume_sequence_number",
409fe41c64bSAlex Richardson (u_char *)desc->volume_sequence_number, 723);
41001a0f853SOlivier Houchard debug_dump_integer("logical_block_size",
411fe41c64bSAlex Richardson (u_char *)desc->logical_block_size, 723);
41201a0f853SOlivier Houchard debug_dump_integer("path_table_size",
413fe41c64bSAlex Richardson (u_char *)desc->path_table_size, 733);
41401a0f853SOlivier Houchard debug_dump_integer("type_l_path_table",
415fe41c64bSAlex Richardson (u_char *)desc->type_l_path_table, 731);
41601a0f853SOlivier Houchard debug_dump_integer("opt_type_l_path_table",
417fe41c64bSAlex Richardson (u_char *)desc->opt_type_l_path_table, 731);
41801a0f853SOlivier Houchard debug_dump_integer("type_m_path_table",
419fe41c64bSAlex Richardson (u_char *)desc->type_m_path_table, 732);
42001a0f853SOlivier Houchard debug_dump_integer("opt_type_m_path_table",
421fe41c64bSAlex Richardson (u_char *)desc->opt_type_m_path_table, 732);
42201a0f853SOlivier Houchard debug_dump_directory_record_9_1(
423fe41c64bSAlex Richardson (u_char *)desc->root_directory_record);
42401a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("volume_set_id",
425fe41c64bSAlex Richardson desc->volume_set_id, ISODCL(191, 318));
42601a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("publisher_id",
427fe41c64bSAlex Richardson desc->publisher_id, ISODCL(319, 446));
42801a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("preparer_id",
429fe41c64bSAlex Richardson desc->preparer_id, ISODCL(447, 574));
43001a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("application_id",
431fe41c64bSAlex Richardson desc->application_id, ISODCL(575, 702));
43201a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("copyright_file_id",
433fe41c64bSAlex Richardson desc->copyright_file_id, ISODCL(703, 739));
43401a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("abstract_file_id",
435fe41c64bSAlex Richardson desc->abstract_file_id, ISODCL(740, 776));
43601a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("bibliographic_file_id",
437fe41c64bSAlex Richardson desc->bibliographic_file_id, ISODCL(777, 813));
43801a0f853SOlivier Houchard
43901a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("creation_date",
440fe41c64bSAlex Richardson desc->creation_date, ISODCL(814, 830));
44101a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("modification_date",
442fe41c64bSAlex Richardson desc->modification_date, ISODCL(831, 847));
44301a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("expiration_date",
444fe41c64bSAlex Richardson desc->expiration_date, ISODCL(848, 864));
44501a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("effective_date",
446fe41c64bSAlex Richardson desc->effective_date, ISODCL(865, 881));
44701a0f853SOlivier Houchard
44801a0f853SOlivier Houchard debug_dump_to_xml_padded_hex_output("file_structure_version",
449fe41c64bSAlex Richardson desc->file_structure_version, ISODCL(882, 882));
45001a0f853SOlivier Houchard break;
45101a0f853SOlivier Houchard }
45201a0f853SOlivier Houchard printf("</volumedescriptor>\n");
45301a0f853SOlivier Houchard }
45401a0f853SOlivier Houchard
455