xref: /netbsd-src/usr.sbin/makefs/cd9660/cd9660_debug.c (revision ec5d1d82264719b6458ad15f7bffd992eca8419f)
1*ec5d1d82Stsutsui /*	$NetBSD: cd9660_debug.c,v 1.14 2023/12/28 12:13:55 tsutsui Exp $	*/
23550dc98Sfvdl 
33550dc98Sfvdl /*
43550dc98Sfvdl  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
53550dc98Sfvdl  * Perez-Rathke and Ram Vedam.  All rights reserved.
63550dc98Sfvdl  *
73550dc98Sfvdl  * This code was written by Daniel Watt, Walter Deignan, Ryan Gabrys,
83550dc98Sfvdl  * Alan Perez-Rathke and Ram Vedam.
93550dc98Sfvdl  *
103550dc98Sfvdl  * Redistribution and use in source and binary forms, with or
113550dc98Sfvdl  * without modification, are permitted provided that the following
123550dc98Sfvdl  * conditions are met:
133550dc98Sfvdl  * 1. Redistributions of source code must retain the above copyright
143550dc98Sfvdl  *    notice, this list of conditions and the following disclaimer.
153550dc98Sfvdl  * 2. Redistributions in binary form must reproduce the above
163550dc98Sfvdl  *    copyright notice, this list of conditions and the following
173550dc98Sfvdl  *    disclaimer in the documentation and/or other materials provided
183550dc98Sfvdl  *    with the distribution.
193550dc98Sfvdl  *
203550dc98Sfvdl  * THIS SOFTWARE IS PROVIDED BY DANIEL WATT, WALTER DEIGNAN, RYAN
213550dc98Sfvdl  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM ``AS IS'' AND ANY EXPRESS OR
223550dc98Sfvdl  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
233550dc98Sfvdl  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
243550dc98Sfvdl  * DISCLAIMED.  IN NO EVENT SHALL DANIEL WATT, WALTER DEIGNAN, RYAN
253550dc98Sfvdl  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM BE LIABLE FOR ANY DIRECT, INDIRECT,
263550dc98Sfvdl  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
273550dc98Sfvdl  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
283550dc98Sfvdl  * USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
293550dc98Sfvdl  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
303550dc98Sfvdl  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
313550dc98Sfvdl  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
323550dc98Sfvdl  * OF SUCH DAMAGE.
333550dc98Sfvdl  */
343550dc98Sfvdl 
353550dc98Sfvdl #if HAVE_NBTOOL_CONFIG_H
363550dc98Sfvdl #include "nbtool_config.h"
373550dc98Sfvdl #endif
383550dc98Sfvdl 
393550dc98Sfvdl #include <sys/cdefs.h>
403550dc98Sfvdl #include <sys/param.h>
413550dc98Sfvdl 
423550dc98Sfvdl #if defined(__RCSID) && !defined(__lint)
43*ec5d1d82Stsutsui __RCSID("$NetBSD: cd9660_debug.c,v 1.14 2023/12/28 12:13:55 tsutsui Exp $");
443550dc98Sfvdl #endif  /* !__lint */
453550dc98Sfvdl 
463550dc98Sfvdl #if !HAVE_NBTOOL_CONFIG_H
473550dc98Sfvdl #include <sys/mount.h>
483550dc98Sfvdl #endif
493550dc98Sfvdl 
503550dc98Sfvdl #include "makefs.h"
513550dc98Sfvdl #include "cd9660.h"
523550dc98Sfvdl #include "iso9660_rrip.h"
533550dc98Sfvdl 
543550dc98Sfvdl static void debug_print_susp_attrs(cd9660node *, int);
553550dc98Sfvdl static void debug_dump_to_xml_padded_hex_output(const char *, unsigned char *,
563550dc98Sfvdl 						int);
573550dc98Sfvdl 
58ae6ae2c3Sperry static inline void
print_n_tabs(int n)593550dc98Sfvdl print_n_tabs(int n)
603550dc98Sfvdl {
613550dc98Sfvdl 	int i;
623550dc98Sfvdl 
633550dc98Sfvdl 	for (i = 1; i <= n; i ++)
643550dc98Sfvdl 		printf("\t");
653550dc98Sfvdl }
663550dc98Sfvdl 
673550dc98Sfvdl #if 0
683550dc98Sfvdl void
693550dc98Sfvdl debug_print_rrip_info(n)
703550dc98Sfvdl cd9660node *n;
713550dc98Sfvdl {
723550dc98Sfvdl 	struct ISO_SUSP_ATTRIBUTES *t;
73689c61f6Sdyoung 	TAILQ_FOREACH(t, &node->head, rr_ll) {
743550dc98Sfvdl 
753550dc98Sfvdl 	}
763550dc98Sfvdl }
773550dc98Sfvdl #endif
783550dc98Sfvdl 
793550dc98Sfvdl static void
debug_print_susp_attrs(cd9660node * n,int indent)803550dc98Sfvdl debug_print_susp_attrs(cd9660node *n, int indent)
813550dc98Sfvdl {
823550dc98Sfvdl 	struct ISO_SUSP_ATTRIBUTES *t;
833550dc98Sfvdl 
84689c61f6Sdyoung 	TAILQ_FOREACH(t, &n->head, rr_ll) {
853550dc98Sfvdl 		print_n_tabs(indent);
863550dc98Sfvdl 		printf("-");
873550dc98Sfvdl 		printf("%c%c: L:%i",t->attr.su_entry.SP.h.type[0],
883550dc98Sfvdl 		    t->attr.su_entry.SP.h.type[1],
893550dc98Sfvdl 		    (int)t->attr.su_entry.SP.h.length[0]);
903550dc98Sfvdl 		printf("\n");
913550dc98Sfvdl 	}
923550dc98Sfvdl }
933550dc98Sfvdl 
943550dc98Sfvdl void
debug_print_tree(iso9660_disk * diskStructure,cd9660node * node,int level)95e4989541Schristos debug_print_tree(iso9660_disk *diskStructure, cd9660node *node, int level)
963550dc98Sfvdl {
978e180a72Sdogcow #if !HAVE_NBTOOL_CONFIG_H
98689c61f6Sdyoung 	cd9660node *cn;
993550dc98Sfvdl 
1003550dc98Sfvdl 	print_n_tabs(level);
101689c61f6Sdyoung 	if (node->type & CD9660_TYPE_DOT) {
1023550dc98Sfvdl 		printf(". (%i)\n",
103689c61f6Sdyoung 		    isonum_733(node->isoDirRecord->extent));
104689c61f6Sdyoung 	} else if (node->type & CD9660_TYPE_DOTDOT) {
1053550dc98Sfvdl 		printf("..(%i)\n",
106689c61f6Sdyoung 		    isonum_733(node->isoDirRecord->extent));
107689c61f6Sdyoung 	} else if (node->isoDirRecord->name[0]=='\0') {
1082ec6e0f1Schristos 		printf("(ROOT) (%" PRIu32 " to %" PRId64 ")\n",
109689c61f6Sdyoung 		    node->fileDataSector,
110689c61f6Sdyoung 		    node->fileDataSector +
111689c61f6Sdyoung 			node->fileSectorsUsed - 1);
1123550dc98Sfvdl 	} else {
1132ec6e0f1Schristos 		printf("%s (%s) (%" PRIu32 " to %" PRId64 ")\n",
114689c61f6Sdyoung 		    node->isoDirRecord->name,
115689c61f6Sdyoung 		    (node->isoDirRecord->flags[0]
1163550dc98Sfvdl 			& ISO_FLAG_DIRECTORY) ?  "DIR" : "FILE",
117689c61f6Sdyoung 		    node->fileDataSector,
118689c61f6Sdyoung 		    (node->fileSectorsUsed == 0) ?
119689c61f6Sdyoung 			node->fileDataSector :
120689c61f6Sdyoung 			node->fileDataSector
121689c61f6Sdyoung 			    + node->fileSectorsUsed - 1);
1223550dc98Sfvdl 	}
123e4989541Schristos 	if (diskStructure->rock_ridge_enabled)
124689c61f6Sdyoung 		debug_print_susp_attrs(node, level + 1);
125689c61f6Sdyoung 	TAILQ_FOREACH(cn, &node->cn_children, cn_next_child)
126e4989541Schristos 		debug_print_tree(diskStructure, cn, level + 1);
1278e180a72Sdogcow #else
128a9eb597fSbjh21 	printf("Sorry, debugging is not supported in host-tools mode.\n");
1298e180a72Sdogcow #endif
1303550dc98Sfvdl }
1313550dc98Sfvdl 
1323550dc98Sfvdl void
debug_print_path_tree(cd9660node * n)1333550dc98Sfvdl debug_print_path_tree(cd9660node *n)
1343550dc98Sfvdl {
1353550dc98Sfvdl 	cd9660node *iterator = n;
1363550dc98Sfvdl 
1373550dc98Sfvdl 	/* Only display this message when called with the root node */
1383550dc98Sfvdl 	if (n->parent == NULL)
1393550dc98Sfvdl 		printf("debug_print_path_table: Dumping path table contents\n");
1403550dc98Sfvdl 
1413550dc98Sfvdl 	while (iterator != NULL) {
1423550dc98Sfvdl 		if (iterator->isoDirRecord->name[0] == '\0')
1433550dc98Sfvdl 			printf("0) (ROOT)\n");
1443550dc98Sfvdl 		else
1453550dc98Sfvdl 			printf("%i) %s\n", iterator->level,
1463550dc98Sfvdl 			    iterator->isoDirRecord->name);
1473550dc98Sfvdl 
1483550dc98Sfvdl 		iterator = iterator->ptnext;
1493550dc98Sfvdl 	}
1503550dc98Sfvdl }
1513550dc98Sfvdl 
1523550dc98Sfvdl void
debug_print_volume_descriptor_information(iso9660_disk * diskStructure)153e4989541Schristos debug_print_volume_descriptor_information(iso9660_disk *diskStructure)
1543550dc98Sfvdl {
155e4989541Schristos 	volume_descriptor *tmp = diskStructure->firstVolumeDescriptor;
156203850f0Schristos 	char temp[CD9660_SECTOR_SIZE];
1573550dc98Sfvdl 
1583550dc98Sfvdl 	printf("==Listing Volume Descriptors==\n");
1593550dc98Sfvdl 
1603550dc98Sfvdl 	while (tmp != NULL) {
161203850f0Schristos 		memset(temp, 0, CD9660_SECTOR_SIZE);
1623550dc98Sfvdl 		memcpy(temp, tmp->volumeDescriptorData + 1, 5);
1632ec6e0f1Schristos 		printf("Volume descriptor in sector %" PRId64
1642ec6e0f1Schristos 		    ": type %i, ID %s\n",
1653550dc98Sfvdl 		    tmp->sector, tmp->volumeDescriptorData[0], temp);
1663550dc98Sfvdl 		switch(tmp->volumeDescriptorData[0]) {
1673550dc98Sfvdl 		case 0:/*boot record*/
1683550dc98Sfvdl 			break;
1693550dc98Sfvdl 
1703550dc98Sfvdl 		case 1:		/* PVD */
1713550dc98Sfvdl 			break;
1723550dc98Sfvdl 
1733550dc98Sfvdl 		case 2:		/* SVD */
1743550dc98Sfvdl 			break;
1753550dc98Sfvdl 
1763550dc98Sfvdl 		case 3:		/* Volume Partition Descriptor */
1773550dc98Sfvdl 			break;
1783550dc98Sfvdl 
1793550dc98Sfvdl 		case 255:	/* terminator */
1803550dc98Sfvdl 			break;
1813550dc98Sfvdl 		}
1823550dc98Sfvdl 		tmp = tmp->next;
1833550dc98Sfvdl 	}
1843550dc98Sfvdl 
1853550dc98Sfvdl 	printf("==Done Listing Volume Descriptors==\n");
1863550dc98Sfvdl }
1873550dc98Sfvdl 
1883550dc98Sfvdl void
debug_dump_to_xml_ptentry(path_table_entry * pttemp,int num,int mode)1893550dc98Sfvdl debug_dump_to_xml_ptentry(path_table_entry *pttemp, int num, int mode)
1903550dc98Sfvdl {
1913550dc98Sfvdl 	printf("<ptentry num=\"%i\">\n" ,num);
1923550dc98Sfvdl 	printf("<length>%i</length>\n", pttemp->length[0]);
1933550dc98Sfvdl 	printf("<extended_attribute_length>%i</extended_attribute_length>\n",
1943550dc98Sfvdl 	    pttemp->extended_attribute_length[0]);
1953550dc98Sfvdl 	printf("<parent_number>%i</parent_number>\n",
1963550dc98Sfvdl 	    debug_get_encoded_number(pttemp->parent_number,mode));
1973550dc98Sfvdl 	debug_dump_to_xml_padded_hex_output("name",
1983550dc98Sfvdl 	    pttemp->name, pttemp->length[0]);
1993550dc98Sfvdl 	printf("</ptentry>\n");
2003550dc98Sfvdl }
2013550dc98Sfvdl 
2023550dc98Sfvdl void
debug_dump_to_xml_path_table(FILE * fd,off_t sector,int size,int mode)203203850f0Schristos debug_dump_to_xml_path_table(FILE *fd, off_t sector, int size, int mode)
2043550dc98Sfvdl {
2053550dc98Sfvdl 	path_table_entry pttemp;
2063550dc98Sfvdl 	int t = 0;
2073550dc98Sfvdl 	int n = 0;
2083550dc98Sfvdl 
209203850f0Schristos 	if (fseeko(fd, CD9660_SECTOR_SIZE * sector, SEEK_SET) == -1)
210*ec5d1d82Stsutsui 		err(EXIT_FAILURE, "fseeko");
2113550dc98Sfvdl 
2123550dc98Sfvdl 	while (t < size) {
2133550dc98Sfvdl 		/* Read fixed data first */
2143550dc98Sfvdl 		fread(&pttemp, 1, 8, fd);
2153550dc98Sfvdl 		t += 8;
2163550dc98Sfvdl 		/* Read variable */
2173550dc98Sfvdl 		fread(((unsigned char*)&pttemp) + 8, 1, pttemp.length[0], fd);
2183550dc98Sfvdl 		t += pttemp.length[0];
2193550dc98Sfvdl 		debug_dump_to_xml_ptentry(&pttemp, n, mode);
2203550dc98Sfvdl 		n++;
2213550dc98Sfvdl 	}
2223550dc98Sfvdl 
2233550dc98Sfvdl }
2243550dc98Sfvdl 
2253550dc98Sfvdl /*
2263550dc98Sfvdl  * XML Debug output functions
2273550dc98Sfvdl  * Dump hierarchy of CD, as well as volume info, to XML
2283550dc98Sfvdl  * Can be used later to diff against a standard,
2293550dc98Sfvdl  * or just provide easy to read detailed debug output
2303550dc98Sfvdl  */
2313550dc98Sfvdl void
debug_dump_to_xml(FILE * fd)2323550dc98Sfvdl debug_dump_to_xml(FILE *fd)
2333550dc98Sfvdl {
234203850f0Schristos 	unsigned char buf[CD9660_SECTOR_SIZE];
235203850f0Schristos 	off_t sector;
2363550dc98Sfvdl 	int t, t2;
2373550dc98Sfvdl 	struct iso_primary_descriptor primaryVD;
2383550dc98Sfvdl 	struct _boot_volume_descriptor bootVD;
2393550dc98Sfvdl 
2400a77b69aSchristos 	memset(&primaryVD, 0, sizeof(primaryVD));
2413550dc98Sfvdl 	printf("<cd9660dump>\n");
2423550dc98Sfvdl 
2433550dc98Sfvdl 	/* Display Volume Descriptors */
2443550dc98Sfvdl 	sector = 16;
2453550dc98Sfvdl 	do {
246203850f0Schristos 		if (fseeko(fd, CD9660_SECTOR_SIZE * sector, SEEK_SET) == -1)
247*ec5d1d82Stsutsui 			err(EXIT_FAILURE, "fseeko");
248203850f0Schristos 		fread(buf, 1, CD9660_SECTOR_SIZE, fd);
2493550dc98Sfvdl 		t = (int)((unsigned char)buf[0]);
2503550dc98Sfvdl 		switch (t) {
2513550dc98Sfvdl 		case 0:
252203850f0Schristos 			memcpy(&bootVD, buf, CD9660_SECTOR_SIZE);
2533550dc98Sfvdl 			break;
2543550dc98Sfvdl 		case 1:
255203850f0Schristos 			memcpy(&primaryVD, buf, CD9660_SECTOR_SIZE);
2563550dc98Sfvdl 			break;
2573550dc98Sfvdl 		}
2583550dc98Sfvdl 		debug_dump_to_xml_volume_descriptor(buf, sector);
2593550dc98Sfvdl 		sector++;
2603550dc98Sfvdl 	} while (t != 255);
2613550dc98Sfvdl 
2623550dc98Sfvdl 	t = debug_get_encoded_number((u_char *)primaryVD.type_l_path_table,
2633550dc98Sfvdl 	    731);
2643550dc98Sfvdl 	t2 = debug_get_encoded_number((u_char *)primaryVD.path_table_size, 733);
2653550dc98Sfvdl 	printf("Path table 1 located at sector %i and is %i bytes long\n",
2663550dc98Sfvdl 	    t,t2);
2673550dc98Sfvdl 	debug_dump_to_xml_path_table(fd, t, t2, 721);
2683550dc98Sfvdl 
2693550dc98Sfvdl 	t = debug_get_encoded_number((u_char *)primaryVD.type_m_path_table,
2703550dc98Sfvdl 	    731);
2713550dc98Sfvdl 	debug_dump_to_xml_path_table(fd, t, t2, 722);
2723550dc98Sfvdl 
2733550dc98Sfvdl 	printf("</cd9660dump>\n");
2743550dc98Sfvdl }
2753550dc98Sfvdl 
2763550dc98Sfvdl static void
debug_dump_to_xml_padded_hex_output(const char * element,unsigned char * buf,int len)2773550dc98Sfvdl debug_dump_to_xml_padded_hex_output(const char *element, unsigned char *buf,
2783550dc98Sfvdl 				    int len)
2793550dc98Sfvdl {
2803550dc98Sfvdl 	int i;
2813550dc98Sfvdl 	int t;
2823550dc98Sfvdl 
2833550dc98Sfvdl 	printf("<%s>",element);
2843550dc98Sfvdl 	for (i = 0; i < len; i++) {
2853550dc98Sfvdl 		t = (unsigned char)buf[i];
2863550dc98Sfvdl 		if (t >= 32 && t < 127)
2873550dc98Sfvdl 			printf("%c",t);
2883550dc98Sfvdl 	}
2893550dc98Sfvdl 	printf("</%s>\n",element);
2903550dc98Sfvdl 
2913550dc98Sfvdl 	printf("<%s:hex>",element);
2923550dc98Sfvdl 	for (i = 0; i < len; i++) {
2933550dc98Sfvdl 		t = (unsigned char)buf[i];
2943550dc98Sfvdl 		printf(" %x",t);
2953550dc98Sfvdl 	}
2963550dc98Sfvdl 	printf("</%s:hex>\n",element);
2973550dc98Sfvdl }
2983550dc98Sfvdl 
2993550dc98Sfvdl int
debug_get_encoded_number(unsigned char * buf,int mode)3003550dc98Sfvdl debug_get_encoded_number(unsigned char* buf, int mode)
3013550dc98Sfvdl {
3028e180a72Sdogcow #if !HAVE_NBTOOL_CONFIG_H
3033550dc98Sfvdl 	switch (mode) {
3043550dc98Sfvdl 	/* 711: Single bite */
3053550dc98Sfvdl 	case 711:
3063550dc98Sfvdl 		return isonum_711(buf);
3073550dc98Sfvdl 
3083550dc98Sfvdl 	/* 712: Single signed byte */
3093550dc98Sfvdl 	case 712:
3103550dc98Sfvdl 		return isonum_712((signed char *)buf);
3113550dc98Sfvdl 
3123550dc98Sfvdl 	/* 721: 16 bit LE */
3133550dc98Sfvdl 	case 721:
3143550dc98Sfvdl 		return isonum_721(buf);
3153550dc98Sfvdl 
3163550dc98Sfvdl 	/* 731: 32 bit LE */
3173550dc98Sfvdl 	case 731:
3183550dc98Sfvdl 		return isonum_731(buf);
3193550dc98Sfvdl 
3203550dc98Sfvdl 	/* 722: 16 bit BE */
3213550dc98Sfvdl 	case 722:
3223550dc98Sfvdl 		return isonum_722(buf);
3233550dc98Sfvdl 
3243550dc98Sfvdl 	/* 732: 32 bit BE */
3253550dc98Sfvdl 	case 732:
3263550dc98Sfvdl 		return isonum_732(buf);
3273550dc98Sfvdl 
3283550dc98Sfvdl 	/* 723: 16 bit bothE */
3293550dc98Sfvdl 	case 723:
3303550dc98Sfvdl 		return isonum_723(buf);
3313550dc98Sfvdl 
3323550dc98Sfvdl 	/* 733: 32 bit bothE */
3333550dc98Sfvdl 	case 733:
3343550dc98Sfvdl 		return isonum_733(buf);
3353550dc98Sfvdl 	}
3368e180a72Sdogcow #endif
3373550dc98Sfvdl 	return 0;
3383550dc98Sfvdl }
3393550dc98Sfvdl 
3403550dc98Sfvdl void
debug_dump_integer(const char * element,char * buf,int mode)3413550dc98Sfvdl debug_dump_integer(const char *element, char* buf, int mode)
3423550dc98Sfvdl {
3433550dc98Sfvdl 	printf("<%s>%i</%s>\n", element,
3443550dc98Sfvdl 	    debug_get_encoded_number((unsigned char *)buf, mode), element);
3453550dc98Sfvdl }
3463550dc98Sfvdl 
3473550dc98Sfvdl void
debug_dump_string(const char * element __unused,unsigned char * buf __unused,int len __unused)3489450025aSchristos debug_dump_string(const char *element __unused, unsigned char *buf __unused, int len __unused)
3493550dc98Sfvdl {
3503550dc98Sfvdl 
3513550dc98Sfvdl }
3523550dc98Sfvdl 
3533550dc98Sfvdl void
debug_dump_directory_record_9_1(unsigned char * buf)3543550dc98Sfvdl debug_dump_directory_record_9_1(unsigned char* buf)
3553550dc98Sfvdl {
3563550dc98Sfvdl 	printf("<directoryrecord>\n");
3573550dc98Sfvdl 	debug_dump_integer("length",
3583550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->length, 711);
3593550dc98Sfvdl 	debug_dump_integer("ext_attr_length",
3603550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->ext_attr_length,711);
3613550dc98Sfvdl 	debug_dump_integer("extent",
3623550dc98Sfvdl 	    (char *)((struct iso_directory_record*) buf)->extent, 733);
3633550dc98Sfvdl 	debug_dump_integer("size",
3643550dc98Sfvdl 	    (char *)((struct iso_directory_record*) buf)->size, 733);
3653550dc98Sfvdl 	debug_dump_integer("flags",
3663550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->flags, 711);
3673550dc98Sfvdl 	debug_dump_integer("file_unit_size",
3683550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->file_unit_size,711);
3693550dc98Sfvdl 	debug_dump_integer("interleave",
3703550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->interleave, 711);
3713550dc98Sfvdl 	debug_dump_integer("volume_sequence_number",
3723550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->volume_sequence_number,
3733550dc98Sfvdl 	    723);
3743550dc98Sfvdl 	debug_dump_integer("name_len",
3753550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->name_len, 711);
3763550dc98Sfvdl 	debug_dump_to_xml_padded_hex_output("name",
3773550dc98Sfvdl 	    (u_char *)((struct iso_directory_record*) buf)->name,
3783550dc98Sfvdl 		debug_get_encoded_number((u_char *)
3793550dc98Sfvdl 		    ((struct iso_directory_record*) buf)->length, 711));
3803550dc98Sfvdl 	printf("</directoryrecord>\n");
3813550dc98Sfvdl }
3823550dc98Sfvdl 
3833550dc98Sfvdl 
3843550dc98Sfvdl void
debug_dump_to_xml_volume_descriptor(unsigned char * buf,int sector)3853550dc98Sfvdl debug_dump_to_xml_volume_descriptor(unsigned char* buf, int sector)
3863550dc98Sfvdl {
3873550dc98Sfvdl 	printf("<volumedescriptor sector=\"%i\">\n", sector);
3883550dc98Sfvdl 	printf("<vdtype>");
3893550dc98Sfvdl 	switch(buf[0]) {
3903550dc98Sfvdl 	case 0:
3913550dc98Sfvdl 		printf("boot");
3923550dc98Sfvdl 		break;
3933550dc98Sfvdl 
3943550dc98Sfvdl 	case 1:
3953550dc98Sfvdl 		printf("primary");
3963550dc98Sfvdl 		break;
3973550dc98Sfvdl 
3983550dc98Sfvdl 	case 2:
3993550dc98Sfvdl 		printf("supplementary");
4003550dc98Sfvdl 		break;
4013550dc98Sfvdl 
4023550dc98Sfvdl 	case 3:
4033550dc98Sfvdl 		printf("volume partition descriptor");
4043550dc98Sfvdl 		break;
4053550dc98Sfvdl 
4063550dc98Sfvdl 	case 255:
4073550dc98Sfvdl 		printf("terminator");
4083550dc98Sfvdl 		break;
4093550dc98Sfvdl 	}
4103550dc98Sfvdl 
4113550dc98Sfvdl 	printf("</vdtype>\n");
4123550dc98Sfvdl 	switch(buf[0]) {
4133550dc98Sfvdl 	case 1:
4143550dc98Sfvdl 		debug_dump_integer("type",
4153550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->type, 711);
4163550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("id",
4173550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->id,
4183550dc98Sfvdl 		    ISODCL (  2,   6));
4193550dc98Sfvdl 		debug_dump_integer("version",
4203550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->version,
4213550dc98Sfvdl 		     711);
4223550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("system_id",
4233550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*)buf)->system_id,
4243550dc98Sfvdl 		    ISODCL(9,40));
4253550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("volume_id",
4263550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*)buf)->volume_id,
4273550dc98Sfvdl 		    ISODCL(41,72));
4283550dc98Sfvdl 		debug_dump_integer("volume_space_size",
4293550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->volume_space_size,
4303550dc98Sfvdl 		    733);
4313550dc98Sfvdl 		debug_dump_integer("volume_set_size",
4323550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->volume_set_size,
4333550dc98Sfvdl 			    733);
4343550dc98Sfvdl 		debug_dump_integer("volume_sequence_number",
4353550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->volume_sequence_number,
4363550dc98Sfvdl 		    723);
4373550dc98Sfvdl 		debug_dump_integer("logical_block_size",
4383550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->logical_block_size,
4393550dc98Sfvdl 			    723);
4403550dc98Sfvdl 		debug_dump_integer("path_table_size",
4413550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->path_table_size,
4423550dc98Sfvdl 			    733);
4433550dc98Sfvdl 		debug_dump_integer("type_l_path_table",
4443550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->type_l_path_table,
4453550dc98Sfvdl 		    731);
4463550dc98Sfvdl 		debug_dump_integer("opt_type_l_path_table",
4473550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->opt_type_l_path_table,
4483550dc98Sfvdl 		    731);
4493550dc98Sfvdl 		debug_dump_integer("type_m_path_table",
4503550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->type_m_path_table,
4513550dc98Sfvdl 		    732);
4523550dc98Sfvdl 		debug_dump_integer("opt_type_m_path_table",
4533550dc98Sfvdl 			((struct iso_primary_descriptor*)buf)->opt_type_m_path_table,732);
4543550dc98Sfvdl 		debug_dump_directory_record_9_1(
4553550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*)buf)->root_directory_record);
4563550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("volume_set_id",
4573550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->volume_set_id,
4583550dc98Sfvdl 		    ISODCL (191, 318));
4593550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("publisher_id",
4603550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->publisher_id,
4613550dc98Sfvdl 		    ISODCL (319, 446));
4623550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("preparer_id",
4633550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->preparer_id,
4643550dc98Sfvdl 		    ISODCL (447, 574));
4653550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("application_id",
4663550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->application_id,
4673550dc98Sfvdl 		    ISODCL (575, 702));
4683550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("copyright_file_id",
4693550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->copyright_file_id,
4703550dc98Sfvdl 		    ISODCL (703, 739));
4713550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("abstract_file_id",
4723550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->abstract_file_id,
4733550dc98Sfvdl 		    ISODCL (740, 776));
4743550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("bibliographic_file_id",
4753550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->bibliographic_file_id,
4763550dc98Sfvdl 		    ISODCL (777, 813));
4773550dc98Sfvdl 
4783550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("creation_date",
4793550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->creation_date,
4803550dc98Sfvdl 		    ISODCL (814, 830));
4813550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("modification_date",
4823550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->modification_date,
4833550dc98Sfvdl 		    ISODCL (831, 847));
4843550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("expiration_date",
4853550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->expiration_date,
4863550dc98Sfvdl 		    ISODCL (848, 864));
4873550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("effective_date",
4883550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->effective_date,
4893550dc98Sfvdl 		    ISODCL (865, 881));
4903550dc98Sfvdl 
4913550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("file_structure_version",
4923550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->file_structure_version,
4933550dc98Sfvdl 		    ISODCL(882,882));
4943550dc98Sfvdl 		break;
4953550dc98Sfvdl 	}
4963550dc98Sfvdl 	printf("</volumedescriptor>\n");
4973550dc98Sfvdl }
4983550dc98Sfvdl 
499