]>
Commit | Line | Data |
---|---|---|
873b7c85 GO |
1 | /* |
2 | * Copyright (c) 2004 Silicon Graphics, Inc. All Rights Reserved. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of version 2 of the GNU General Public License as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it would be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
11 | * | |
12 | * Further, this software is distributed without any warranty that it is | |
13 | * free of the rightful claim of any third person regarding infringement | |
14 | * or the like. Any license provided herein, whether implied or | |
15 | * otherwise, applies only to this software file. Patent licenses, if | |
16 | * any, provided herein do not apply to combinations of this program with | |
17 | * other software, or any other product whatsoever. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License along | |
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | |
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | |
22 | * | |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | |
24 | * Mountain View, CA 94043, or: | |
25 | * | |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | |
31 | */ | |
32 | ||
33 | #include "logprint.h" | |
34 | ||
35 | /* | |
36 | * Dump log blocks, not data | |
37 | */ | |
38 | ||
39 | void | |
40 | xfs_log_dump( | |
41 | xlog_t *log, | |
42 | int fd, | |
43 | int print_block_start) | |
44 | { | |
45 | int r; | |
46 | uint last_cycle = -1; | |
47 | xfs_daddr_t blkno, dupblkno; | |
48 | xlog_rec_header_t *hdr; | |
49 | char buf[XLOG_HEADER_SIZE]; | |
50 | ||
51 | dupblkno = 0; | |
52 | hdr = (xlog_rec_header_t *)buf; | |
53 | xlog_print_lseek(log, fd, 0, SEEK_SET); | |
54 | for (blkno = 0; blkno < log->l_logBBsize; blkno++) { | |
55 | r = read(fd, buf, sizeof(buf)); | |
56 | if (r < 0) { | |
57 | fprintf(stderr, "%s: read error (%lld): %s\n", | |
58 | __FUNCTION__, (long long)blkno, | |
59 | strerror(errno)); | |
60 | continue; | |
61 | } else if (r == 0) { | |
62 | printf("%s: physical end of log at %lld\n", | |
63 | __FUNCTION__, (long long)blkno); | |
64 | break; | |
65 | } | |
66 | ||
67 | if (CYCLE_LSN(buf, ARCH_CONVERT) == XLOG_HEADER_MAGIC_NUM && | |
68 | !print_no_data) { | |
69 | printf( | |
70 | "%6lld HEADER Cycle %d tail %d:%06d len %6d ops %d\n", | |
71 | (long long)blkno, | |
72 | INT_GET(hdr->h_cycle, ARCH_CONVERT), | |
73 | CYCLE_LSN(hdr->h_tail_lsn, ARCH_CONVERT), | |
74 | BLOCK_LSN(hdr->h_tail_lsn, ARCH_CONVERT), | |
75 | INT_GET(hdr->h_len, ARCH_CONVERT), | |
76 | INT_GET(hdr->h_num_logops, ARCH_CONVERT)); | |
77 | } | |
78 | ||
79 | if (GET_CYCLE(buf, ARCH_CONVERT) != last_cycle) { | |
80 | printf( | |
81 | "[%05lld - %05lld] Cycle 0x%08x New Cycle 0x%08x\n", | |
82 | (long long)dupblkno, (long long)blkno, | |
83 | last_cycle, GET_CYCLE(buf, ARCH_CONVERT)); | |
84 | last_cycle = GET_CYCLE(buf, ARCH_CONVERT); | |
85 | dupblkno = blkno; | |
86 | } | |
87 | } | |
88 | } |