]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - db/io.h
misc: fix Coverity errors
[thirdparty/xfsprogs-dev.git] / db / io.h
CommitLineData
2bd0ea18 1/*
da23017d
NS
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
dfc130f3 4 *
da23017d
NS
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
2bd0ea18 7 * published by the Free Software Foundation.
dfc130f3 8 *
da23017d
NS
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
dfc130f3 13 *
da23017d
NS
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2bd0ea18
NS
17 */
18
19struct typ;
20
21#define BBMAP_SIZE (XFS_MAX_BLOCKSIZE / BBSIZE)
22typedef struct bbmap {
48e32b40
DC
23 int nmaps;
24 struct xfs_buf_map b[BBMAP_SIZE];
2bd0ea18
NS
25} bbmap_t;
26
27typedef struct iocur {
28 __int64_t bb; /* BB number in filesystem of buf */
29 int blen; /* length of "buf", bb's */
30 int boff; /* data - buf */
31 void *buf; /* base address of buffer */
32 void *data; /* current interesting data */
33 xfs_ino_t dirino; /* current directory inode number */
34 xfs_ino_t ino; /* current inode number */
35 int len; /* length of "data", bytes */
36 __uint16_t mode; /* current inode's mode */
37 xfs_off_t off; /* fs offset of "data" in bytes */
38 const struct typ *typ; /* type of "data" */
72298d16
DC
39 bbmap_t *bbmap; /* map daddr if fragmented */
40 struct xfs_buf *bp; /* underlying buffer */
a73b88f2
DC
41 int ino_crc_ok:1;
42 int ino_buf:1;
66a40d02 43 int dquot_buf:1;
fd491857 44 int need_crc:1;
2bd0ea18
NS
45} iocur_t;
46
47#define DB_RING_ADD 1 /* add to ring on set_cur */
48#define DB_RING_IGN 0 /* do not add to ring on set_cur */
49
50extern iocur_t *iocur_base; /* base of stack */
51extern iocur_t *iocur_top; /* top element of stack */
52extern int iocur_sp; /* current top of stack */
53extern int iocur_len; /* length of stack array */
54
55extern void io_init(void);
56extern void off_cur(int off, int len);
57extern void pop_cur(void);
58extern void print_iocur(char *tag, iocur_t *ioc);
59extern void push_cur(void);
2a8b3fdf 60extern int read_buf(__int64_t daddr, int count, void *bufp);
2bd0ea18
NS
61extern void write_cur(void);
62extern void set_cur(const struct typ *t, __int64_t d, int c, int ring_add,
63 bbmap_t *bbmap);
64extern void ring_add(void);
9ba69ce2 65extern void set_iocur_type(const struct typ *t);
c9f5e3db 66extern void xfs_dummy_verify(struct xfs_buf *bp);
86769b32 67extern void xfs_verify_recalc_crc(struct xfs_buf *bp);
0522f1cc 68
b511ff41
DC
69/*
70 * returns -1 for unchecked, 0 for bad and 1 for good
71 */
72static inline int
0522f1cc
DC
73iocur_crc_valid()
74{
b511ff41
DC
75 if (!iocur_top->bp)
76 return -1;
77 if (iocur_top->bp->b_flags & LIBXFS_B_UNCHECKED)
78 return -1;
66fc04e0 79 return (iocur_top->bp->b_error != -EFSBADCRC &&
a73b88f2 80 (!iocur_top->ino_buf || iocur_top->ino_crc_ok));
0522f1cc 81}