xref: /netbsd-src/usr.sbin/makefs/cd9660/cd9660_debug.c (revision 689c61f61d9c84911bf45818f4d30f8a88f2138e)
1*689c61f6Sdyoung /*	$NetBSD: cd9660_debug.c,v 1.2 2005/10/25 02:22:04 dyoung 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*689c61f6Sdyoung __RCSID("$NetBSD: cd9660_debug.c,v 1.2 2005/10/25 02:22:04 dyoung 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 
583550dc98Sfvdl static __inline void
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;
73*689c61f6Sdyoung 	TAILQ_FOREACH(t, &node->head, rr_ll) {
743550dc98Sfvdl 
753550dc98Sfvdl 	}
763550dc98Sfvdl }
773550dc98Sfvdl #endif
783550dc98Sfvdl 
793550dc98Sfvdl static void
803550dc98Sfvdl debug_print_susp_attrs(cd9660node *n, int indent)
813550dc98Sfvdl {
823550dc98Sfvdl 	struct ISO_SUSP_ATTRIBUTES *t;
833550dc98Sfvdl 
84*689c61f6Sdyoung 	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
95*689c61f6Sdyoung debug_print_tree(cd9660node *node, int level)
963550dc98Sfvdl {
97*689c61f6Sdyoung 	cd9660node *cn;
983550dc98Sfvdl 
993550dc98Sfvdl 	print_n_tabs(level);
100*689c61f6Sdyoung 	if (node->type & CD9660_TYPE_DOT) {
1013550dc98Sfvdl 		printf(". (%i)\n",
102*689c61f6Sdyoung 		    isonum_733(node->isoDirRecord->extent));
103*689c61f6Sdyoung 	} else if (node->type & CD9660_TYPE_DOTDOT) {
1043550dc98Sfvdl 		printf("..(%i)\n",
105*689c61f6Sdyoung 		    isonum_733(node->isoDirRecord->extent));
106*689c61f6Sdyoung 	} else if (node->isoDirRecord->name[0]=='\0') {
1073550dc98Sfvdl 		printf("(ROOT) (%i to %i)\n",
108*689c61f6Sdyoung 		    node->fileDataSector,
109*689c61f6Sdyoung 		    node->fileDataSector +
110*689c61f6Sdyoung 			node->fileSectorsUsed - 1);
1113550dc98Sfvdl 	} else {
1123550dc98Sfvdl 		printf("%s (%s) (%i to %i)\n",
113*689c61f6Sdyoung 		    node->isoDirRecord->name,
114*689c61f6Sdyoung 		    (node->isoDirRecord->flags[0]
1153550dc98Sfvdl 			& ISO_FLAG_DIRECTORY) ?  "DIR" : "FILE",
116*689c61f6Sdyoung 		    node->fileDataSector,
117*689c61f6Sdyoung 		    (node->fileSectorsUsed == 0) ?
118*689c61f6Sdyoung 			node->fileDataSector :
119*689c61f6Sdyoung 			node->fileDataSector
120*689c61f6Sdyoung 			    + node->fileSectorsUsed - 1);
1213550dc98Sfvdl 	}
122*689c61f6Sdyoung 	if (diskStructure.rock_ridge_enabled)
123*689c61f6Sdyoung 		debug_print_susp_attrs(node, level + 1);
124*689c61f6Sdyoung 	TAILQ_FOREACH(cn, &node->cn_children, cn_next_child)
125*689c61f6Sdyoung 		debug_print_tree(cn, level + 1);
1263550dc98Sfvdl }
1273550dc98Sfvdl 
1283550dc98Sfvdl void
1293550dc98Sfvdl debug_print_path_tree(cd9660node *n)
1303550dc98Sfvdl {
1313550dc98Sfvdl 	cd9660node *iterator = n;
1323550dc98Sfvdl 
1333550dc98Sfvdl 	/* Only display this message when called with the root node */
1343550dc98Sfvdl 	if (n->parent == NULL)
1353550dc98Sfvdl 		printf("debug_print_path_table: Dumping path table contents\n");
1363550dc98Sfvdl 
1373550dc98Sfvdl 	while (iterator != NULL) {
1383550dc98Sfvdl 		if (iterator->isoDirRecord->name[0] == '\0')
1393550dc98Sfvdl 			printf("0) (ROOT)\n");
1403550dc98Sfvdl 		else
1413550dc98Sfvdl 			printf("%i) %s\n", iterator->level,
1423550dc98Sfvdl 			    iterator->isoDirRecord->name);
1433550dc98Sfvdl 
1443550dc98Sfvdl 		iterator = iterator->ptnext;
1453550dc98Sfvdl 	}
1463550dc98Sfvdl }
1473550dc98Sfvdl 
1483550dc98Sfvdl void
1493550dc98Sfvdl debug_print_volume_descriptor_information(void)
1503550dc98Sfvdl {
1513550dc98Sfvdl 	volume_descriptor *tmp = diskStructure.firstVolumeDescriptor;
1523550dc98Sfvdl 	char temp[2048];
1533550dc98Sfvdl 
1543550dc98Sfvdl 	printf("==Listing Volume Descriptors==\n");
1553550dc98Sfvdl 
1563550dc98Sfvdl 	while (tmp != NULL) {
1573550dc98Sfvdl 		memset(temp, 0, 2048);
1583550dc98Sfvdl 		memcpy(temp, tmp->volumeDescriptorData + 1, 5);
1593550dc98Sfvdl 		printf("Volume descriptor in sector %i: type %i, ID %s\n",
1603550dc98Sfvdl 		    tmp->sector, tmp->volumeDescriptorData[0], temp);
1613550dc98Sfvdl 		switch(tmp->volumeDescriptorData[0]) {
1623550dc98Sfvdl 		case 0:/*boot record*/
1633550dc98Sfvdl 			break;
1643550dc98Sfvdl 
1653550dc98Sfvdl 		case 1:		/* PVD */
1663550dc98Sfvdl 			break;
1673550dc98Sfvdl 
1683550dc98Sfvdl 		case 2:		/* SVD */
1693550dc98Sfvdl 			break;
1703550dc98Sfvdl 
1713550dc98Sfvdl 		case 3:		/* Volume Partition Descriptor */
1723550dc98Sfvdl 			break;
1733550dc98Sfvdl 
1743550dc98Sfvdl 		case 255:	/* terminator */
1753550dc98Sfvdl 			break;
1763550dc98Sfvdl 		}
1773550dc98Sfvdl 		tmp = tmp->next;
1783550dc98Sfvdl 	}
1793550dc98Sfvdl 
1803550dc98Sfvdl 	printf("==Done Listing Volume Descriptors==\n");
1813550dc98Sfvdl }
1823550dc98Sfvdl 
1833550dc98Sfvdl void
1843550dc98Sfvdl debug_dump_to_xml_ptentry(path_table_entry *pttemp, int num, int mode)
1853550dc98Sfvdl {
1863550dc98Sfvdl 	printf("<ptentry num=\"%i\">\n" ,num);
1873550dc98Sfvdl 	printf("<length>%i</length>\n", pttemp->length[0]);
1883550dc98Sfvdl 	printf("<extended_attribute_length>%i</extended_attribute_length>\n",
1893550dc98Sfvdl 	    pttemp->extended_attribute_length[0]);
1903550dc98Sfvdl 	printf("<parent_number>%i</parent_number>\n",
1913550dc98Sfvdl 	    debug_get_encoded_number(pttemp->parent_number,mode));
1923550dc98Sfvdl 	debug_dump_to_xml_padded_hex_output("name",
1933550dc98Sfvdl 	    pttemp->name, pttemp->length[0]);
1943550dc98Sfvdl 	printf("</ptentry>\n");
1953550dc98Sfvdl }
1963550dc98Sfvdl 
1973550dc98Sfvdl void
1983550dc98Sfvdl debug_dump_to_xml_path_table(FILE *fd, int sector, int size, int mode)
1993550dc98Sfvdl {
2003550dc98Sfvdl 	path_table_entry pttemp;
2013550dc98Sfvdl 	int t = 0;
2023550dc98Sfvdl 	int n = 0;
2033550dc98Sfvdl 
2043550dc98Sfvdl 	fseek(fd, 2048 * sector, SEEK_SET);
2053550dc98Sfvdl 
2063550dc98Sfvdl 	while (t < size) {
2073550dc98Sfvdl 		/* Read fixed data first */
2083550dc98Sfvdl 		fread(&pttemp, 1, 8, fd);
2093550dc98Sfvdl 		t += 8;
2103550dc98Sfvdl 		/* Read variable */
2113550dc98Sfvdl 		fread(((unsigned char*)&pttemp) + 8, 1, pttemp.length[0], fd);
2123550dc98Sfvdl 		t += pttemp.length[0];
2133550dc98Sfvdl 		debug_dump_to_xml_ptentry(&pttemp, n, mode);
2143550dc98Sfvdl 		n++;
2153550dc98Sfvdl 	}
2163550dc98Sfvdl 
2173550dc98Sfvdl }
2183550dc98Sfvdl 
2193550dc98Sfvdl /*
2203550dc98Sfvdl  * XML Debug output functions
2213550dc98Sfvdl  * Dump hierarchy of CD, as well as volume info, to XML
2223550dc98Sfvdl  * Can be used later to diff against a standard,
2233550dc98Sfvdl  * or just provide easy to read detailed debug output
2243550dc98Sfvdl  */
2253550dc98Sfvdl void
2263550dc98Sfvdl debug_dump_to_xml(FILE *fd)
2273550dc98Sfvdl {
2283550dc98Sfvdl 	unsigned char buf[2048];
2293550dc98Sfvdl 	int sector;
2303550dc98Sfvdl 	int t, t2;
2313550dc98Sfvdl 	struct iso_primary_descriptor primaryVD;
2323550dc98Sfvdl 	struct _boot_volume_descriptor bootVD;
2333550dc98Sfvdl 
2343550dc98Sfvdl 	printf("<cd9660dump>\n");
2353550dc98Sfvdl 
2363550dc98Sfvdl 	/* Display Volume Descriptors */
2373550dc98Sfvdl 	sector = 16;
2383550dc98Sfvdl 	do {
2393550dc98Sfvdl 		fseek(fd, 2048*sector, SEEK_SET);
2403550dc98Sfvdl 		fread(buf, 1, 2048, fd);
2413550dc98Sfvdl 		t = (int)((unsigned char)buf[0]);
2423550dc98Sfvdl 		switch (t) {
2433550dc98Sfvdl 		case 0:
2443550dc98Sfvdl 			memcpy(&bootVD, buf, 2048);
2453550dc98Sfvdl 			break;
2463550dc98Sfvdl 		case 1:
2473550dc98Sfvdl 			memcpy(&primaryVD, buf, 2048);
2483550dc98Sfvdl 			break;
2493550dc98Sfvdl 		}
2503550dc98Sfvdl 		debug_dump_to_xml_volume_descriptor(buf, sector);
2513550dc98Sfvdl 		sector++;
2523550dc98Sfvdl 	} while (t != 255);
2533550dc98Sfvdl 
2543550dc98Sfvdl 	t = debug_get_encoded_number((u_char *)primaryVD.type_l_path_table,
2553550dc98Sfvdl 	    731);
2563550dc98Sfvdl 	t2 = debug_get_encoded_number((u_char *)primaryVD.path_table_size, 733);
2573550dc98Sfvdl 	printf("Path table 1 located at sector %i and is %i bytes long\n",
2583550dc98Sfvdl 	    t,t2);
2593550dc98Sfvdl 	debug_dump_to_xml_path_table(fd, t, t2, 721);
2603550dc98Sfvdl 
2613550dc98Sfvdl 	t = debug_get_encoded_number((u_char *)primaryVD.type_m_path_table,
2623550dc98Sfvdl 	    731);
2633550dc98Sfvdl 	debug_dump_to_xml_path_table(fd, t, t2, 722);
2643550dc98Sfvdl 
2653550dc98Sfvdl 	printf("</cd9660dump>\n");
2663550dc98Sfvdl }
2673550dc98Sfvdl 
2683550dc98Sfvdl static void
2693550dc98Sfvdl debug_dump_to_xml_padded_hex_output(const char *element, unsigned char *buf,
2703550dc98Sfvdl 				    int len)
2713550dc98Sfvdl {
2723550dc98Sfvdl 	int i;
2733550dc98Sfvdl 	int t;
2743550dc98Sfvdl 
2753550dc98Sfvdl 	printf("<%s>",element);
2763550dc98Sfvdl 	for (i = 0; i < len; i++) {
2773550dc98Sfvdl 		t = (unsigned char)buf[i];
2783550dc98Sfvdl 		if (t >= 32 && t < 127)
2793550dc98Sfvdl 			printf("%c",t);
2803550dc98Sfvdl 	}
2813550dc98Sfvdl 	printf("</%s>\n",element);
2823550dc98Sfvdl 
2833550dc98Sfvdl 	printf("<%s:hex>",element);
2843550dc98Sfvdl 	for (i = 0; i < len; i++) {
2853550dc98Sfvdl 		t = (unsigned char)buf[i];
2863550dc98Sfvdl 		printf(" %x",t);
2873550dc98Sfvdl 	}
2883550dc98Sfvdl 	printf("</%s:hex>\n",element);
2893550dc98Sfvdl }
2903550dc98Sfvdl 
2913550dc98Sfvdl int
2923550dc98Sfvdl debug_get_encoded_number(unsigned char* buf, int mode)
2933550dc98Sfvdl {
2943550dc98Sfvdl 	switch (mode) {
2953550dc98Sfvdl 	/* 711: Single bite */
2963550dc98Sfvdl 	case 711:
2973550dc98Sfvdl 		return isonum_711(buf);
2983550dc98Sfvdl 
2993550dc98Sfvdl 	/* 712: Single signed byte */
3003550dc98Sfvdl 	case 712:
3013550dc98Sfvdl 		return isonum_712((signed char *)buf);
3023550dc98Sfvdl 
3033550dc98Sfvdl 	/* 721: 16 bit LE */
3043550dc98Sfvdl 	case 721:
3053550dc98Sfvdl 		return isonum_721(buf);
3063550dc98Sfvdl 
3073550dc98Sfvdl 	/* 731: 32 bit LE */
3083550dc98Sfvdl 	case 731:
3093550dc98Sfvdl 		return isonum_731(buf);
3103550dc98Sfvdl 
3113550dc98Sfvdl 	/* 722: 16 bit BE */
3123550dc98Sfvdl 	case 722:
3133550dc98Sfvdl 		return isonum_722(buf);
3143550dc98Sfvdl 
3153550dc98Sfvdl 	/* 732: 32 bit BE */
3163550dc98Sfvdl 	case 732:
3173550dc98Sfvdl 		return isonum_732(buf);
3183550dc98Sfvdl 
3193550dc98Sfvdl 	/* 723: 16 bit bothE */
3203550dc98Sfvdl 	case 723:
3213550dc98Sfvdl 		return isonum_723(buf);
3223550dc98Sfvdl 
3233550dc98Sfvdl 	/* 733: 32 bit bothE */
3243550dc98Sfvdl 	case 733:
3253550dc98Sfvdl 		return isonum_733(buf);
3263550dc98Sfvdl 	}
3273550dc98Sfvdl 	return 0;
3283550dc98Sfvdl }
3293550dc98Sfvdl 
3303550dc98Sfvdl void
3313550dc98Sfvdl debug_dump_integer(const char *element, char* buf, int mode)
3323550dc98Sfvdl {
3333550dc98Sfvdl 	printf("<%s>%i</%s>\n", element,
3343550dc98Sfvdl 	    debug_get_encoded_number((unsigned char *)buf, mode), element);
3353550dc98Sfvdl }
3363550dc98Sfvdl 
3373550dc98Sfvdl void
3383550dc98Sfvdl debug_dump_string(const char *element, unsigned char *buf, int len)
3393550dc98Sfvdl {
3403550dc98Sfvdl 
3413550dc98Sfvdl }
3423550dc98Sfvdl 
3433550dc98Sfvdl void
3443550dc98Sfvdl debug_dump_directory_record_9_1(unsigned char* buf)
3453550dc98Sfvdl {
3463550dc98Sfvdl 	printf("<directoryrecord>\n");
3473550dc98Sfvdl 	debug_dump_integer("length",
3483550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->length, 711);
3493550dc98Sfvdl 	debug_dump_integer("ext_attr_length",
3503550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->ext_attr_length,711);
3513550dc98Sfvdl 	debug_dump_integer("extent",
3523550dc98Sfvdl 	    (char *)((struct iso_directory_record*) buf)->extent, 733);
3533550dc98Sfvdl 	debug_dump_integer("size",
3543550dc98Sfvdl 	    (char *)((struct iso_directory_record*) buf)->size, 733);
3553550dc98Sfvdl 	debug_dump_integer("flags",
3563550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->flags, 711);
3573550dc98Sfvdl 	debug_dump_integer("file_unit_size",
3583550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->file_unit_size,711);
3593550dc98Sfvdl 	debug_dump_integer("interleave",
3603550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->interleave, 711);
3613550dc98Sfvdl 	debug_dump_integer("volume_sequence_number",
3623550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->volume_sequence_number,
3633550dc98Sfvdl 	    723);
3643550dc98Sfvdl 	debug_dump_integer("name_len",
3653550dc98Sfvdl 	    ((struct iso_directory_record*) buf)->name_len, 711);
3663550dc98Sfvdl 	debug_dump_to_xml_padded_hex_output("name",
3673550dc98Sfvdl 	    (u_char *)((struct iso_directory_record*) buf)->name,
3683550dc98Sfvdl 		debug_get_encoded_number((u_char *)
3693550dc98Sfvdl 		    ((struct iso_directory_record*) buf)->length, 711));
3703550dc98Sfvdl 	printf("</directoryrecord>\n");
3713550dc98Sfvdl }
3723550dc98Sfvdl 
3733550dc98Sfvdl 
3743550dc98Sfvdl void
3753550dc98Sfvdl debug_dump_to_xml_volume_descriptor(unsigned char* buf, int sector)
3763550dc98Sfvdl {
3773550dc98Sfvdl 	printf("<volumedescriptor sector=\"%i\">\n", sector);
3783550dc98Sfvdl 	printf("<vdtype>");
3793550dc98Sfvdl 	switch(buf[0]) {
3803550dc98Sfvdl 	case 0:
3813550dc98Sfvdl 		printf("boot");
3823550dc98Sfvdl 		break;
3833550dc98Sfvdl 
3843550dc98Sfvdl 	case 1:
3853550dc98Sfvdl 		printf("primary");
3863550dc98Sfvdl 		break;
3873550dc98Sfvdl 
3883550dc98Sfvdl 	case 2:
3893550dc98Sfvdl 		printf("supplementary");
3903550dc98Sfvdl 		break;
3913550dc98Sfvdl 
3923550dc98Sfvdl 	case 3:
3933550dc98Sfvdl 		printf("volume partition descriptor");
3943550dc98Sfvdl 		break;
3953550dc98Sfvdl 
3963550dc98Sfvdl 	case 255:
3973550dc98Sfvdl 		printf("terminator");
3983550dc98Sfvdl 		break;
3993550dc98Sfvdl 	}
4003550dc98Sfvdl 
4013550dc98Sfvdl 	printf("</vdtype>\n");
4023550dc98Sfvdl 	switch(buf[0]) {
4033550dc98Sfvdl 	case 1:
4043550dc98Sfvdl 		debug_dump_integer("type",
4053550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->type, 711);
4063550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("id",
4073550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->id,
4083550dc98Sfvdl 		    ISODCL (  2,   6));
4093550dc98Sfvdl 		debug_dump_integer("version",
4103550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->version,
4113550dc98Sfvdl 		     711);
4123550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("system_id",
4133550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*)buf)->system_id,
4143550dc98Sfvdl 		    ISODCL(9,40));
4153550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("volume_id",
4163550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*)buf)->volume_id,
4173550dc98Sfvdl 		    ISODCL(41,72));
4183550dc98Sfvdl 		debug_dump_integer("volume_space_size",
4193550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->volume_space_size,
4203550dc98Sfvdl 		    733);
4213550dc98Sfvdl 		debug_dump_integer("volume_set_size",
4223550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->volume_set_size,
4233550dc98Sfvdl 			    733);
4243550dc98Sfvdl 		debug_dump_integer("volume_sequence_number",
4253550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->volume_sequence_number,
4263550dc98Sfvdl 		    723);
4273550dc98Sfvdl 		debug_dump_integer("logical_block_size",
4283550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->logical_block_size,
4293550dc98Sfvdl 			    723);
4303550dc98Sfvdl 		debug_dump_integer("path_table_size",
4313550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->path_table_size,
4323550dc98Sfvdl 			    733);
4333550dc98Sfvdl 		debug_dump_integer("type_l_path_table",
4343550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->type_l_path_table,
4353550dc98Sfvdl 		    731);
4363550dc98Sfvdl 		debug_dump_integer("opt_type_l_path_table",
4373550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->opt_type_l_path_table,
4383550dc98Sfvdl 		    731);
4393550dc98Sfvdl 		debug_dump_integer("type_m_path_table",
4403550dc98Sfvdl 		    ((struct iso_primary_descriptor*)buf)->type_m_path_table,
4413550dc98Sfvdl 		    732);
4423550dc98Sfvdl 		debug_dump_integer("opt_type_m_path_table",
4433550dc98Sfvdl 			((struct iso_primary_descriptor*)buf)->opt_type_m_path_table,732);
4443550dc98Sfvdl 		debug_dump_directory_record_9_1(
4453550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*)buf)->root_directory_record);
4463550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("volume_set_id",
4473550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->volume_set_id,
4483550dc98Sfvdl 		    ISODCL (191, 318));
4493550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("publisher_id",
4503550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->publisher_id,
4513550dc98Sfvdl 		    ISODCL (319, 446));
4523550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("preparer_id",
4533550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->preparer_id,
4543550dc98Sfvdl 		    ISODCL (447, 574));
4553550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("application_id",
4563550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->application_id,
4573550dc98Sfvdl 		    ISODCL (575, 702));
4583550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("copyright_file_id",
4593550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->copyright_file_id,
4603550dc98Sfvdl 		    ISODCL (703, 739));
4613550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("abstract_file_id",
4623550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->abstract_file_id,
4633550dc98Sfvdl 		    ISODCL (740, 776));
4643550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("bibliographic_file_id",
4653550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->bibliographic_file_id,
4663550dc98Sfvdl 		    ISODCL (777, 813));
4673550dc98Sfvdl 
4683550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("creation_date",
4693550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->creation_date,
4703550dc98Sfvdl 		    ISODCL (814, 830));
4713550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("modification_date",
4723550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->modification_date,
4733550dc98Sfvdl 		    ISODCL (831, 847));
4743550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("expiration_date",
4753550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->expiration_date,
4763550dc98Sfvdl 		    ISODCL (848, 864));
4773550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("effective_date",
4783550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->effective_date,
4793550dc98Sfvdl 		    ISODCL (865, 881));
4803550dc98Sfvdl 
4813550dc98Sfvdl 		debug_dump_to_xml_padded_hex_output("file_structure_version",
4823550dc98Sfvdl 		    (u_char *)((struct iso_primary_descriptor*) buf)->file_structure_version,
4833550dc98Sfvdl 		    ISODCL(882,882));
4843550dc98Sfvdl 		break;
4853550dc98Sfvdl 	}
4863550dc98Sfvdl 	printf("</volumedescriptor>\n");
4873550dc98Sfvdl }
4883550dc98Sfvdl 
489