xref: /openbsd-src/usr.sbin/makefs/cd9660/cd9660_debug.c (revision 9a86cdb6ba5369e6dd43374dabd04379f4952a21)
1*9a86cdb6Snatano /*	$OpenBSD: cd9660_debug.c,v 1.3 2016/10/16 20:26:56 natano Exp $	*/
26163fc9cSnatano /*	$NetBSD: cd9660_debug.c,v 1.13 2013/10/19 17:16:37 christos Exp $	*/
36163fc9cSnatano 
46163fc9cSnatano /*
56163fc9cSnatano  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
66163fc9cSnatano  * Perez-Rathke and Ram Vedam.  All rights reserved.
76163fc9cSnatano  *
86163fc9cSnatano  * This code was written by Daniel Watt, Walter Deignan, Ryan Gabrys,
96163fc9cSnatano  * Alan Perez-Rathke and Ram Vedam.
106163fc9cSnatano  *
116163fc9cSnatano  * Redistribution and use in source and binary forms, with or
126163fc9cSnatano  * without modification, are permitted provided that the following
136163fc9cSnatano  * conditions are met:
146163fc9cSnatano  * 1. Redistributions of source code must retain the above copyright
156163fc9cSnatano  *    notice, this list of conditions and the following disclaimer.
166163fc9cSnatano  * 2. Redistributions in binary form must reproduce the above
176163fc9cSnatano  *    copyright notice, this list of conditions and the following
186163fc9cSnatano  *    disclaimer in the documentation and/or other materials provided
196163fc9cSnatano  *    with the distribution.
206163fc9cSnatano  *
216163fc9cSnatano  * THIS SOFTWARE IS PROVIDED BY DANIEL WATT, WALTER DEIGNAN, RYAN
226163fc9cSnatano  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM ``AS IS'' AND ANY EXPRESS OR
236163fc9cSnatano  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
246163fc9cSnatano  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
256163fc9cSnatano  * DISCLAIMED.  IN NO EVENT SHALL DANIEL WATT, WALTER DEIGNAN, RYAN
266163fc9cSnatano  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM BE LIABLE FOR ANY DIRECT, INDIRECT,
276163fc9cSnatano  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
286163fc9cSnatano  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
296163fc9cSnatano  * USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
306163fc9cSnatano  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
316163fc9cSnatano  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
326163fc9cSnatano  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
336163fc9cSnatano  * OF SUCH DAMAGE.
346163fc9cSnatano  */
356163fc9cSnatano 
366163fc9cSnatano #include <inttypes.h>
376163fc9cSnatano 
386163fc9cSnatano #include "cd9660.h"
396163fc9cSnatano #include "iso9660_rrip.h"
406163fc9cSnatano 
416163fc9cSnatano static void debug_print_susp_attrs(cd9660node *, int);
426163fc9cSnatano static void debug_dump_to_xml_padded_hex_output(const char *, unsigned char *,
436163fc9cSnatano 						int);
446163fc9cSnatano 
456163fc9cSnatano static inline void
print_n_tabs(int n)466163fc9cSnatano print_n_tabs(int n)
476163fc9cSnatano {
486163fc9cSnatano 	int i;
496163fc9cSnatano 
506163fc9cSnatano 	for (i = 1; i <= n; i ++)
516163fc9cSnatano 		printf("\t");
526163fc9cSnatano }
536163fc9cSnatano 
546163fc9cSnatano #if 0
556163fc9cSnatano void
566163fc9cSnatano debug_print_rrip_info(n)
576163fc9cSnatano cd9660node *n;
586163fc9cSnatano {
596163fc9cSnatano 	struct ISO_SUSP_ATTRIBUTES *t;
606163fc9cSnatano 	TAILQ_FOREACH(t, &node->head, rr_ll) {
616163fc9cSnatano 
626163fc9cSnatano 	}
636163fc9cSnatano }
646163fc9cSnatano #endif
656163fc9cSnatano 
666163fc9cSnatano static void
debug_print_susp_attrs(cd9660node * n,int indent)676163fc9cSnatano debug_print_susp_attrs(cd9660node *n, int indent)
686163fc9cSnatano {
696163fc9cSnatano 	struct ISO_SUSP_ATTRIBUTES *t;
706163fc9cSnatano 
716163fc9cSnatano 	TAILQ_FOREACH(t, &n->head, rr_ll) {
726163fc9cSnatano 		print_n_tabs(indent);
736163fc9cSnatano 		printf("-");
746163fc9cSnatano 		printf("%c%c: L:%i",t->attr.su_entry.SP.h.type[0],
756163fc9cSnatano 		    t->attr.su_entry.SP.h.type[1],
766163fc9cSnatano 		    (int)t->attr.su_entry.SP.h.length[0]);
776163fc9cSnatano 		printf("\n");
786163fc9cSnatano 	}
796163fc9cSnatano }
806163fc9cSnatano 
816163fc9cSnatano void
debug_print_tree(iso9660_disk * diskStructure,cd9660node * node,int level)826163fc9cSnatano debug_print_tree(iso9660_disk *diskStructure, cd9660node *node, int level)
836163fc9cSnatano {
846163fc9cSnatano 	cd9660node *cn;
856163fc9cSnatano 
866163fc9cSnatano 	print_n_tabs(level);
876163fc9cSnatano 	if (node->type & CD9660_TYPE_DOT) {
886163fc9cSnatano 		printf(". (%i)\n",
896163fc9cSnatano 		    isonum_733(node->isoDirRecord->extent));
906163fc9cSnatano 	} else if (node->type & CD9660_TYPE_DOTDOT) {
916163fc9cSnatano 		printf("..(%i)\n",
926163fc9cSnatano 		    isonum_733(node->isoDirRecord->extent));
936163fc9cSnatano 	} else if (node->isoDirRecord->name[0]=='\0') {
946163fc9cSnatano 		printf("(ROOT) (%" PRIu32 " to %" PRId64 ")\n",
956163fc9cSnatano 		    node->fileDataSector,
966163fc9cSnatano 		    node->fileDataSector +
976163fc9cSnatano 			node->fileSectorsUsed - 1);
986163fc9cSnatano 	} else {
996163fc9cSnatano 		printf("%s (%s) (%" PRIu32 " to %" PRId64 ")\n",
1006163fc9cSnatano 		    node->isoDirRecord->name,
1016163fc9cSnatano 		    (node->isoDirRecord->flags[0]
1026163fc9cSnatano 			& ISO_FLAG_DIRECTORY) ?  "DIR" : "FILE",
1036163fc9cSnatano 		    node->fileDataSector,
1046163fc9cSnatano 		    (node->fileSectorsUsed == 0) ?
1056163fc9cSnatano 			node->fileDataSector :
1066163fc9cSnatano 			node->fileDataSector
1076163fc9cSnatano 			    + node->fileSectorsUsed - 1);
1086163fc9cSnatano 	}
1096163fc9cSnatano 	if (diskStructure->rock_ridge_enabled)
1106163fc9cSnatano 		debug_print_susp_attrs(node, level + 1);
1116163fc9cSnatano 	TAILQ_FOREACH(cn, &node->cn_children, cn_next_child)
1126163fc9cSnatano 		debug_print_tree(diskStructure, cn, level + 1);
1136163fc9cSnatano }
1146163fc9cSnatano 
1156163fc9cSnatano void
debug_print_path_tree(cd9660node * n)1166163fc9cSnatano debug_print_path_tree(cd9660node *n)
1176163fc9cSnatano {
1186163fc9cSnatano 	cd9660node *iterator = n;
1196163fc9cSnatano 
1206163fc9cSnatano 	/* Only display this message when called with the root node */
1216163fc9cSnatano 	if (n->parent == NULL)
1226163fc9cSnatano 		printf("debug_print_path_table: Dumping path table contents\n");
1236163fc9cSnatano 
1246163fc9cSnatano 	while (iterator != NULL) {
1256163fc9cSnatano 		if (iterator->isoDirRecord->name[0] == '\0')
1266163fc9cSnatano 			printf("0) (ROOT)\n");
1276163fc9cSnatano 		else
1286163fc9cSnatano 			printf("%i) %s\n", iterator->level,
1296163fc9cSnatano 			    iterator->isoDirRecord->name);
1306163fc9cSnatano 
1316163fc9cSnatano 		iterator = iterator->ptnext;
1326163fc9cSnatano 	}
1336163fc9cSnatano }
1346163fc9cSnatano 
1356163fc9cSnatano void
debug_print_volume_descriptor_information(iso9660_disk * diskStructure)1366163fc9cSnatano debug_print_volume_descriptor_information(iso9660_disk *diskStructure)
1376163fc9cSnatano {
1386163fc9cSnatano 	volume_descriptor *tmp = diskStructure->firstVolumeDescriptor;
1396163fc9cSnatano 	char temp[CD9660_SECTOR_SIZE];
1406163fc9cSnatano 
1416163fc9cSnatano 	printf("==Listing Volume Descriptors==\n");
1426163fc9cSnatano 
1436163fc9cSnatano 	while (tmp != NULL) {
1446163fc9cSnatano 		memset(temp, 0, CD9660_SECTOR_SIZE);
1456163fc9cSnatano 		memcpy(temp, tmp->volumeDescriptorData + 1, 5);
1466163fc9cSnatano 		printf("Volume descriptor in sector %" PRId64
1476163fc9cSnatano 		    ": type %i, ID %s\n",
1486163fc9cSnatano 		    tmp->sector, tmp->volumeDescriptorData[0], temp);
1496163fc9cSnatano 		switch(tmp->volumeDescriptorData[0]) {
1506163fc9cSnatano 		case 0:/*boot record*/
1516163fc9cSnatano 			break;
1526163fc9cSnatano 
1536163fc9cSnatano 		case 1:		/* PVD */
1546163fc9cSnatano 			break;
1556163fc9cSnatano 
1566163fc9cSnatano 		case 2:		/* SVD */
1576163fc9cSnatano 			break;
1586163fc9cSnatano 
1596163fc9cSnatano 		case 3:		/* Volume Partition Descriptor */
1606163fc9cSnatano 			break;
1616163fc9cSnatano 
1626163fc9cSnatano 		case 255:	/* terminator */
1636163fc9cSnatano 			break;
1646163fc9cSnatano 		}
1656163fc9cSnatano 		tmp = tmp->next;
1666163fc9cSnatano 	}
1676163fc9cSnatano 
1686163fc9cSnatano 	printf("==Done Listing Volume Descriptors==\n");
1696163fc9cSnatano }
1706163fc9cSnatano 
1716163fc9cSnatano void
debug_dump_to_xml_ptentry(path_table_entry * pttemp,int num,int mode)1726163fc9cSnatano debug_dump_to_xml_ptentry(path_table_entry *pttemp, int num, int mode)
1736163fc9cSnatano {
1746163fc9cSnatano 	printf("<ptentry num=\"%i\">\n" ,num);
1756163fc9cSnatano 	printf("<length>%i</length>\n", pttemp->length[0]);
1766163fc9cSnatano 	printf("<extended_attribute_length>%i</extended_attribute_length>\n",
1776163fc9cSnatano 	    pttemp->extended_attribute_length[0]);
1786163fc9cSnatano 	printf("<parent_number>%i</parent_number>\n",
1796163fc9cSnatano 	    debug_get_encoded_number(pttemp->parent_number,mode));
1806163fc9cSnatano 	debug_dump_to_xml_padded_hex_output("name",
1816163fc9cSnatano 	    pttemp->name, pttemp->length[0]);
1826163fc9cSnatano 	printf("</ptentry>\n");
1836163fc9cSnatano }
1846163fc9cSnatano 
1856163fc9cSnatano void
debug_dump_to_xml_path_table(FILE * fd,off_t sector,int size,int mode)1866163fc9cSnatano debug_dump_to_xml_path_table(FILE *fd, off_t sector, int size, int mode)
1876163fc9cSnatano {
1886163fc9cSnatano 	path_table_entry pttemp;
1896163fc9cSnatano 	int t = 0;
1906163fc9cSnatano 	int n = 0;
1916163fc9cSnatano 
1926163fc9cSnatano 	if (fseeko(fd, CD9660_SECTOR_SIZE * sector, SEEK_SET) == -1)
1936163fc9cSnatano 		err(1, "fseeko");
1946163fc9cSnatano 
1956163fc9cSnatano 	while (t < size) {
1966163fc9cSnatano 		/* Read fixed data first */
1976163fc9cSnatano 		fread(&pttemp, 1, 8, fd);
1986163fc9cSnatano 		t += 8;
1996163fc9cSnatano 		/* Read variable */
2006163fc9cSnatano 		fread(((unsigned char*)&pttemp) + 8, 1, pttemp.length[0], fd);
2016163fc9cSnatano 		t += pttemp.length[0];
2026163fc9cSnatano 		debug_dump_to_xml_ptentry(&pttemp, n, mode);
2036163fc9cSnatano 		n++;
2046163fc9cSnatano 	}
2056163fc9cSnatano 
2066163fc9cSnatano }
2076163fc9cSnatano 
2086163fc9cSnatano /*
2096163fc9cSnatano  * XML Debug output functions
2106163fc9cSnatano  * Dump hierarchy of CD, as well as volume info, to XML
2116163fc9cSnatano  * Can be used later to diff against a standard,
2126163fc9cSnatano  * or just provide easy to read detailed debug output
2136163fc9cSnatano  */
2146163fc9cSnatano void
debug_dump_to_xml(FILE * fd)2156163fc9cSnatano debug_dump_to_xml(FILE *fd)
2166163fc9cSnatano {
2176163fc9cSnatano 	unsigned char buf[CD9660_SECTOR_SIZE];
2186163fc9cSnatano 	off_t sector;
2196163fc9cSnatano 	int t, t2;
2206163fc9cSnatano 	struct iso_primary_descriptor primaryVD;
2216163fc9cSnatano 	struct _boot_volume_descriptor bootVD;
2226163fc9cSnatano 
2236163fc9cSnatano 	memset(&primaryVD, 0, sizeof(primaryVD));
2246163fc9cSnatano 	printf("<cd9660dump>\n");
2256163fc9cSnatano 
2266163fc9cSnatano 	/* Display Volume Descriptors */
2276163fc9cSnatano 	sector = 16;
2286163fc9cSnatano 	do {
2296163fc9cSnatano 		if (fseeko(fd, CD9660_SECTOR_SIZE * sector, SEEK_SET) == -1)
2306163fc9cSnatano 			err(1, "fseeko");
2316163fc9cSnatano 		fread(buf, 1, CD9660_SECTOR_SIZE, fd);
2326163fc9cSnatano 		t = (int)((unsigned char)buf[0]);
2336163fc9cSnatano 		switch (t) {
2346163fc9cSnatano 		case 0:
2356163fc9cSnatano 			memcpy(&bootVD, buf, CD9660_SECTOR_SIZE);
2366163fc9cSnatano 			break;
2376163fc9cSnatano 		case 1:
2386163fc9cSnatano 			memcpy(&primaryVD, buf, CD9660_SECTOR_SIZE);
2396163fc9cSnatano 			break;
2406163fc9cSnatano 		}
2416163fc9cSnatano 		debug_dump_to_xml_volume_descriptor(buf, sector);
2426163fc9cSnatano 		sector++;
2436163fc9cSnatano 	} while (t != 255);
2446163fc9cSnatano 
2456163fc9cSnatano 	t = debug_get_encoded_number((u_char *)primaryVD.type_l_path_table,
2466163fc9cSnatano 	    731);
2476163fc9cSnatano 	t2 = debug_get_encoded_number((u_char *)primaryVD.path_table_size, 733);
2486163fc9cSnatano 	printf("Path table 1 located at sector %i and is %i bytes long\n",
2496163fc9cSnatano 	    t,t2);
2506163fc9cSnatano 	debug_dump_to_xml_path_table(fd, t, t2, 721);
2516163fc9cSnatano 
2526163fc9cSnatano 	t = debug_get_encoded_number((u_char *)primaryVD.type_m_path_table,
2536163fc9cSnatano 	    731);
2546163fc9cSnatano 	debug_dump_to_xml_path_table(fd, t, t2, 722);
2556163fc9cSnatano 
2566163fc9cSnatano 	printf("</cd9660dump>\n");
2576163fc9cSnatano }
2586163fc9cSnatano 
2596163fc9cSnatano static void
debug_dump_to_xml_padded_hex_output(const char * element,unsigned char * buf,int len)2606163fc9cSnatano debug_dump_to_xml_padded_hex_output(const char *element, unsigned char *buf,
2616163fc9cSnatano 				    int len)
2626163fc9cSnatano {
2636163fc9cSnatano 	int i;
2646163fc9cSnatano 	int t;
2656163fc9cSnatano 
2666163fc9cSnatano 	printf("<%s>",element);
2676163fc9cSnatano 	for (i = 0; i < len; i++) {
2686163fc9cSnatano 		t = (unsigned char)buf[i];
2696163fc9cSnatano 		if (t >= 32 && t < 127)
2706163fc9cSnatano 			printf("%c",t);
2716163fc9cSnatano 	}
2726163fc9cSnatano 	printf("</%s>\n",element);
2736163fc9cSnatano 
2746163fc9cSnatano 	printf("<%s:hex>",element);
2756163fc9cSnatano 	for (i = 0; i < len; i++) {
2766163fc9cSnatano 		t = (unsigned char)buf[i];
2776163fc9cSnatano 		printf(" %x",t);
2786163fc9cSnatano 	}
2796163fc9cSnatano 	printf("</%s:hex>\n",element);
2806163fc9cSnatano }
2816163fc9cSnatano 
2826163fc9cSnatano int
debug_get_encoded_number(unsigned char * buf,int mode)2836163fc9cSnatano debug_get_encoded_number(unsigned char* buf, int mode)
2846163fc9cSnatano {
2856163fc9cSnatano 	switch (mode) {
2866163fc9cSnatano 	/* 711: Single bite */
2876163fc9cSnatano 	case 711:
2886163fc9cSnatano 		return isonum_711(buf);
2896163fc9cSnatano 
2906163fc9cSnatano 	/* 712: Single signed byte */
2916163fc9cSnatano 	case 712:
2926163fc9cSnatano 		return isonum_712((signed char *)buf);
2936163fc9cSnatano 
2946163fc9cSnatano 	/* 721: 16 bit LE */
2956163fc9cSnatano 	case 721:
2966163fc9cSnatano 		return isonum_721(buf);
2976163fc9cSnatano 
2986163fc9cSnatano 	/* 731: 32 bit LE */
2996163fc9cSnatano 	case 731:
3006163fc9cSnatano 		return isonum_731(buf);
3016163fc9cSnatano 
3026163fc9cSnatano 	/* 722: 16 bit BE */
3036163fc9cSnatano 	case 722:
3046163fc9cSnatano 		return isonum_722(buf);
3056163fc9cSnatano 
3066163fc9cSnatano 	/* 732: 32 bit BE */
3076163fc9cSnatano 	case 732:
3086163fc9cSnatano 		return isonum_732(buf);
3096163fc9cSnatano 
3106163fc9cSnatano 	/* 723: 16 bit bothE */
3116163fc9cSnatano 	case 723:
3126163fc9cSnatano 		return isonum_723(buf);
3136163fc9cSnatano 
3146163fc9cSnatano 	/* 733: 32 bit bothE */
3156163fc9cSnatano 	case 733:
3166163fc9cSnatano 		return isonum_733(buf);
3176163fc9cSnatano 	}
3186163fc9cSnatano 	return 0;
3196163fc9cSnatano }
3206163fc9cSnatano 
3216163fc9cSnatano void
debug_dump_integer(const char * element,char * buf,int mode)3226163fc9cSnatano debug_dump_integer(const char *element, char* buf, int mode)
3236163fc9cSnatano {
3246163fc9cSnatano 	printf("<%s>%i</%s>\n", element,
3256163fc9cSnatano 	    debug_get_encoded_number((unsigned char *)buf, mode), element);
3266163fc9cSnatano }
3276163fc9cSnatano 
3286163fc9cSnatano void
debug_dump_string(const char * element __unused,unsigned char * buf __unused,int len __unused)3296163fc9cSnatano debug_dump_string(const char *element __unused, unsigned char *buf __unused, int len __unused)
3306163fc9cSnatano {
3316163fc9cSnatano 
3326163fc9cSnatano }
3336163fc9cSnatano 
3346163fc9cSnatano void
debug_dump_directory_record_9_1(unsigned char * buf)3356163fc9cSnatano debug_dump_directory_record_9_1(unsigned char* buf)
3366163fc9cSnatano {
3376163fc9cSnatano 	printf("<directoryrecord>\n");
3386163fc9cSnatano 	debug_dump_integer("length",
3396163fc9cSnatano 	    ((struct iso_directory_record*) buf)->length, 711);
3406163fc9cSnatano 	debug_dump_integer("ext_attr_length",
3416163fc9cSnatano 	    ((struct iso_directory_record*) buf)->ext_attr_length,711);
3426163fc9cSnatano 	debug_dump_integer("extent",
3436163fc9cSnatano 	    (char *)((struct iso_directory_record*) buf)->extent, 733);
3446163fc9cSnatano 	debug_dump_integer("size",
3456163fc9cSnatano 	    (char *)((struct iso_directory_record*) buf)->size, 733);
3466163fc9cSnatano 	debug_dump_integer("flags",
3476163fc9cSnatano 	    ((struct iso_directory_record*) buf)->flags, 711);
3486163fc9cSnatano 	debug_dump_integer("file_unit_size",
3496163fc9cSnatano 	    ((struct iso_directory_record*) buf)->file_unit_size,711);
3506163fc9cSnatano 	debug_dump_integer("interleave",
3516163fc9cSnatano 	    ((struct iso_directory_record*) buf)->interleave, 711);
3526163fc9cSnatano 	debug_dump_integer("volume_sequence_number",
3536163fc9cSnatano 	    ((struct iso_directory_record*) buf)->volume_sequence_number,
3546163fc9cSnatano 	    723);
3556163fc9cSnatano 	debug_dump_integer("name_len",
3566163fc9cSnatano 	    ((struct iso_directory_record*) buf)->name_len, 711);
3576163fc9cSnatano 	debug_dump_to_xml_padded_hex_output("name",
3586163fc9cSnatano 	    (u_char *)((struct iso_directory_record*) buf)->name,
3596163fc9cSnatano 		debug_get_encoded_number((u_char *)
3606163fc9cSnatano 		    ((struct iso_directory_record*) buf)->length, 711));
3616163fc9cSnatano 	printf("</directoryrecord>\n");
3626163fc9cSnatano }
3636163fc9cSnatano 
3646163fc9cSnatano 
3656163fc9cSnatano void
debug_dump_to_xml_volume_descriptor(unsigned char * buf,int sector)3666163fc9cSnatano debug_dump_to_xml_volume_descriptor(unsigned char* buf, int sector)
3676163fc9cSnatano {
3686163fc9cSnatano 	printf("<volumedescriptor sector=\"%i\">\n", sector);
3696163fc9cSnatano 	printf("<vdtype>");
3706163fc9cSnatano 	switch(buf[0]) {
3716163fc9cSnatano 	case 0:
3726163fc9cSnatano 		printf("boot");
3736163fc9cSnatano 		break;
3746163fc9cSnatano 
3756163fc9cSnatano 	case 1:
3766163fc9cSnatano 		printf("primary");
3776163fc9cSnatano 		break;
3786163fc9cSnatano 
3796163fc9cSnatano 	case 2:
3806163fc9cSnatano 		printf("supplementary");
3816163fc9cSnatano 		break;
3826163fc9cSnatano 
3836163fc9cSnatano 	case 3:
3846163fc9cSnatano 		printf("volume partition descriptor");
3856163fc9cSnatano 		break;
3866163fc9cSnatano 
3876163fc9cSnatano 	case 255:
3886163fc9cSnatano 		printf("terminator");
3896163fc9cSnatano 		break;
3906163fc9cSnatano 	}
3916163fc9cSnatano 
3926163fc9cSnatano 	printf("</vdtype>\n");
3936163fc9cSnatano 	switch(buf[0]) {
3946163fc9cSnatano 	case 1:
3956163fc9cSnatano 		debug_dump_integer("type",
3966163fc9cSnatano 		    ((struct iso_primary_descriptor*)buf)->type, 711);
3976163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("id",
3986163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->id,
3996163fc9cSnatano 		    ISODCL (  2,   6));
4006163fc9cSnatano 		debug_dump_integer("version",
4016163fc9cSnatano 		    ((struct iso_primary_descriptor*)buf)->version,
4026163fc9cSnatano 		     711);
4036163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("system_id",
4046163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*)buf)->system_id,
4056163fc9cSnatano 		    ISODCL(9,40));
4066163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("volume_id",
4076163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*)buf)->volume_id,
4086163fc9cSnatano 		    ISODCL(41,72));
4096163fc9cSnatano 		debug_dump_integer("volume_space_size",
4106163fc9cSnatano 		    ((struct iso_primary_descriptor*)buf)->volume_space_size,
4116163fc9cSnatano 		    733);
4126163fc9cSnatano 		debug_dump_integer("volume_set_size",
4136163fc9cSnatano 		    ((struct iso_primary_descriptor*)buf)->volume_set_size,
4146163fc9cSnatano 			    733);
4156163fc9cSnatano 		debug_dump_integer("volume_sequence_number",
4166163fc9cSnatano 		    ((struct iso_primary_descriptor*)buf)->volume_sequence_number,
4176163fc9cSnatano 		    723);
4186163fc9cSnatano 		debug_dump_integer("logical_block_size",
4196163fc9cSnatano 		    ((struct iso_primary_descriptor*)buf)->logical_block_size,
4206163fc9cSnatano 			    723);
4216163fc9cSnatano 		debug_dump_integer("path_table_size",
4226163fc9cSnatano 		    ((struct iso_primary_descriptor*)buf)->path_table_size,
4236163fc9cSnatano 			    733);
4246163fc9cSnatano 		debug_dump_integer("type_l_path_table",
4256163fc9cSnatano 		    ((struct iso_primary_descriptor*)buf)->type_l_path_table,
4266163fc9cSnatano 		    731);
4276163fc9cSnatano 		debug_dump_integer("opt_type_l_path_table",
4286163fc9cSnatano 		    ((struct iso_primary_descriptor*)buf)->opt_type_l_path_table,
4296163fc9cSnatano 		    731);
4306163fc9cSnatano 		debug_dump_integer("type_m_path_table",
4316163fc9cSnatano 		    ((struct iso_primary_descriptor*)buf)->type_m_path_table,
4326163fc9cSnatano 		    732);
4336163fc9cSnatano 		debug_dump_integer("opt_type_m_path_table",
4346163fc9cSnatano 			((struct iso_primary_descriptor*)buf)->opt_type_m_path_table,732);
4356163fc9cSnatano 		debug_dump_directory_record_9_1(
4366163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*)buf)->root_directory_record);
4376163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("volume_set_id",
4386163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->volume_set_id,
4396163fc9cSnatano 		    ISODCL (191, 318));
4406163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("publisher_id",
4416163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->publisher_id,
4426163fc9cSnatano 		    ISODCL (319, 446));
4436163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("preparer_id",
4446163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->preparer_id,
4456163fc9cSnatano 		    ISODCL (447, 574));
4466163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("application_id",
4476163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->application_id,
4486163fc9cSnatano 		    ISODCL (575, 702));
4496163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("copyright_file_id",
4506163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->copyright_file_id,
4516163fc9cSnatano 		    ISODCL (703, 739));
4526163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("abstract_file_id",
4536163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->abstract_file_id,
4546163fc9cSnatano 		    ISODCL (740, 776));
4556163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("bibliographic_file_id",
4566163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->bibliographic_file_id,
4576163fc9cSnatano 		    ISODCL (777, 813));
4586163fc9cSnatano 
4596163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("creation_date",
4606163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->creation_date,
4616163fc9cSnatano 		    ISODCL (814, 830));
4626163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("modification_date",
4636163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->modification_date,
4646163fc9cSnatano 		    ISODCL (831, 847));
4656163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("expiration_date",
4666163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->expiration_date,
4676163fc9cSnatano 		    ISODCL (848, 864));
4686163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("effective_date",
4696163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->effective_date,
4706163fc9cSnatano 		    ISODCL (865, 881));
4716163fc9cSnatano 
4726163fc9cSnatano 		debug_dump_to_xml_padded_hex_output("file_structure_version",
4736163fc9cSnatano 		    (u_char *)((struct iso_primary_descriptor*) buf)->file_structure_version,
4746163fc9cSnatano 		    ISODCL(882,882));
4756163fc9cSnatano 		break;
4766163fc9cSnatano 	}
4776163fc9cSnatano 	printf("</volumedescriptor>\n");
4786163fc9cSnatano }
4796163fc9cSnatano 
480