]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - logprint/logprint.c
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
42 int print_transactions
;
46 int print_exit
= 1; /* -e is now default. specify -c to override */
54 fprintf(stderr
, "Usage: %s [options...] <device>\n\n\
56 -c try to continue if error found in log\n\
57 -l <device> filename of external log\n\
58 -n don't try and interpret log data\n\
59 -o print buffer data in hex\n\
60 -s <start blk> block # to start printing\n\
61 -v print \"overwrite\" data\n\
62 -t print out transactional view\n\
63 -b in transactional view, extract buffer info\n\
64 -i in transactional view, extract inode info\n\
65 -q in transactional view, extract quota info\n\
66 -D print only data; no decoding\n\
67 -V print version information\n",
73 logstat(libxfs_init_t
*x
)
79 /* On Linux we always read the superblock of the
80 * filesystem. We need this to get the length of the
81 * log. Otherwise we end up seeking forever. -- mkp
83 if ((fd
= open(x
->dname
, O_RDONLY
)) == -1) {
84 fprintf(stderr
, " Can't open device %s: %s\n",
85 x
->dname
, strerror(errno
));
88 lseek64(fd
, 0, SEEK_SET
);
89 if (read(fd
, buf
, sizeof(buf
)) != sizeof(buf
)) {
90 fprintf(stderr
, " read of XFS superblock failed\n");
96 * Conjure up a mount structure
98 libxfs_xlate_sb(buf
, &(mp
.m_sb
), 1, ARCH_CONVERT
, XFS_SB_ALL_BITS
);
100 mp
.m_blkbb_log
= sb
->sb_blocklog
- BBSHIFT
;
102 x
->logBBsize
= XFS_FSB_TO_BB(&mp
, sb
->sb_logblocks
);
103 x
->logBBstart
= XFS_FSB_TO_DADDR(&mp
, sb
->sb_logstart
);
105 if (!x
->logname
&& sb
->sb_logstart
== 0) {
106 fprintf(stderr
, " external log device not specified\n\n");
111 if (x
->logname
&& *x
->logname
) { /* External log */
112 if ((fd
= open(x
->logname
, O_RDONLY
)) == -1) {
113 fprintf(stderr
, "Can't open file %s: %s\n",
114 x
->logname
, strerror(errno
));
118 } else { /* Internal log */
126 main(int argc
, char **argv
)
128 int print_start
= -1;
133 progname
= basename(argv
[0]);
134 while ((c
= getopt(argc
, argv
, "bel:iqnors:tDVvc")) != EOF
) {
151 /* default is to stop on error.
180 print_start
= atoi(optarg
);
184 print_transactions
++;
188 printf("%s version %s\n", progname
, VERSION
);
201 if (argc
- optind
!= 1)
204 x
.dname
= argv
[optind
];
210 x
.isreadonly
= LIBXFS_ISINACTIVE
;
211 x
.notvolmsg
= "You should never see this message.\n";
213 printf("xfs_logprint:\n");
214 if (!libxfs_init(&x
))
219 logfd
=(x
.logfd
<0)?(x
.dfd
):(x
.logfd
);
221 printf(" data device: 0x%llx\n", (unsigned long long)x
.ddev
);
224 printf(" log file: \"%s\" ", x
.logname
);
226 printf(" log device: 0x%llx ", (unsigned long long)x
.logdev
);
229 printf("daddr: %lld length: %lld\n\n",
230 (long long)x
.logBBstart
, (long long)x
.logBBsize
);
232 ASSERT(x
.logBBstart
<= INT_MAX
);
234 /* init log structure */
235 log
.l_dev
= x
.logdev
;
236 log
.l_logsize
= BBTOB(x
.logBBsize
);
237 log
.l_logBBstart
= x
.logBBstart
;
238 log
.l_logBBsize
= x
.logBBsize
;
241 if (print_transactions
)
242 xfs_log_print_trans(&log
, print_start
);
244 xfs_log_print(&log
, logfd
, print_start
);