]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - logprint/logprint.h
cmd/xfs/bmap/Makefile 1.8 Renamed to cmd/xfsprogs/bmap/Makefile
[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 EIO
78 #define XFS_ERROR(e) (e)
79
80 #define xlog_warn(fmt,args...) \
81 ( fprintf(stderr,fmt,## args), fputc('\n', stderr) )
82 #define cmn_err(sev,fmt,args...) \
83 xlog_warn(fmt,## args)
84 #define xlog_exit(fmt,args...) \
85 ( xlog_warn(fmt,## args), exit(1) )
86 #define xlog_panic(fmt,args...) \
87 xlog_exit(fmt,## args)
88
89 #define xlog_get_bp(nbblks, mp) libxfs_getbuf(x.logdev, 0, (nbblks))
90 #define xlog_put_bp(bp) libxfs_putbuf(bp)
91 #define xlog_bread(log,blkno,nbblks,bp) \
92 (libxfs_readbufr(x.logdev, \
93 (log)->l_logBBstart+(blkno), bp, (nbblks), 1), 0)
94
95 #define kmem_zalloc(size, foo) calloc(size,1)
96 #define kmem_free(ptr, foo) free(ptr)
97 #define kmem_realloc(ptr, len, old, foo) realloc(ptr, len)
98
99 /* command line flags */
100 extern int print_data;
101 extern int print_only_data;
102 extern int print_inode;
103 extern int print_quota;
104 extern int print_buffer;
105 extern int print_transactions;
106 extern int print_overwrite;
107
108 extern int print_exit;
109 extern int print_no_data;
110 extern int print_no_print;
111
112 /* exports */
113
114 extern char *trans_type[];
115
116 /* libxfs parameters */
117 extern libxfs_init_t x;
118
119 extern void xfs_log_print_trans(xlog_t *log,
120 int print_block_start);
121
122 extern void xfs_log_print( xlog_t *log,
123 int fd,
124 int print_block_start);
125
126 extern int xlog_find_zeroed(xlog_t *log, xfs_daddr_t *blk_no);
127 extern int xlog_find_cycle_start(xlog_t *log, xfs_buf_t *bp,
128 xfs_daddr_t first_blk, xfs_daddr_t *last_blk, uint cycle);
129 extern int xlog_find_tail(xlog_t *log, xfs_daddr_t *head_blk,
130 xfs_daddr_t *tail_blk, int readonly);
131
132 extern int xlog_test_footer(xlog_t *log);
133 extern int xlog_recover(xlog_t *log, int readonly);
134 extern void xlog_recover_print_data(xfs_caddr_t p, int len);
135 extern void xlog_recover_print_logitem(xlog_recover_item_t *item);
136 extern void xlog_recover_print_trans_head(xlog_recover_t *tr);
137 extern int xlog_print_find_oldest(xlog_t *log, xfs_daddr_t *last_blk);
138
139 extern void print_xlog_op_line(void);
140 extern void print_xlog_record_line(void);
141 extern void print_stars(void);
142
143 /* for transactional view */
144 extern void xlog_recover_print_trans_head(xlog_recover_t *tr);
145
146 extern void xlog_recover_print_trans( xlog_recover_t *trans,
147 xlog_recover_item_t *itemq,
148 int print);
149
150 extern int xlog_do_recovery_pass( xlog_t *log,
151 xfs_daddr_t head_blk,
152 xfs_daddr_t tail_blk,
153 int pass);
154 extern int xlog_recover_do_trans( xlog_t *log,
155 xlog_recover_t *trans,
156 int pass);
157 extern int xlog_header_check_recover( xfs_mount_t *mp,
158 xlog_rec_header_t *head);
159 extern int xlog_header_check_mount( xfs_mount_t *mp,
160 xlog_rec_header_t *head);
161
162 #endif /* XFS_LOGPRINT_H */