blob: 1d9ef96f33aa736beeeeda6b368453cecbe774e6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * 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 Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * 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 Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * 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 Torvalds1da177e2005-04-16 15:20:36 -070017 */
18#ifndef __XFS_DIR2_H__
19#define __XFS_DIR2_H__
20
21struct uio;
22struct xfs_dabuf;
23struct xfs_da_args;
24struct xfs_dir2_put_args;
Nathan Scottf6c2d1f2006-06-20 13:04:51 +100025struct xfs_bmap_free;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026struct xfs_inode;
Nathan Scottf6c2d1f2006-06-20 13:04:51 +100027struct xfs_mount;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028struct 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 */
48typedef __uint16_t xfs_dir2_data_off_t;
49#define NULLDATAOFF 0xffffU
50typedef uint xfs_dir2_data_aoff_t; /* argument form */
51
52/*
53 * Directory block number (logical dirblk in file)
54 */
55typedef __uint32_t xfs_dir2_db_t;
56
57/*
58 * Byte offset in a directory.
59 */
Nathan Scott2d0f8642006-03-14 13:20:33 +110060typedef xfs_off_t xfs_dir2_off_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Barry Naujok556b8b12008-04-10 12:22:07 +100062extern struct xfs_name xfs_name_dotdot;
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064/*
Nathan Scottf6c2d1f2006-06-20 13:04:51 +100065 * Generic directory interface routines
66 */
67extern void xfs_dir_startup(void);
68extern void xfs_dir_mount(struct xfs_mount *mp);
69extern int xfs_dir_isempty(struct xfs_inode *dp);
70extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
71 struct xfs_inode *pdp);
72extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
Barry Naujok556b8b12008-04-10 12:22:07 +100073 struct xfs_name *name, xfs_ino_t inum,
Nathan Scottf6c2d1f2006-06-20 13:04:51 +100074 xfs_fsblock_t *first,
75 struct xfs_bmap_free *flist, xfs_extlen_t tot);
76extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
Barry Naujok384f3ce2008-05-21 16:58:22 +100077 struct xfs_name *name, xfs_ino_t *inum,
78 struct xfs_name *ci_name);
Nathan Scottf6c2d1f2006-06-20 13:04:51 +100079extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
Barry Naujok556b8b12008-04-10 12:22:07 +100080 struct xfs_name *name, xfs_ino_t ino,
Nathan Scottf6c2d1f2006-06-20 13:04:51 +100081 xfs_fsblock_t *first,
82 struct xfs_bmap_free *flist, xfs_extlen_t tot);
Nathan Scottf6c2d1f2006-06-20 13:04:51 +100083extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
Barry Naujok556b8b12008-04-10 12:22:07 +100084 struct xfs_name *name, xfs_ino_t inum,
Nathan Scottf6c2d1f2006-06-20 13:04:51 +100085 xfs_fsblock_t *first,
86 struct xfs_bmap_free *flist, xfs_extlen_t tot);
87extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
Barry Naujok556b8b12008-04-10 12:22:07 +100088 struct xfs_name *name, uint resblks);
Nathan Scottf6c2d1f2006-06-20 13:04:51 +100089extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
90
91/*
92 * Utility routines for v2 directories.
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 */
Nathan Scott2d0f8642006-03-14 13:20:33 +110094extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
95 xfs_dir2_db_t *dbp);
96extern int xfs_dir2_isblock(struct xfs_trans *tp, struct xfs_inode *dp,
97 int *vp);
98extern int xfs_dir2_isleaf(struct xfs_trans *tp, struct xfs_inode *dp,
99 int *vp);
100extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
101 struct xfs_dabuf *bp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
Barry Naujok384f3ce2008-05-21 16:58:22 +1000103extern int xfs_dir_cilookup_result(struct xfs_da_args *args, const char *name,
104 int len);
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106#endif /* __XFS_DIR2_H__ */