| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 |  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. | 
 | 3 |  * All Rights Reserved. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 |  * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 |  * published by the Free Software Foundation. | 
 | 8 |  * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 |  * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 |  */ | 
 | 18 | #ifndef __XFS_DIR2_BLOCK_H__ | 
 | 19 | #define	__XFS_DIR2_BLOCK_H__ | 
 | 20 |  | 
 | 21 | /* | 
 | 22 |  * xfs_dir2_block.h | 
 | 23 |  * Directory version 2, single block format structures | 
 | 24 |  */ | 
 | 25 |  | 
 | 26 | struct uio; | 
 | 27 | struct xfs_dabuf; | 
 | 28 | struct xfs_da_args; | 
 | 29 | struct xfs_dir2_data_hdr; | 
 | 30 | struct xfs_dir2_leaf_entry; | 
 | 31 | struct xfs_inode; | 
 | 32 | struct xfs_mount; | 
 | 33 | struct xfs_trans; | 
 | 34 |  | 
 | 35 | /* | 
 | 36 |  * The single block format is as follows: | 
 | 37 |  * xfs_dir2_data_hdr_t structure | 
 | 38 |  * xfs_dir2_data_entry_t and xfs_dir2_data_unused_t structures | 
 | 39 |  * xfs_dir2_leaf_entry_t structures | 
 | 40 |  * xfs_dir2_block_tail_t structure | 
 | 41 |  */ | 
 | 42 |  | 
 | 43 | #define	XFS_DIR2_BLOCK_MAGIC	0x58443242	/* XD2B: for one block dirs */ | 
 | 44 |  | 
 | 45 | typedef struct xfs_dir2_block_tail { | 
| Nathan Scott | e922fff | 2006-03-17 17:27:56 +1100 | [diff] [blame] | 46 | 	__be32		count;			/* count of leaf entries */ | 
 | 47 | 	__be32		stale;			/* count of stale lf entries */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | } xfs_dir2_block_tail_t; | 
 | 49 |  | 
 | 50 | /* | 
 | 51 |  * Generic single-block structure, for xfs_db. | 
 | 52 |  */ | 
 | 53 | typedef struct xfs_dir2_block { | 
 | 54 | 	xfs_dir2_data_hdr_t	hdr;		/* magic XFS_DIR2_BLOCK_MAGIC */ | 
 | 55 | 	xfs_dir2_data_union_t	u[1]; | 
 | 56 | 	xfs_dir2_leaf_entry_t	leaf[1]; | 
 | 57 | 	xfs_dir2_block_tail_t	tail; | 
 | 58 | } xfs_dir2_block_t; | 
 | 59 |  | 
 | 60 | /* | 
 | 61 |  * Pointer to the leaf header embedded in a data block (1-block format) | 
 | 62 |  */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #define	XFS_DIR2_BLOCK_TAIL_P(mp,block)	xfs_dir2_block_tail_p(mp,block) | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 64 | static inline xfs_dir2_block_tail_t * | 
 | 65 | xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block) | 
 | 66 | { | 
 | 67 | 	return (((xfs_dir2_block_tail_t *) | 
 | 68 | 		((char *)(block) + (mp)->m_dirblksize)) - 1); | 
 | 69 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 |  | 
 | 71 | /* | 
 | 72 |  * Pointer to the leaf entries embedded in a data block (1-block format) | 
 | 73 |  */ | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 74 | #define	XFS_DIR2_BLOCK_LEAF_P(btp)	xfs_dir2_block_leaf_p(btp) | 
 | 75 | static inline struct xfs_dir2_leaf_entry * | 
 | 76 | xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp) | 
 | 77 | { | 
| Nathan Scott | e922fff | 2006-03-17 17:27:56 +1100 | [diff] [blame] | 78 | 	return ((struct xfs_dir2_leaf_entry *)btp) - be32_to_cpu(btp->count); | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 79 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 |  | 
 | 81 | /* | 
 | 82 |  * Function declarations. | 
 | 83 |  */ | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 84 | extern int xfs_dir2_block_addname(struct xfs_da_args *args); | 
 | 85 | extern int xfs_dir2_block_getdents(struct xfs_trans *tp, struct xfs_inode *dp, | 
 | 86 | 				   struct uio *uio, int *eofp, | 
 | 87 | 				   struct xfs_dirent *dbp, xfs_dir2_put_t put); | 
 | 88 | extern int xfs_dir2_block_lookup(struct xfs_da_args *args); | 
 | 89 | extern int xfs_dir2_block_removename(struct xfs_da_args *args); | 
 | 90 | extern int xfs_dir2_block_replace(struct xfs_da_args *args); | 
 | 91 | extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args, | 
 | 92 | 				  struct xfs_dabuf *lbp, struct xfs_dabuf *dbp); | 
 | 93 | extern int xfs_dir2_sf_to_block(struct xfs_da_args *args); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 |  | 
 | 95 | #endif	/* __XFS_DIR2_BLOCK_H__ */ |