]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/libxlog.h
zero more at end of device at mkfs time, be sure to
[thirdparty/xfsprogs-dev.git] / include / libxlog.h
CommitLineData
d321ceac 1/*
93d9f139 2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
d321ceac
NS
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
2e542de0 35#include <xfs/libxfs.h>
d321ceac
NS
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 */
42typedef 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; /* */
a562a63b 61 uint l_sectbb_log; /* log2 of sector size in bbs */
d321ceac
NS
62} xlog_t;
63
2e542de0
NS
64#include <xfs/xfs_log_recover.h>
65#include <xfs/xfs_buf_item.h>
66#include <xfs/xfs_inode_item.h>
67#include <xfs/xfs_extfree_item.h>
d321ceac 68
a562a63b
NS
69typedef union {
70 xlog_rec_header_t hic_header;
71 xlog_rec_ext_header_t hic_xheader;
72 char hic_sector[XLOG_HEADER_SIZE];
73} xlog_in_core_2_t;
74
d321ceac
NS
75/*
76 * macros mapping kernel code to user code
77 */
93d9f139 78#ifndef EFSCORRUPTED
dfc130f3 79#define EFSCORRUPTED 990
93d9f139 80#endif
4ca431fc 81#define STATIC static
4ca431fc 82#define XFS_ERROR(e) (e)
dc0bd4a0 83#ifdef DEBUG
84#define XFS_ERROR_REPORT(e,l,mp) fprintf(stderr, "ERROR: %s\n", e)
85#else
4ca431fc 86#define XFS_ERROR_REPORT(e,l,mp) ((void) 0)
dc0bd4a0 87#endif
4ca431fc
NS
88#define XFS_CORRUPTION_ERROR(e,l,mp,m) ((void) 0)
89#define unlikely(x) (x)
90#define min(a,b) ((a) < (b) ? (a) : (b))
d321ceac
NS
91
92#if (__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 95))
93# define xlog_warn(fmt,args...) \
94 ( fprintf(stderr,fmt,## args), fputc('\n', stderr) )
95# define cmn_err(sev,fmt,args...) \
96 xlog_warn(fmt,## args)
97# define xlog_exit(fmt,args...) \
98 ( xlog_warn(fmt,## args), exit(1) )
99# define xlog_panic(fmt,args...) \
100 xlog_exit(fmt,## args)
101#else
102# define xlog_warn(...) \
103 ( fprintf(stderr,__VA_ARGS__), fputc('\n', stderr) )
104# define cmn_err(sev,...) \
105 xlog_warn(__VA_ARGS__)
106# define xlog_exit(...) \
107 ( xlog_warn(__VA_ARGS__), exit(1) )
108# define xlog_panic(...) \
109 xlog_exit(__VA_ARGS__)
110#endif
111
a562a63b 112#define xlog_get_bp(log,bbs) libxfs_getbuf(x.logdev, 0, (bbs))
d321ceac 113#define xlog_put_bp(bp) libxfs_putbuf(bp)
a562a63b 114#define xlog_bread(log,blkno,bbs,bp) \
d321ceac 115 (libxfs_readbufr(x.logdev, \
a562a63b
NS
116 (log)->l_logBBstart+(blkno), bp, (bbs), 1), 0)
117#define xlog_align(log,blkno,nbblks,bp) XFS_BUF_PTR(bp)
dfc130f3 118
d321ceac 119#define kmem_zalloc(size, foo) calloc(size,1)
a562a63b 120#define kmem_alloc(size, foo) calloc(size,1)
d321ceac
NS
121#define kmem_free(ptr, foo) free(ptr)
122#define kmem_realloc(ptr, len, old, foo) realloc(ptr, len)
123
124/* exports */
125extern int print_record_header;
126extern int print_exit;
127
128/* libxfs parameters */
129extern libxfs_init_t x;
130
131extern void xfs_log_print_trans(xlog_t *log,
132 int print_block_start);
133
134extern void xfs_log_print( xlog_t *log,
dfc130f3 135 int fd,
d321ceac
NS
136 int print_block_start);
137
138extern int xlog_find_zeroed(xlog_t *log, xfs_daddr_t *blk_no);
139extern int xlog_find_cycle_start(xlog_t *log, xfs_buf_t *bp,
140 xfs_daddr_t first_blk, xfs_daddr_t *last_blk, uint cycle);
141extern int xlog_find_tail(xlog_t *log, xfs_daddr_t *head_blk,
142 xfs_daddr_t *tail_blk, int readonly);
143
144extern int xlog_test_footer(xlog_t *log);
145extern int xlog_recover(xlog_t *log, int readonly);
146extern void xlog_recover_print_data(xfs_caddr_t p, int len);
147extern void xlog_recover_print_logitem(xlog_recover_item_t *item);
148extern void xlog_recover_print_trans_head(xlog_recover_t *tr);
149extern int xlog_print_find_oldest(xlog_t *log, xfs_daddr_t *last_blk);
150
151extern void print_xlog_op_line(void);
152extern void print_xlog_record_line(void);
153extern void print_stars(void);
154
155/* for transactional view */
156extern void xlog_recover_print_trans_head(xlog_recover_t *tr);
157
158extern void xlog_recover_print_trans( xlog_recover_t *trans,
159 xlog_recover_item_t *itemq,
160 int print);
161
162extern int xlog_do_recovery_pass( xlog_t *log,
163 xfs_daddr_t head_blk,
164 xfs_daddr_t tail_blk,
165 int pass);
166extern int xlog_recover_do_trans( xlog_t *log,
167 xlog_recover_t *trans,
168 int pass);
dfc130f3
RC
169extern int xlog_header_check_recover( xfs_mount_t *mp,
170 xlog_rec_header_t *head);
171extern int xlog_header_check_mount( xfs_mount_t *mp,
172 xlog_rec_header_t *head);
d321ceac
NS
173
174#endif /* LIBXLOG_H */