]>
Commit | Line | Data |
---|---|---|
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 | ||
610f3285 BN |
19 | #ifndef _XFS_REPAIR_BMAP_H |
20 | #define _XFS_REPAIR_BMAP_H | |
2bd0ea18 NS |
21 | |
22 | /* | |
610f3285 | 23 | * Extent descriptor. |
2bd0ea18 | 24 | */ |
610f3285 | 25 | typedef struct bmap_ext { |
5a35bf2c DC |
26 | xfs_fileoff_t startoff; |
27 | xfs_fsblock_t startblock; | |
28 | xfs_filblks_t blockcount; | |
610f3285 | 29 | } bmap_ext_t; |
2bd0ea18 NS |
30 | |
31 | /* | |
32 | * Block map. | |
33 | */ | |
34 | typedef struct blkmap { | |
610f3285 BN |
35 | int naexts; |
36 | int nexts; | |
37 | bmap_ext_t exts[1]; | |
2bd0ea18 | 38 | } blkmap_t; |
2bd0ea18 | 39 | |
610f3285 BN |
40 | #define BLKMAP_SIZE(n) \ |
41 | (offsetof(blkmap_t, exts) + (sizeof(bmap_ext_t) * (n))) | |
2bd0ea18 | 42 | |
df63c43b DC |
43 | /* |
44 | * For 32 bit platforms, we are limited to extent arrays of 2^31 bytes, which | |
45 | * limits the number of extents in an inode we can check. If we don't limit the | |
46 | * valid range, we can overflow the BLKMAP_SIZE() calculation and allocate less | |
47 | * memory than we think we needed, and hence walk off the end of the array and | |
48 | * corrupt memory. | |
49 | */ | |
50 | #if BITS_PER_LONG == 32 | |
51 | #define BLKMAP_NEXTS_MAX ((INT_MAX / sizeof(bmap_ext_t)) - 1) | |
52 | #else | |
53 | #define BLKMAP_NEXTS_MAX INT_MAX | |
54 | #endif | |
55 | ||
52cb19dc CH |
56 | extern pthread_key_t dblkmap_key; |
57 | extern pthread_key_t ablkmap_key; | |
58 | ||
610f3285 | 59 | blkmap_t *blkmap_alloc(xfs_extnum_t nex, int whichfork); |
2bd0ea18 | 60 | void blkmap_free(blkmap_t *blkmap); |
bd758142 | 61 | void blkmap_free_final(void); |
610f3285 | 62 | |
5a35bf2c DC |
63 | int blkmap_set_ext(blkmap_t **blkmapp, xfs_fileoff_t o, |
64 | xfs_fsblock_t b, xfs_filblks_t c); | |
610f3285 | 65 | |
5a35bf2c DC |
66 | xfs_fsblock_t blkmap_get(blkmap_t *blkmap, xfs_fileoff_t o); |
67 | int blkmap_getn(blkmap_t *blkmap, xfs_fileoff_t o, | |
68 | xfs_filblks_t nb, bmap_ext_t **bmpp, | |
1e77098c | 69 | bmap_ext_t *bmpp_single); |
5a35bf2c DC |
70 | xfs_fileoff_t blkmap_last_off(blkmap_t *blkmap); |
71 | xfs_fileoff_t blkmap_next_off(blkmap_t *blkmap, xfs_fileoff_t o, int *t); | |
610f3285 BN |
72 | |
73 | #endif /* _XFS_REPAIR_BMAP_H */ |