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_H__ |
| 19 | #define __XFS_DIR2_H__ |
| 20 | |
| 21 | struct uio; |
| 22 | struct xfs_dabuf; |
| 23 | struct xfs_da_args; |
| 24 | struct xfs_dir2_put_args; |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 25 | struct xfs_bmap_free; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | struct xfs_inode; |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 27 | struct xfs_mount; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | struct xfs_trans; |
| 29 | |
| 30 | /* |
| 31 | * Directory version 2. |
| 32 | * There are 4 possible formats: |
| 33 | * shortform |
| 34 | * single block - data with embedded leaf at the end |
| 35 | * multiple data blocks, single leaf+freeindex block |
| 36 | * data blocks, node&leaf blocks (btree), freeindex blocks |
| 37 | * |
| 38 | * The shortform format is in xfs_dir2_sf.h. |
| 39 | * The single block format is in xfs_dir2_block.h. |
| 40 | * The data block format is in xfs_dir2_data.h. |
| 41 | * The leaf and freeindex block formats are in xfs_dir2_leaf.h. |
| 42 | * Node blocks are the same as the other version, in xfs_da_btree.h. |
| 43 | */ |
| 44 | |
| 45 | /* |
| 46 | * Byte offset in data block and shortform entry. |
| 47 | */ |
| 48 | typedef __uint16_t xfs_dir2_data_off_t; |
| 49 | #define NULLDATAOFF 0xffffU |
| 50 | typedef uint xfs_dir2_data_aoff_t; /* argument form */ |
| 51 | |
| 52 | /* |
| 53 | * Directory block number (logical dirblk in file) |
| 54 | */ |
| 55 | typedef __uint32_t xfs_dir2_db_t; |
| 56 | |
| 57 | /* |
| 58 | * Byte offset in a directory. |
| 59 | */ |
Nathan Scott | 2d0f864 | 2006-03-14 13:20:33 +1100 | [diff] [blame] | 60 | typedef xfs_off_t xfs_dir2_off_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
Barry Naujok | 556b8b1 | 2008-04-10 12:22:07 +1000 | [diff] [blame] | 62 | extern struct xfs_name xfs_name_dotdot; |
| 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | /* |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 65 | * Generic directory interface routines |
| 66 | */ |
| 67 | extern void xfs_dir_startup(void); |
| 68 | extern void xfs_dir_mount(struct xfs_mount *mp); |
| 69 | extern int xfs_dir_isempty(struct xfs_inode *dp); |
| 70 | extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp, |
| 71 | struct xfs_inode *pdp); |
| 72 | extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp, |
Barry Naujok | 556b8b1 | 2008-04-10 12:22:07 +1000 | [diff] [blame] | 73 | struct xfs_name *name, xfs_ino_t inum, |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 74 | xfs_fsblock_t *first, |
| 75 | struct xfs_bmap_free *flist, xfs_extlen_t tot); |
| 76 | extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp, |
Barry Naujok | 556b8b1 | 2008-04-10 12:22:07 +1000 | [diff] [blame] | 77 | struct xfs_name *name, xfs_ino_t *inum); |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 78 | extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp, |
Barry Naujok | 556b8b1 | 2008-04-10 12:22:07 +1000 | [diff] [blame] | 79 | struct xfs_name *name, xfs_ino_t ino, |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 80 | xfs_fsblock_t *first, |
| 81 | struct xfs_bmap_free *flist, xfs_extlen_t tot); |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 82 | extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp, |
Barry Naujok | 556b8b1 | 2008-04-10 12:22:07 +1000 | [diff] [blame] | 83 | struct xfs_name *name, xfs_ino_t inum, |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 84 | xfs_fsblock_t *first, |
| 85 | struct xfs_bmap_free *flist, xfs_extlen_t tot); |
| 86 | extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp, |
Barry Naujok | 556b8b1 | 2008-04-10 12:22:07 +1000 | [diff] [blame] | 87 | struct xfs_name *name, uint resblks); |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 88 | extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); |
| 89 | |
| 90 | /* |
| 91 | * Utility routines for v2 directories. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | */ |
Nathan Scott | 2d0f864 | 2006-03-14 13:20:33 +1100 | [diff] [blame] | 93 | extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, |
| 94 | xfs_dir2_db_t *dbp); |
| 95 | extern int xfs_dir2_isblock(struct xfs_trans *tp, struct xfs_inode *dp, |
| 96 | int *vp); |
| 97 | extern int xfs_dir2_isleaf(struct xfs_trans *tp, struct xfs_inode *dp, |
| 98 | int *vp); |
| 99 | extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db, |
| 100 | struct xfs_dabuf *bp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
| 102 | #endif /* __XFS_DIR2_H__ */ |