Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef __XFS_DIR2_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define __XFS_DIR2_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "xfs_da_format.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "xfs_da_btree.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) struct xfs_da_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) struct xfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) struct xfs_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) struct xfs_trans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) struct xfs_dir2_sf_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) struct xfs_dir2_sf_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) struct xfs_dir2_data_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) struct xfs_dir2_data_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) struct xfs_dir2_data_unused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) struct xfs_dir3_icfree_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) struct xfs_dir3_icleaf_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) extern struct xfs_name	xfs_name_dotdot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * Convert inode mode to directory entry filetype
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) extern unsigned char xfs_mode_to_ftype(int mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * Generic directory interface routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) extern void xfs_dir_startup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) extern int xfs_da_mount(struct xfs_mount *mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) extern void xfs_da_unmount(struct xfs_mount *mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) extern int xfs_dir_isempty(struct xfs_inode *dp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 				struct xfs_inode *pdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 				struct xfs_name *name, xfs_ino_t inum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 				xfs_extlen_t tot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 				struct xfs_name *name, xfs_ino_t *inum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 				struct xfs_name *ci_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 				struct xfs_name *name, xfs_ino_t ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 				xfs_extlen_t tot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) extern bool xfs_dir2_sf_replace_needblock(struct xfs_inode *dp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 				xfs_ino_t inum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 				struct xfs_name *name, xfs_ino_t inum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 				xfs_extlen_t tot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 				struct xfs_name *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * Direct call from the bmap code, bypassing the generic directory layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) extern int xfs_dir2_sf_to_block(struct xfs_da_args *args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  * Interface routines used by userspace utilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) extern int xfs_dir2_isblock(struct xfs_da_args *args, int *r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) extern int xfs_dir2_isleaf(struct xfs_da_args *args, int *r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 				struct xfs_buf *bp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) extern void xfs_dir2_data_freescan(struct xfs_mount *mp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		struct xfs_dir2_data_hdr *hdr, int *loghead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) extern void xfs_dir2_data_log_entry(struct xfs_da_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		struct xfs_buf *bp, struct xfs_dir2_data_entry *dep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) extern void xfs_dir2_data_log_header(struct xfs_da_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		struct xfs_buf *bp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) extern void xfs_dir2_data_log_unused(struct xfs_da_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		struct xfs_buf *bp, struct xfs_dir2_data_unused *dup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) extern void xfs_dir2_data_make_free(struct xfs_da_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		struct xfs_buf *bp, xfs_dir2_data_aoff_t offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) extern int xfs_dir2_data_use_free(struct xfs_da_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		struct xfs_buf *bp, struct xfs_dir2_data_unused *dup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		int *needlogp, int *needscanp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) extern struct xfs_dir2_data_free *xfs_dir2_data_freefind(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_free *bf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		struct xfs_dir2_data_unused *dup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) extern const struct xfs_buf_ops xfs_dir3_block_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) extern const struct xfs_buf_ops xfs_dir3_leafn_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) extern const struct xfs_buf_ops xfs_dir3_free_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) extern const struct xfs_buf_ops xfs_dir3_data_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  * Directory offset/block conversion functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  * DB blocks here are logical directory block numbers, not filesystem blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * Convert dataptr to byte in file space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static inline xfs_dir2_off_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * Convert byte in file space to dataptr.  It had better be aligned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static inline xfs_dir2_dataptr_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  * Convert byte in space to (DB) block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static inline xfs_dir2_db_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	return (xfs_dir2_db_t)(by >> geo->blklog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  * Convert dataptr to a block number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static inline xfs_dir2_db_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * Convert byte in space to offset in a block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static inline xfs_dir2_data_aoff_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * Convert dataptr to a byte offset in a block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static inline xfs_dir2_data_aoff_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * Convert block and offset to byte in space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static inline xfs_dir2_off_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 			xfs_dir2_data_aoff_t o)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	return ((xfs_dir2_off_t)db << geo->blklog) + o;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * Convert block (DB) to block (dablk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static inline xfs_dablk_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  * Convert byte in space to (DA) block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static inline xfs_dablk_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  * Convert block and offset to dataptr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static inline xfs_dir2_dataptr_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			   xfs_dir2_data_aoff_t o)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  * Convert block (dablk) to block (DB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) static inline xfs_dir2_db_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  * Convert block (dablk) to byte offset in space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static inline xfs_dir2_off_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  * Directory tail pointer accessor functions. Based on block geometry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) static inline struct xfs_dir2_block_tail *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	return ((struct xfs_dir2_block_tail *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		((char *)hdr + geo->blksize)) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) static inline struct xfs_dir2_leaf_tail *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	return (struct xfs_dir2_leaf_tail *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		((char *)lp + geo->blksize -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		  sizeof(struct xfs_dir2_leaf_tail));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)  * The Linux API doesn't pass down the total size of the buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  * we read into down to the filesystem.  With the filldir concept
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)  * it's not needed for correct information, but the XFS dir2 leaf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  * code wants an estimate of the buffer size to calculate it's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  * readahead window and size the buffers used for mapping to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)  * physical blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)  * Try to give it an estimate that's good enough, maybe at some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  * point we can change the ->readdir prototype to include the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  * buffer size.  For now we use the current glibc buffer size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  * musl libc hardcodes 2k and dietlibc uses PAGE_SIZE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) #define XFS_READDIR_BUFSIZE	(32768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) unsigned char xfs_dir3_get_dtype(struct xfs_mount *mp, uint8_t filetype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) unsigned int xfs_dir3_data_end_offset(struct xfs_da_geometry *geo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		struct xfs_dir2_data_hdr *hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) bool xfs_dir2_namecheck(const void *name, size_t length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) #endif	/* __XFS_DIR2_H__ */