]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/libxlog.h
Update copyright dates
[thirdparty/xfsprogs-dev.git] / include / libxlog.h
1 /*
2 * Copyright (c) 2000-2001 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 LIBXLOG_H
33 #define LIBXLOG_H
34
35 #include <libxfs.h>
36
37 /*
38 * define the userlevel xlog_t to be the subset of the kernel's
39 * xlog_t that we actually need to get our work done, avoiding
40 * the need to define any exotic kernel types in userland.
41 */
42 typedef struct log {
43 xfs_lsn_t l_tail_lsn; /* lsn of 1st LR w/ unflush buffers */
44 xfs_lsn_t l_last_sync_lsn;/* lsn of last LR on disk */
45 xfs_mount_t *l_mp; /* mount point */
46 dev_t l_dev; /* dev_t of log */
47 xfs_daddr_t l_logBBstart; /* start block of log */
48 int l_logsize; /* size of log in bytes */
49 int l_logBBsize; /* size of log in 512 byte chunks */
50 int l_curr_cycle; /* Cycle number of log writes */
51 int l_prev_cycle; /* Cycle # b4 last block increment */
52 int l_curr_block; /* current logical block of log */
53 int l_prev_block; /* previous logical block of log */
54 int l_iclog_size; /* size of log in bytes */
55 int l_iclog_size_log;/* log power size of log */
56 int l_iclog_bufs; /* number of iclog buffers */
57 int l_grant_reserve_cycle; /* */
58 int l_grant_reserve_bytes; /* */
59 int l_grant_write_cycle; /* */
60 int l_grant_write_bytes; /* */
61 } xlog_t;
62
63 #include <xfs_log_recover.h>
64 #include <xfs_buf_item.h>
65 #include <xfs_inode_item.h>
66 #include <xfs_extfree_item.h>
67 #include <xfs_dquot_item.h>
68
69
70 /*
71 * macros mapping kernel code to user code
72 */
73 #define STATIC static
74 #define EFSCORRUPTED 990
75 #define XFS_ERROR(e) (e)
76 #define min(a,b) ((a) < (b) ? (a) : (b))
77
78 #if (__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 95))
79 # define xlog_warn(fmt,args...) \
80 ( fprintf(stderr,fmt,## args), fputc('\n', stderr) )
81 # define cmn_err(sev,fmt,args...) \
82 xlog_warn(fmt,## args)
83 # define xlog_exit(fmt,args...) \
84 ( xlog_warn(fmt,## args), exit(1) )
85 # define xlog_panic(fmt,args...) \
86 xlog_exit(fmt,## args)
87 #else
88 # define xlog_warn(...) \
89 ( fprintf(stderr,__VA_ARGS__), fputc('\n', stderr) )
90 # define cmn_err(sev,...) \
91 xlog_warn(__VA_ARGS__)
92 # define xlog_exit(...) \
93 ( xlog_warn(__VA_ARGS__), exit(1) )
94 # define xlog_panic(...) \
95 xlog_exit(__VA_ARGS__)
96 #endif
97
98 #define xlog_get_bp(nbblks, mp) libxfs_getbuf(x.logdev, 0, (nbblks))
99 #define xlog_put_bp(bp) libxfs_putbuf(bp)
100 #define xlog_bread(log,blkno,nbblks,bp) \
101 (libxfs_readbufr(x.logdev, \
102 (log)->l_logBBstart+(blkno), bp, (nbblks), 1), 0)
103
104 #define kmem_zalloc(size, foo) calloc(size,1)
105 #define kmem_free(ptr, foo) free(ptr)
106 #define kmem_realloc(ptr, len, old, foo) realloc(ptr, len)
107
108 /* exports */
109 extern int print_record_header;
110 extern int print_exit;
111
112 /* libxfs parameters */
113 extern libxfs_init_t x;
114
115 extern void xfs_log_print_trans(xlog_t *log,
116 int print_block_start);
117
118 extern void xfs_log_print( xlog_t *log,
119 int fd,
120 int print_block_start);
121
122 extern int xlog_find_zeroed(xlog_t *log, xfs_daddr_t *blk_no);
123 extern int xlog_find_cycle_start(xlog_t *log, xfs_buf_t *bp,
124 xfs_daddr_t first_blk, xfs_daddr_t *last_blk, uint cycle);
125 extern int xlog_find_tail(xlog_t *log, xfs_daddr_t *head_blk,
126 xfs_daddr_t *tail_blk, int readonly);
127
128 extern int xlog_test_footer(xlog_t *log);
129 extern int xlog_recover(xlog_t *log, int readonly);
130 extern void xlog_recover_print_data(xfs_caddr_t p, int len);
131 extern void xlog_recover_print_logitem(xlog_recover_item_t *item);
132 extern void xlog_recover_print_trans_head(xlog_recover_t *tr);
133 extern int xlog_print_find_oldest(xlog_t *log, xfs_daddr_t *last_blk);
134
135 extern void print_xlog_op_line(void);
136 extern void print_xlog_record_line(void);
137 extern void print_stars(void);
138
139 /* for transactional view */
140 extern void xlog_recover_print_trans_head(xlog_recover_t *tr);
141
142 extern void xlog_recover_print_trans( xlog_recover_t *trans,
143 xlog_recover_item_t *itemq,
144 int print);
145
146 extern int xlog_do_recovery_pass( xlog_t *log,
147 xfs_daddr_t head_blk,
148 xfs_daddr_t tail_blk,
149 int pass);
150 extern int xlog_recover_do_trans( xlog_t *log,
151 xlog_recover_t *trans,
152 int pass);
153 extern int xlog_header_check_recover( xfs_mount_t *mp,
154 xlog_rec_header_t *head);
155 extern int xlog_header_check_mount( xfs_mount_t *mp,
156 xlog_rec_header_t *head);
157
158 #endif /* LIBXLOG_H */