b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
| 4 | * All Rights Reserved. |
| 5 | */ |
| 6 | #ifndef __XFS_DIR2_PRIV_H__ |
| 7 | #define __XFS_DIR2_PRIV_H__ |
| 8 | |
| 9 | struct dir_context; |
| 10 | |
| 11 | /* |
| 12 | * In-core version of the leaf and free block headers to abstract the |
| 13 | * differences in the v2 and v3 disk format of the headers. |
| 14 | */ |
| 15 | struct xfs_dir3_icleaf_hdr { |
| 16 | uint32_t forw; |
| 17 | uint32_t back; |
| 18 | uint16_t magic; |
| 19 | uint16_t count; |
| 20 | uint16_t stale; |
| 21 | }; |
| 22 | |
| 23 | struct xfs_dir3_icfree_hdr { |
| 24 | uint32_t magic; |
| 25 | uint32_t firstdb; |
| 26 | uint32_t nvalid; |
| 27 | uint32_t nused; |
| 28 | }; |
| 29 | |
| 30 | /* xfs_dir2.c */ |
| 31 | extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, |
| 32 | xfs_dir2_db_t *dbp); |
| 33 | extern int xfs_dir_cilookup_result(struct xfs_da_args *args, |
| 34 | const unsigned char *name, int len); |
| 35 | |
| 36 | |
| 37 | /* xfs_dir2_block.c */ |
| 38 | extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp, |
| 39 | struct xfs_buf **bpp); |
| 40 | extern int xfs_dir2_block_addname(struct xfs_da_args *args); |
| 41 | extern int xfs_dir2_block_lookup(struct xfs_da_args *args); |
| 42 | extern int xfs_dir2_block_removename(struct xfs_da_args *args); |
| 43 | extern int xfs_dir2_block_replace(struct xfs_da_args *args); |
| 44 | extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args, |
| 45 | struct xfs_buf *lbp, struct xfs_buf *dbp); |
| 46 | |
| 47 | /* xfs_dir2_data.c */ |
| 48 | #ifdef DEBUG |
| 49 | extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp); |
| 50 | #else |
| 51 | #define xfs_dir3_data_check(dp,bp) |
| 52 | #endif |
| 53 | |
| 54 | extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp, |
| 55 | struct xfs_buf *bp); |
| 56 | extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp, |
| 57 | xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp); |
| 58 | extern int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno, |
| 59 | xfs_daddr_t mapped_bno); |
| 60 | |
| 61 | extern struct xfs_dir2_data_free * |
| 62 | xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr, |
| 63 | struct xfs_dir2_data_free *bf, struct xfs_dir2_data_unused *dup, |
| 64 | int *loghead); |
| 65 | extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, |
| 66 | struct xfs_buf **bpp); |
| 67 | |
| 68 | /* xfs_dir2_leaf.c */ |
| 69 | extern int xfs_dir3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp, |
| 70 | xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp); |
| 71 | extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp, |
| 72 | xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp); |
| 73 | extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args, |
| 74 | struct xfs_buf *dbp); |
| 75 | extern int xfs_dir2_leaf_addname(struct xfs_da_args *args); |
| 76 | extern void xfs_dir3_leaf_compact(struct xfs_da_args *args, |
| 77 | struct xfs_dir3_icleaf_hdr *leafhdr, struct xfs_buf *bp); |
| 78 | extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr, |
| 79 | struct xfs_dir2_leaf_entry *ents, int *indexp, |
| 80 | int *lowstalep, int *highstalep, int *lowlogp, int *highlogp); |
| 81 | extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno, |
| 82 | struct xfs_buf **bpp, uint16_t magic); |
| 83 | extern void xfs_dir3_leaf_log_ents(struct xfs_da_args *args, |
| 84 | struct xfs_buf *bp, int first, int last); |
| 85 | extern void xfs_dir3_leaf_log_header(struct xfs_da_args *args, |
| 86 | struct xfs_buf *bp); |
| 87 | extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args); |
| 88 | extern int xfs_dir2_leaf_removename(struct xfs_da_args *args); |
| 89 | extern int xfs_dir2_leaf_replace(struct xfs_da_args *args); |
| 90 | extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args, |
| 91 | struct xfs_buf *lbp); |
| 92 | extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args, |
| 93 | struct xfs_buf *lbp, xfs_dir2_db_t db); |
| 94 | extern struct xfs_dir2_leaf_entry * |
| 95 | xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr, |
| 96 | struct xfs_dir2_leaf_entry *ents, int index, int compact, |
| 97 | int lowstale, int highstale, int *lfloglow, int *lfloghigh); |
| 98 | extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state); |
| 99 | |
| 100 | extern xfs_failaddr_t xfs_dir3_leaf_check_int(struct xfs_mount *mp, |
| 101 | struct xfs_inode *dp, struct xfs_dir3_icleaf_hdr *hdr, |
| 102 | struct xfs_dir2_leaf *leaf); |
| 103 | |
| 104 | /* xfs_dir2_node.c */ |
| 105 | extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args, |
| 106 | struct xfs_buf *lbp); |
| 107 | extern xfs_dahash_t xfs_dir2_leaf_lasthash(struct xfs_inode *dp, |
| 108 | struct xfs_buf *bp, int *count); |
| 109 | extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp, |
| 110 | struct xfs_da_args *args, int *indexp, |
| 111 | struct xfs_da_state *state); |
| 112 | extern int xfs_dir2_leafn_order(struct xfs_inode *dp, struct xfs_buf *leaf1_bp, |
| 113 | struct xfs_buf *leaf2_bp); |
| 114 | extern int xfs_dir2_leafn_split(struct xfs_da_state *state, |
| 115 | struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk); |
| 116 | extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action); |
| 117 | extern void xfs_dir2_leafn_unbalance(struct xfs_da_state *state, |
| 118 | struct xfs_da_state_blk *drop_blk, |
| 119 | struct xfs_da_state_blk *save_blk); |
| 120 | extern int xfs_dir2_node_addname(struct xfs_da_args *args); |
| 121 | extern int xfs_dir2_node_lookup(struct xfs_da_args *args); |
| 122 | extern int xfs_dir2_node_removename(struct xfs_da_args *args); |
| 123 | extern int xfs_dir2_node_replace(struct xfs_da_args *args); |
| 124 | extern int xfs_dir2_node_trim_free(struct xfs_da_args *args, xfs_fileoff_t fo, |
| 125 | int *rvalp); |
| 126 | extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp, |
| 127 | xfs_dablk_t fbno, struct xfs_buf **bpp); |
| 128 | |
| 129 | /* xfs_dir2_sf.c */ |
| 130 | extern int xfs_dir2_block_sfsize(struct xfs_inode *dp, |
| 131 | struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp); |
| 132 | extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp, |
| 133 | int size, xfs_dir2_sf_hdr_t *sfhp); |
| 134 | extern int xfs_dir2_sf_addname(struct xfs_da_args *args); |
| 135 | extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino); |
| 136 | extern int xfs_dir2_sf_lookup(struct xfs_da_args *args); |
| 137 | extern int xfs_dir2_sf_removename(struct xfs_da_args *args); |
| 138 | extern int xfs_dir2_sf_replace(struct xfs_da_args *args); |
| 139 | extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_inode *ip); |
| 140 | |
| 141 | /* xfs_dir2_readdir.c */ |
| 142 | extern int xfs_readdir(struct xfs_trans *tp, struct xfs_inode *dp, |
| 143 | struct dir_context *ctx, size_t bufsize); |
| 144 | |
| 145 | #endif /* __XFS_DIR2_PRIV_H__ */ |