File: iprdumpfmt.c

package info (click to toggle)
iprutils 2.4.14.1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,556 kB
  • ctags: 3,479
  • sloc: ansic: 26,320; sh: 11,463; makefile: 74; python: 10
file content (600 lines) | stat: -rw-r--r-- 14,886 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
/**
 * IBM IPR dump formatting utility
 *
 * (C) Copyright 2015
 * International Business Machines Corporation and others.
 * All Rights Reserved. This program and the accompanying
 * materials are made available under the terms of the
 * Common Public License v1.0 which accompanies this distribution.
 **/

#include <endian.h>
#include <getopt.h>
#include "iprlib.h"

#define EYE_CATCHER_BE 0xC5D4E3F2
#define EYE_CATCHER_LE 0xF2E3D4C5

#define OS_LINUX 0x4C4E5558

#define DRV_IPR2 0x49505232

#define TYPE_ASCII 0x41534349
#define TYPE_BIN   0x42494E41
#define TYPE_MR32  0x4D523332
#define TYPE_MR64  0x4D523634

#define ID_IOA_DUMP     0x494F4131
#define ID_IOA_LOC      0x4C4F4341
#define ID_DRV_TRACE    0x54524143
#define ID_DRV_VER      0x44525652
#define ID_DRV_TYPE     0x54595045
#define ID_DRV_CTRL_BLK 0x494F4342
#define ID_DRV_PEND_OPS 0x414F5053

#define IPR_DUMP_STATUS_SUCCESS      0
#define IPR_DUMP_STATUS_QUAL_SUCCESS 2
#define IPR_DUMP_STATUS_FAILED       0xFFFFFFFF

