1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
7 #ifndef _XFS_REPAIR_BMAP_H
8 #define _XFS_REPAIR_BMAP_H
13 typedef struct bmap_ext
{
14 xfs_fileoff_t startoff
;
15 xfs_fsblock_t startblock
;
16 xfs_filblks_t blockcount
;
22 typedef struct blkmap
{
28 #define BLKMAP_SIZE(n) \
29 (offsetof(blkmap_t, exts) + (sizeof(bmap_ext_t) * (n)))
32 * For 32 bit platforms, we are limited to extent arrays of 2^31 bytes, which
33 * limits the number of extents in an inode we can check. If we don't limit the
34 * valid range, we can overflow the BLKMAP_SIZE() calculation and allocate less
35 * memory than we think we needed, and hence walk off the end of the array and
38 #if BITS_PER_LONG == 32
39 #define BLKMAP_NEXTS_MAX ((INT_MAX / sizeof(bmap_ext_t)) - 1)
41 #define BLKMAP_NEXTS_MAX INT_MAX
44 extern pthread_key_t dblkmap_key
;
45 extern pthread_key_t ablkmap_key
;
47 blkmap_t
*blkmap_alloc(xfs_extnum_t nex
, int whichfork
);
48 void blkmap_free(blkmap_t
*blkmap
);
49 void blkmap_free_final(void);
51 int blkmap_set_ext(blkmap_t
**blkmapp
, xfs_fileoff_t o
,
52 xfs_fsblock_t b
, xfs_filblks_t c
);
54 xfs_fsblock_t
blkmap_get(blkmap_t
*blkmap
, xfs_fileoff_t o
);
55 int blkmap_getn(blkmap_t
*blkmap
, xfs_fileoff_t o
,
56 xfs_filblks_t nb
, bmap_ext_t
**bmpp
,
57 bmap_ext_t
*bmpp_single
);
58 xfs_fileoff_t
blkmap_last_off(blkmap_t
*blkmap
);
59 xfs_fileoff_t
blkmap_next_off(blkmap_t
*blkmap
, xfs_fileoff_t o
, int *t
);
61 #endif /* _XFS_REPAIR_BMAP_H */