]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - logprint/log_dump.c
xfs_io: support passing the FORCE_REBUILD flag to online repair
[thirdparty/xfsprogs-dev.git] / logprint / log_dump.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6 #include "libxfs.h"
7 #include "libxlog.h"
8
9 #include "logprint.h"
10
11 /*
12 * Dump log blocks, not data
13 */
14
15 void
16 xfs_log_dump(
17 struct xlog *log,
18 int fd,
19 int print_block_start)
20 {
21 int r;
22 uint last_cycle = -1;
23 xfs_daddr_t blkno, dupblkno;
24 xlog_rec_header_t *hdr;
25 char buf[XLOG_HEADER_SIZE];
26
27 dupblkno = 0;
28 hdr = (xlog_rec_header_t *)buf;
29 xlog_print_lseek(log, fd, 0, SEEK_SET);
30 for (blkno = 0; blkno < log->l_logBBsize; blkno++) {
31 r = read(fd, buf, sizeof(buf));
32 if (r < 0) {
33 fprintf(stderr, _("%s: read error (%lld): %s\n"),
34 __FUNCTION__, (long long)blkno,
35 strerror(errno));
36 continue;
37 } else if (r == 0) {
38 printf(_("%s: physical end of log at %lld\n"),
39 __FUNCTION__, (long long)blkno);
40 break;
41 }
42
43 if (CYCLE_LSN(be64_to_cpu(*(__be64 *)buf)) ==
44 XLOG_HEADER_MAGIC_NUM && !print_no_data) {
45 printf(_(
46 "%6lld HEADER Cycle %d tail %d:%06d len %6d ops %d\n"),
47 (long long)blkno,
48 be32_to_cpu(hdr->h_cycle),
49 CYCLE_LSN(be64_to_cpu(hdr->h_tail_lsn)),
50 BLOCK_LSN(be64_to_cpu(hdr->h_tail_lsn)),
51 be32_to_cpu(hdr->h_len),
52 be32_to_cpu(hdr->h_num_logops));
53 }
54
55 if (xlog_get_cycle(buf) != last_cycle) {
56 printf(_(
57 "[%05lld - %05lld] Cycle 0x%08x New Cycle 0x%08x\n"),
58 (long long)dupblkno, (long long)blkno,
59 last_cycle, xlog_get_cycle(buf));
60 last_cycle = xlog_get_cycle(buf);
61 dupblkno = blkno;
62 }
63 }
64 }