static const struct {
	const u8 op;
	const char *name;
} scsi_cmnds[] = {
	{ 0xc1, "IPR_CANCEL_REQUEST" },
	{ 0xc2, "IPR_QUERY_RSRC_STATE" },
	{ 0xc3, "IPR_RESET_DEVICE" },
	{ 0xc4, "IPR_ID_HOST_RR_Q" },
	{ 0xc5, "IPR_QUERY_IOA_CONFIG" },
	{ 0xce, "IPR_CANCEL_ALL_REQUESTS" },
	{ 0xcf, "IPR_HOST_CONTROLLED_ASYNC" },
	{ 0xfb, "IPR_SET_SUPPORTED_DEVICES" },
	{ 0xf7, "IPR_IOA_SHUTDOWN" },

	{ 0x00, "TEST_UNIT_READY" },
	{ 0x01, "REZERO_UNIT" },
	{ 0x03, "REQUEST_SENSE" },
	{ 0x04, "FORMAT_UNIT" },
	{ 0x05, "READ_BLOCK_LIMITS" },
	{ 0x07, "REASSIGN_BLOCKS" },
	{ 0x07, "INITIALIZE_ELEMENT_STATUS" },
	{ 0x08, "READ_6" },
	{ 0x0a, "WRITE_6" },
	{ 0x0b, "SEEK_6" },
	{ 0x0f, "READ_REVERSE" },
	{ 0x10, "WRITE_FILEMARKS" },
	{ 0x11, "SPACE" },
	{ 0x12, "INQUIRY" },
	{ 0x14, "RECOVER_BUFFERED_DATA" },
	{ 0x15, "MODE_SELECT" },
	{ 0x16, "RESERVE" },
	{ 0x17, "RELEASE" },
	{ 0x18, "COPY" },
	{ 0x19, "ERASE" },
	{ 0x1a, "MODE_SENSE" },
	{ 0x1b, "START_STOP" },
	{ 0x1c, "RECEIVE_DIAGNOSTIC" },
	{ 0x1d, "SEND_DIAGNOSTIC" },
	{ 0x1e, "ALLOW_MEDIUM_REMOVAL" },
	{ 0x23, "READ_FORMAT_CAPACITIES" },
	{ 0x24, "SET_WINDOW" },
	{ 0x25, "READ_CAPACITY" },
	{ 0x28, "READ_10" },
	{ 0x2a, "WRITE_10" },
	{ 0x2b, "SEEK_10" },
	{ 0x2b, "POSITION_TO_ELEMENT" },
	{ 0x2e, "WRITE_VERIFY" },
	{ 0x2f, "VERIFY" },
	{ 0x30, "SEARCH_HIGH" },
	{ 0x31, "SEARCH_EQUAL" },
	{ 0x32, "SEARCH_LOW" },
	{ 0x33, "SET_LIMITS" },
	{ 0x34, "PRE_FETCH" },
	{ 0x34, "READ_POSITION" },
	{ 0x35, "SYNCHRONIZE_CACHE" },
	{ 0x36, "LOCK_UNLOCK_CACHE" },
	{ 0x37, "READ_DEFECT_DATA" },
	{ 0x38, "MEDIUM_SCAN" },
	{ 0x39, "COMPARE" },
	{ 0x3a, "COPY_VERIFY" },
	{ 0x3b, "WRITE_BUFFER" },
	{ 0x3c, "READ_BUFFER" },
	{ 0x3d, "UPDATE_BLOCK" },
	{ 0x3e, "READ_LONG" },
	{ 0x3f, "WRITE_LONG" },
	{ 0x40, "CHANGE_DEFINITION" },
	{ 0x41, "WRITE_SAME" },
	{ 0x42, "UNMAP" },
	{ 0x43, "READ_TOC" },
	{ 0x44, "READ_HEADER" },
	{ 0x4a, "GET_EVENT_STATUS_NOTIFICATION" },
	{ 0x4c, "LOG_SELECT" },
	{ 0x4d, "LOG_SENSE" },
	{ 0x53, "XDWRITEREAD_10" },
	{ 0x55, "MODE_SELECT_10" },
	{ 0x56, "RESERVE_10" },
	{ 0x57, "RELEASE_10" },
	{ 0x5a, "MODE_SENSE_10" },
	{ 0x5e, "PERSISTENT_RESERVE_IN" },
	{ 0x5f, "PERSISTENT_RESERVE_OUT" },
	{ 0x7f, "VARIABLE_LENGTH_CMD" },
	{ 0xa0, "REPORT_LUNS" },
	{ 0xa2, "SECURITY_PROTOCOL_IN" },
	{ 0xa3, "MAINTENANCE_IN" },
	{ 0xa4, "MAINTENANCE_OUT" },
	{ 0xa5, "MOVE_MEDIUM" },
	{ 0xa6, "EXCHANGE_MEDIUM" },
	{ 0xa8, "READ_12" },
	{ 0xa9, "SERVICE_ACTION_OUT_12" },
	{ 0xaa, "WRITE_12" },
	{ 0xab, "SERVICE_ACTION_IN_12" },
	{ 0xae, "WRITE_VERIFY_12" },
	{ 0xaf, "VERIFY_12" },
	{ 0xb0, "SEARCH_HIGH_12" },
	{ 0xb1, "SEARCH_EQUAL_12" },
	{ 0xb2, "SEARCH_LOW_12" },
	{ 0xb5, "SECURITY_PROTOCOL_OUT" },
	{ 0xb8, "READ_ELEMENT_STATUS" },
	{ 0xb6, "SEND_VOLUME_TAG" },
	{ 0xea, "WRITE_LONG_2" },
	{ 0x83, "EXTENDED_COPY" },
	{ 0x84, "RECEIVE_COPY_RESULTS" },
	{ 0x86, "ACCESS_CONTROL_IN" },
	{ 0x87, "ACCESS_CONTROL_OUT" },
	{ 0x88, "READ_16" },
	{ 0x89, "COMPARE_AND_WRITE" },
	{ 0x8a, "WRITE_16" },
	{ 0x8c, "READ_ATTRIBUTE" },
	{ 0x8d, "WRITE_ATTRIBUTE" },
	{ 0x8f, "VERIFY_16" },
	{ 0x91, "SYNCHRONIZE_CACHE_16" },
	{ 0x93, "WRITE_SAME_16" },
	{ 0x9d, "SERVICE_ACTION_BIDIRECTIONAL" },
	{ 0x9e, "SERVICE_ACTION_IN_16" },
	{ 0x9f, "SERVICE_ACTION_OUT_16" }
};

struct ipr_dump_header {
	u32 eye_catcher;
	u32 len;
	u32 num_entries;
	u32 first_entry_offset;
	u32 status;
	u32 os;
	u32 driver_name;
};

struct ipr_dump_entry_header {
	u32 eye_catcher;
	u32 len; /* does not include entry header */
	u32 num_elems;
	u32 offset; /* offset to data from beginning of dump file */
	u32 data_type;
	u32 id;
	u32 status;
};

struct ipr_trace_entry {
	u32 time;

	u8 op_code; /* SCSI opcode */
	u8 ata_op_code;
	u8 type;
#define IPR_TRACE_START			0x00
#define IPR_TRACE_FINISH		0xff
	u8 cmd_index;

	u32 res_handle; /* stored as BE */
	union {
		u32 ioasc;
		u32 add_data;
		u32 res_addr;
	} u;
};

