]>
Commit | Line | Data |
---|---|---|
959ef981 | 1 | // SPDX-License-Identifier: GPL-2.0 |
873b7c85 | 2 | /* |
da23017d NS |
3 | * Copyright (c) 2004-2005 Silicon Graphics, Inc. |
4 | * All Rights Reserved. | |
873b7c85 | 5 | */ |
6b803e5a CH |
6 | #include "libxfs.h" |
7 | #include "libxlog.h" | |
873b7c85 GO |
8 | |
9 | #include "logprint.h" | |
10 | ||
11 | /* | |
12 | * Dump log blocks, not data | |
13 | */ | |
14 | ||
15 | void | |
16 | xfs_log_dump( | |
999f0b9c | 17 | struct xlog *log, |
873b7c85 GO |
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) { | |
9ee7055c | 33 | fprintf(stderr, _("%s: read error (%lld): %s\n"), |
873b7c85 GO |
34 | __FUNCTION__, (long long)blkno, |
35 | strerror(errno)); | |
36 | continue; | |
37 | } else if (r == 0) { | |
9ee7055c | 38 | printf(_("%s: physical end of log at %lld\n"), |
873b7c85 GO |
39 | __FUNCTION__, (long long)blkno); |
40 | break; | |
41 | } | |
42 | ||
5e656dbb | 43 | if (CYCLE_LSN(be64_to_cpu(*(__be64 *)buf)) == |
46eca962 | 44 | XLOG_HEADER_MAGIC_NUM && !print_no_data) { |
9ee7055c AM |
45 | printf(_( |
46 | "%6lld HEADER Cycle %d tail %d:%06d len %6d ops %d\n"), | |
873b7c85 | 47 | (long long)blkno, |
5e656dbb BN |
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)); | |
873b7c85 GO |
53 | } |
54 | ||
5e656dbb | 55 | if (xlog_get_cycle(buf) != last_cycle) { |
9ee7055c AM |
56 | printf(_( |
57 | "[%05lld - %05lld] Cycle 0x%08x New Cycle 0x%08x\n"), | |
873b7c85 | 58 | (long long)dupblkno, (long long)blkno, |
5e656dbb BN |
59 | last_cycle, xlog_get_cycle(buf)); |
60 | last_cycle = xlog_get_cycle(buf); | |
873b7c85 GO |
61 | dupblkno = blkno; |
62 | } | |
63 | } | |
64 | } |