]>
Commit | Line | Data |
---|---|---|
873b7c85 | 1 | /* |
da23017d NS |
2 | * Copyright (c) 2004-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | |
873b7c85 | 4 | * |
da23017d NS |
5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as | |
873b7c85 GO |
7 | * published by the Free Software Foundation. |
8 | * | |
da23017d NS |
9 | * This program is distributed in the hope that it would be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
873b7c85 | 13 | * |
da23017d NS |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
873b7c85 GO |
17 | */ |
18 | ||
19 | #include "logprint.h" | |
20 | ||
21 | /* | |
22 | * Dump log blocks, not data | |
23 | */ | |
24 | ||
25 | void | |
26 | xfs_log_dump( | |
27 | xlog_t *log, | |
28 | int fd, | |
29 | int print_block_start) | |
30 | { | |
31 | int r; | |
32 | uint last_cycle = -1; | |
33 | xfs_daddr_t blkno, dupblkno; | |
34 | xlog_rec_header_t *hdr; | |
35 | char buf[XLOG_HEADER_SIZE]; | |
36 | ||
37 | dupblkno = 0; | |
38 | hdr = (xlog_rec_header_t *)buf; | |
39 | xlog_print_lseek(log, fd, 0, SEEK_SET); | |
40 | for (blkno = 0; blkno < log->l_logBBsize; blkno++) { | |
41 | r = read(fd, buf, sizeof(buf)); | |
42 | if (r < 0) { | |
9ee7055c | 43 | fprintf(stderr, _("%s: read error (%lld): %s\n"), |
873b7c85 GO |
44 | __FUNCTION__, (long long)blkno, |
45 | strerror(errno)); | |
46 | continue; | |
47 | } else if (r == 0) { | |
9ee7055c | 48 | printf(_("%s: physical end of log at %lld\n"), |
873b7c85 GO |
49 | __FUNCTION__, (long long)blkno); |
50 | break; | |
51 | } | |
52 | ||
5e656dbb | 53 | if (CYCLE_LSN(be64_to_cpu(*(__be64 *)buf)) == |
46eca962 | 54 | XLOG_HEADER_MAGIC_NUM && !print_no_data) { |
9ee7055c AM |
55 | printf(_( |
56 | "%6lld HEADER Cycle %d tail %d:%06d len %6d ops %d\n"), | |
873b7c85 | 57 | (long long)blkno, |
5e656dbb BN |
58 | be32_to_cpu(hdr->h_cycle), |
59 | CYCLE_LSN(be64_to_cpu(hdr->h_tail_lsn)), | |
60 | BLOCK_LSN(be64_to_cpu(hdr->h_tail_lsn)), | |
61 | be32_to_cpu(hdr->h_len), | |
62 | be32_to_cpu(hdr->h_num_logops)); | |
873b7c85 GO |
63 | } |
64 | ||
5e656dbb | 65 | if (xlog_get_cycle(buf) != last_cycle) { |
9ee7055c AM |
66 | printf(_( |
67 | "[%05lld - %05lld] Cycle 0x%08x New Cycle 0x%08x\n"), | |
873b7c85 | 68 | (long long)dupblkno, (long long)blkno, |
5e656dbb BN |
69 | last_cycle, xlog_get_cycle(buf)); |
70 | last_cycle = xlog_get_cycle(buf); | |
873b7c85 GO |
71 | dupblkno = blkno; |
72 | } | |
73 | } | |
74 | } |