static void *dump_map;    /* ipr dump memory map */
static FILE *out_fp;      /* output report file pointer */
static int verbose_trace; /* flag for verbose trace printing */

#define TARGET_TO_HOST32(value, eye_catcher) \
	(eye_catcher == EYE_CATCHER_BE ? \
	 be32toh(value) : \
	 le32toh(value))

/**
 * get_scsi_command_literal -
 * @value:		SCSI opcode
 *
 * Returns:
 *   SCSI command string
 **/
static const char* get_scsi_command_literal(u32 value)
{
	u32 i = 0;

	for (i = 0; i < ARRAY_SIZE(scsi_cmnds); ++i) {
		if (value == scsi_cmnds[i].op)
			return scsi_cmnds[i].name;
	}
	return NULL;
}

/**
 * read_dump_header -
 * @hdr:		ipr dump header pointer
 *
 * Returns:
 *   nothing
 **/
static void read_dump_header(struct ipr_dump_header *hdr)
{
	struct ipr_dump_header *raw_hdr = dump_map;

	hdr->eye_catcher = htobe32(raw_hdr->eye_catcher);

	/* convert to correct endianness */
	hdr->len = TARGET_TO_HOST32(raw_hdr->len, hdr->eye_catcher);
	hdr->num_entries = TARGET_TO_HOST32(raw_hdr->num_entries,
					    hdr->eye_catcher);
	hdr->first_entry_offset = TARGET_TO_HOST32(raw_hdr->first_entry_offset,
						   hdr->eye_catcher);
	hdr->status = TARGET_TO_HOST32(raw_hdr->status, hdr->eye_catcher);
	hdr->os = TARGET_TO_HOST32(raw_hdr->os, hdr->eye_catcher);
	hdr->driver_name = TARGET_TO_HOST32(raw_hdr->driver_name,
					    hdr->eye_catcher);
}

/**
 * print_dump_header -
 * @hdr:		ipr dump header pointer
 *
 * Returns:
 *   nothing
 **/
static void print_dump_header(struct ipr_dump_header *hdr)
{
	fprintf(out_fp, "IPR Adapter Dump Report\n\n");
	switch (hdr->eye_catcher) {
	case EYE_CATCHER_BE:
		fprintf(out_fp, "Big Endian format: ");
		break;
	case EYE_CATCHER_LE:
		fprintf(out_fp, "Little Endian format: ");
		break;
	default:
		fprintf(out_fp, "Unknown dump format: ");
	}
	fprintf(out_fp, "Eye Catcher is 0x%08X\n", hdr->eye_catcher);

	fprintf(out_fp, "Total length: %d bytes\n", hdr->len);
	fprintf(out_fp, "Number of dump entries: %d\n", hdr->num_entries);
	fprintf(out_fp, "Offset to first entry: 0x%08X bytes\n",
		hdr->first_entry_offset);
	fprintf(out_fp, "Dump status: 0x%08X ", hdr->status);
	switch (hdr->status) {
	case IPR_DUMP_STATUS_SUCCESS:
		fprintf(out_fp, "(SUCCESS)\n");
		break;
	case IPR_DUMP_STATUS_QUAL_SUCCESS:
		fprintf(out_fp, "(QUAL_SUCCESS)\n");
		break;
	case IPR_DUMP_STATUS_FAILED:
		fprintf(out_fp, "(FAILED)\n");
		break;
	default:
		fprintf(out_fp, "(UNKNOWN)\n");
	}

	fprintf(out_fp, "Operating System: ");
	switch (hdr->os) {
	case OS_LINUX:
		fprintf(out_fp, "Linux\n");
		break;
	default:
		fprintf(out_fp, "unknown\n");
	}

	fprintf(out_fp, "Driver: ");
	switch (hdr->driver_name) {
	case DRV_IPR2:
		fprintf(out_fp, "ipr2\n");
		break;
	default:
		fprintf(out_fp, "unknown\n");
	}
}

/**
 * read_entry_header -
 * @hdr:		ipr dump entry header pointer
 * @offset:		offset to entry data
 *
 * Returns:
 *   offset to next entry header
 **/
static u32 read_entry_header(struct ipr_dump_entry_header *hdr, u32 offset)
{
	struct ipr_dump_entry_header *raw_hdr = dump_map+offset;
	hdr->eye_catcher = htobe32(raw_hdr->eye_catcher);

	/* convert to correct endianness */
	hdr->len = TARGET_TO_HOST32(raw_hdr->len, hdr->eye_catcher);
	hdr->num_elems = TARGET_TO_HOST32(raw_hdr->num_elems, hdr->eye_catcher);
	hdr->offset = TARGET_TO_HOST32(raw_hdr->offset, hdr->eye_catcher);
	hdr->data_type = TARGET_TO_HOST32(raw_hdr->data_type, hdr->eye_catcher);
	hdr->id = TARGET_TO_HOST32(raw_hdr->id, hdr->eye_catcher);
	hdr->status = TARGET_TO_HOST32(raw_hdr->status, hdr->eye_catcher);
	hdr->offset += offset;

	return (hdr->offset + hdr->len);
}

