]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - logprint/log_dump.c
xfs_repair: only update in-core extent state after scanning full extent
[thirdparty/xfsprogs-dev.git] / logprint / log_dump.c
1 /*
2 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
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
7 * published by the Free Software Foundation.
8 *
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.
13 *
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
17 */
18 #include "libxfs.h"
19 #include "libxlog.h"
20
21 #include "logprint.h"
22
23 /*
24 * Dump log blocks, not data
25 */
26
27 void
28 xfs_log_dump(
29 struct xlog *log,
30 int fd,
31 int print_block_start)
32 {
33 int r;
34 uint last_cycle = -1;
35 xfs_daddr_t blkno, dupblkno;
36 xlog_rec_header_t *hdr;
37 char buf[XLOG_HEADER_SIZE];
38
39 dupblkno = 0;
40 hdr = (xlog_rec_header_t *)buf;
41 xlog_print_lseek(log, fd, 0, SEEK_SET);
42 for (blkno = 0; blkno < log->l_logBBsize; blkno++) {
43 r = read(fd, buf, sizeof(buf));
44 if (r < 0) {
45 fprintf(stderr, _("%s: read error (%lld): %s\n"),
46 __FUNCTION__, (long long)blkno,
47 strerror(errno));
48 continue;
49 } else if (r == 0) {
50 printf(_("%s: physical end of log at %lld\n"),
51 __FUNCTION__, (long long)blkno);
52 break;
53 }
54
55 if (CYCLE_LSN(be64_to_cpu(*(__be64 *)buf)) ==
56 XLOG_HEADER_MAGIC_NUM && !print_no_data) {
57 printf(_(
58 "%6lld HEADER Cycle %d tail %d:%06d len %6d ops %d\n"),
59 (long long)blkno,
60 be32_to_cpu(hdr->h_cycle),
61 CYCLE_LSN(be64_to_cpu(hdr->h_tail_lsn)),
62 BLOCK_LSN(be64_to_cpu(hdr->h_tail_lsn)),
63 be32_to_cpu(hdr->h_len),
64 be32_to_cpu(hdr->h_num_logops));
65 }
66
67 if (xlog_get_cycle(buf) != last_cycle) {
68 printf(_(
69 "[%05lld - %05lld] Cycle 0x%08x New Cycle 0x%08x\n"),
70 (long long)dupblkno, (long long)blkno,
71 last_cycle, xlog_get_cycle(buf));
72 last_cycle = xlog_get_cycle(buf);
73 dupblkno = blkno;
74 }
75 }
76 }