]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - logprint/logprint.h
bump minor version number.
[thirdparty/xfsprogs-dev.git] / logprint / logprint.h
1 /*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
3 *
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.
7 *
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.
11 *
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.
18 *
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.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32 #ifndef XFS_LOGPRINT_H
33 #define XFS_LOGPRINT_H
34
35 #include <libxfs.h>
36 #include <string.h>
37 #include <errno.h>
38
39 /*
40 * define the userlevel xlog_t to be the subset of the kernel's
41 * xlog_t that we actually need to get our work done, avoiding
42 * the need to define any exotic kernel types in userland.
43 */
44 typedef struct log {
45 xfs_lsn_t l_tail_lsn; /* lsn of 1st LR w/ unflush buffers */
46 xfs_lsn_t l_last_sync_lsn;/* lsn of last LR on disk */
47 xfs_mount_t *l_mp; /* mount point */
48 dev_t l_dev; /* dev_t of log */
49 xfs_daddr_t l_logBBstart; /* start block of log */
50 int l_logsize; /* size of log in bytes */
51 int l_logBBsize; /* size of log in 512 byte chunks */
52 int l_roundoff; /* round off error of all iclogs */
53 int l_curr_cycle; /* Cycle number of log writes */
54 int l_prev_cycle; /* Cycle # b4 last block increment */
55 int l_curr_block; /* current logical block of log */
56 int l_prev_block; /* previous logical block of log */
57 int l_iclog_size; /* size of log in bytes */
58 int l_iclog_size_log;/* log power size of log */
59 int l_iclog_bufs; /* number of iclog buffers */
60 int l_grant_reserve_cycle; /* */
61 int l_grant_reserve_bytes; /* */
62 int l_grant_write_cycle; /* */
63 int l_grant_write_bytes; /* */
64 } xlog_t;
65
66 #include <xfs_log_recover.h>
67 #include <xfs_buf_item.h>
68 #include <xfs_inode_item.h>
69 #include <xfs_extfree_item.h>
70 #include <xfs_dquot_item.h>
71
72
73 /*
74 * macros mapping kernel code to user code
75 */
76 #define STATIC static
77 #define EFSCORRUPTED 990
78 #define XFS_ERROR(e) (e)
79
80 #if (__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 95))
81 # define xlog_warn(fmt,args...) \
82 ( fprintf(stderr,fmt,## args), fputc('\n', stderr) )
83 # define cmn_err(sev,fmt,args...) \
84 xlog_warn(fmt,## args)
85 # define xlog_exit(fmt,args...) \
86 ( xlog_warn(fmt,## args), exit(1) )
87 # define xlog_panic(fmt,args...) \
88 xlog_exit(fmt,## args)
89 #else
90 # define xlog_warn(...) \
91 ( fprintf(stderr,__VA_ARGS__), fputc('\n', stderr) )
92 # define cmn_err(sev,...) \
93 xlog_warn(__VA_ARGS__)
94 # define xlog_exit(...) \
95 ( xlog_warn(__VA_ARGS__), exit(1) )
96 # define xlog_panic(...) \
97 xlog_exit(__VA_ARGS__)
98 #endif
99
100 #define xlog_get_bp(nbblks, mp) libxfs_getbuf(x.logdev, 0, (nbblks))
101 #define xlog_put_bp(bp) libxfs_putbuf(bp)
102 #define xlog_bread(log,blkno,nbblks,bp) \
103 (libxfs_readbufr(x.logdev, \
104 (log)->l_logBBstart+(blkno), bp, (nbblks), 1), 0)
105
106 #define kmem_zalloc(size, foo) calloc(size,1)
107 #define kmem_free(ptr, foo) free(ptr)
108 #define kmem_realloc(ptr, len, old, foo) realloc(ptr, len)
109
110 /* command line flags */
111 extern int print_data;
112 extern int print_only_data;
113 extern int print_inode;
114 extern int print_quota;
115 extern int print_buffer;
116 extern int print_transactions;
117 extern int print_overwrite;
118
119 extern int print_exit;
120 extern int print_no_data;
121 extern int print_no_print;
122
123 /* exports */
124
125 extern char *trans_type[];
126
127 /* libxfs parameters */
128 extern libxfs_init_t x;
129
130 extern void xfs_log_print_trans(xlog_t *log,
131 int print_block_start);
132
133 extern void xfs_log_print( xlog_t *log,
134 int fd,
135 int print_block_start);
136
137 extern int xlog_find_zeroed(xlog_t *log, xfs_daddr_t *blk_no);
138 extern int xlog_find_cycle_start(xlog_t *log, xfs_buf_t *bp,
139 xfs_daddr_t first_blk, xfs_daddr_t *last_blk, uint cycle);
140 extern int xlog_find_tail(xlog_t *log, xfs_daddr_t *head_blk,
141 xfs_daddr_t *tail_blk, int readonly);
142
143 extern int xlog_test_footer(xlog_t *log);
144 extern int xlog_recover(xlog_t *log, int readonly);
145 extern void xlog_recover_print_data(xfs_caddr_t p, int len);
146 extern void xlog_recover_print_logitem(xlog_recover_item_t *item);
147 extern void xlog_recover_print_trans_head(xlog_recover_t *tr);
148 extern int xlog_print_find_oldest(xlog_t *log, xfs_daddr_t *last_blk);
149
150 extern void print_xlog_op_line(void);
151 extern void print_xlog_record_line(void);
152 extern void print_stars(void);
153
154 /* for transactional view */
155 extern void xlog_recover_print_trans_head(xlog_recover_t *tr);
156
157 extern void xlog_recover_print_trans( xlog_recover_t *trans,
158 xlog_recover_item_t *itemq,
159 int print);
160
161 extern int xlog_do_recovery_pass( xlog_t *log,
162 xfs_daddr_t head_blk,
163 xfs_daddr_t tail_blk,
164 int pass);
165 extern int xlog_recover_do_trans( xlog_t *log,
166 xlog_recover_t *trans,
167 int pass);
168 extern int xlog_header_check_recover( xfs_mount_t *mp,
169 xlog_rec_header_t *head);
170 extern int xlog_header_check_mount( xfs_mount_t *mp,
171 xlog_rec_header_t *head);
172
173 #endif /* XFS_LOGPRINT_H */