/**
 * read_trace_data -
 * @offset:		offset to entry data
 * @eye_catcher:	ipr entry eye catcher
 *
 * Returns:
 *   ipr trace entry structure
 **/
static struct ipr_trace_entry read_trace_data(u32 offset, u32 eye_catcher)
{
	struct ipr_trace_entry trace;
	struct ipr_trace_entry *raw_trace = dump_map+offset;

        /* always stored as BE */
	trace.res_handle = htobe32(raw_trace->res_handle);

	/* convert to correct endianness */
	trace.time = TARGET_TO_HOST32(raw_trace->time, eye_catcher);
	trace.u.add_data = TARGET_TO_HOST32(raw_trace->u.add_data, eye_catcher);

	/* copy remaining trace fields */
	trace.op_code = raw_trace->op_code;
	trace.ata_op_code = raw_trace->ata_op_code;
	trace.type = raw_trace->type;
	trace.cmd_index = raw_trace->cmd_index;

	return trace;
}

#define JIFF_TO_USEC(x) x * 1000 * 1000 / sysconf(_SC_CLK_TCK)
/**
 * print_trace -
 * @hdr:		ipr entry header pointer
 *
 * Returns:
 *   nothing
 **/
static void print_trace(struct ipr_dump_entry_header *hdr)
{
	u32 i, min_pos, min_time, num_entries, offset;
	struct ipr_trace_entry *raw_trace;
	struct ipr_trace_entry t;
	const char *cmnd;

	num_entries = hdr->len / sizeof(*raw_trace);
	raw_trace = dump_map + hdr->offset;
	min_pos = 0;
	min_time = TARGET_TO_HOST32(raw_trace->time, hdr->eye_catcher);

	fprintf(out_fp, "\t entries found: %d\n\n", num_entries);
	for (i = 1; i < num_entries; ++i) {
		raw_trace = dump_map + hdr->offset + i*sizeof(*raw_trace);
		if (TARGET_TO_HOST32(raw_trace->time, hdr->eye_catcher) <
		    min_time) {
			min_time = TARGET_TO_HOST32(raw_trace->time,
						    hdr->eye_catcher);
			min_pos = i;
		}
	}
	for (i = 0; i < num_entries; ++i) {
		offset = hdr->offset +
			((min_pos+i)%num_entries) * sizeof(*raw_trace);
		t = read_trace_data(offset, hdr->eye_catcher);
		fprintf(out_fp, "\t %08X %02X%02X%02X%02X %08X %08X",
			t.time,	t.op_code, t.ata_op_code, t.type, t.cmd_index,
			t.res_handle, t.u.add_data);
		if (verbose_trace) {
			t.time -= min_time;
			fprintf(out_fp, "\t|\t%+10lld\xC2\xB5s\t",
				(long long unsigned)JIFF_TO_USEC(t.time));
			switch(t.type) {
			case IPR_TRACE_START:
				fprintf(out_fp, "START\t");
				break;
			case IPR_TRACE_FINISH:
				fprintf(out_fp, "FINISH\t");
				break;
			default:
				fprintf(out_fp, "\t");
			}
			cmnd = get_scsi_command_literal(t.op_code);
			if (cmnd)
				fprintf(out_fp, "%s", cmnd);

		}
		fprintf(out_fp, "\n");
	}
}

/**
 * dump_entry_data -
 * @hdr:		ipr dump entry header pointer
 *
 * Returns:
 *   nothing
 **/
static void dump_entry_data(struct ipr_dump_entry_header *hdr)
{
	u32 i;
	char *s;

	switch (hdr->id) {
	case ID_IOA_LOC:
		fprintf(out_fp, "IOA Location:\n");
		s = dump_map+hdr->offset;
		fprintf(out_fp, "\t %.*s\n\n", hdr->len, s);
		break;
	case ID_DRV_VER:
		fprintf(out_fp, "Driver Version:\n");
		s = dump_map+hdr->offset;
		fprintf(out_fp, "\t %.*s\n\n", hdr->len, s);
		break;
	case ID_DRV_TRACE:
		fprintf(out_fp, "Driver Trace Entries:\n");
		print_trace(hdr);
		fprintf(out_fp, "\n");
		break;
	case ID_DRV_TYPE:
		fprintf(out_fp, "Driver Type:\n");
		i = TARGET_TO_HOST32(*(int*)(dump_map+hdr->offset),
				     hdr->eye_catcher);
		fprintf(out_fp, "\t CCIN: 0x%04X\n", i);
		i = TARGET_TO_HOST32(*(int*)(dump_map+hdr->offset+sizeof(i)),
				     hdr->eye_catcher);
		fprintf(out_fp,"\t Adapter firmware Version: "
			" %02X%02X%02X%02X\n\n",
			i >> 24,                /* major release */
			(i & 0x00FF0000) >> 16, /* card type */
			(i & 0x0000FF00) >> 8,  /* minor release 0 */
			i & 0x000000FF);        /* minor release 1 */
		break;
	case ID_IOA_DUMP:
		/* skip this one, not very useful for driver debugging */
		break;
	case ID_DRV_CTRL_BLK:
	case ID_DRV_PEND_OPS:
		/* not implemented yet */
		fprintf(stderr,
			"Warning: found IPR Control Block or IPR Pending Ops!\n"
			"These are not implemented yet. Skipping...\n");
		break;
	default:
		fprintf(stderr,
			"Warning: did not recognize data identification "
			"(id 0x%08X). Skipping...\n\n", hdr->id);
	}
}

/**
 * fsize -
 * @filename:		ipr dump file name
 *
 * Returns:
 *   ipr dump file size
 **/
off_t fsize(const char *filename)
{
	struct stat st;

	if (stat(filename, &st) == 0)
		return st.st_size;

	return -1;
}

/**
 * print_usage -
 *
 * Returns:
 *   nothing
 **/
static void print_usage()
{
	fprintf(stdout,
		"Usage: iprdumpfmt [options] dump_file\n"
		"  Options:\n"
		"\t-h --help\tPrint this message\n"
		"\t-o --output\tSpecify an output file\n"
		"\t-v --verbose\tPrint verbose trace data\n");
}

static struct option long_options[] = {
	{"output", required_argument, 0, 'o'},
	{"help", no_argument, 0, 'h'},
	{"verbose", no_argument, &verbose_trace, 1},
	{0, 0, 0, 0}
};

int main(int argc, char *argv[])
{
	u32 i, offset;
	int in_fd, filesize;
	struct ipr_dump_header hdr;
	struct ipr_dump_entry_header entry_hdr;
	int c, option_index = 0;
	char out_filename[512] = {'\0'};

	while ((c = getopt_long(argc, argv, "hvo:", long_options,
				&option_index)) != -1) {
		switch (c) {
		case 0:
			break;
		case 'o':
			strncpy(out_filename, optarg, sizeof(out_filename) - 1);
			break;
		case '?':
		case 'h':
			print_usage();
			return 0;
		case 'v':
			verbose_trace = 1;
			break;
		default:
			return -1;
		}
	}

	if (argc - optind < 1) {
		/* needs at least a dump file */
		print_usage();
		return -1;
	}

	in_fd = open(argv[optind], O_RDONLY);
	if (in_fd < 0) {
		int rc = errno;
		fprintf(stderr, "Could not open dump file %s: %s\n",
			argv[optind], strerror(errno));
		return rc;
	}

	if (out_filename[0] == '\0')
		snprintf(out_filename, sizeof(out_filename), "%s.report",
			 argv[optind]);
	out_fp = fopen(out_filename, "w");
	if (out_fp == NULL) {
		int rc = errno;
		fprintf(stderr, "Could not open output file %s: %s\n",
			out_filename, strerror(errno));
		return rc;
	}

	filesize = fsize(argv[optind]);
	if (filesize < 0) {
		int rc = errno;
		fprintf(stderr, "Could not determine size of %s: %s\n",
			argv[optind], strerror(errno));
		return rc;
	}

	dump_map = mmap(NULL, filesize, PROT_READ, MAP_PRIVATE, in_fd, 0);
	if (dump_map == MAP_FAILED) {
		int rc = errno;
		fprintf(stderr, "Could not map dump file to memory: %s\n",
			strerror(errno));
		return rc;
	}

	read_dump_header(&hdr);
	print_dump_header(&hdr);
	fprintf(out_fp, "\n");

	offset = hdr.first_entry_offset;
	for (i = 0; i < hdr.num_entries; ++i) {
		offset = read_entry_header(&entry_hdr, offset);
		dump_entry_data(&entry_hdr);
	}

	return 0;
}