1ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh/* -*- mode: c; c-basic-offset: 8; -*-
2ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * vim: noexpandtab sw=8 ts=8 sts=0:
3ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh *
4ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * dir.h
5ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh *
6ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * Function prototypes
7ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh *
8ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
9ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh *
10ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * This program is free software; you can redistribute it and/or
11ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * modify it under the terms of the GNU General Public
12ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * License as published by the Free Software Foundation; either
13ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * version 2 of the License, or (at your option) any later version.
14ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh *
15ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * This program is distributed in the hope that it will be useful,
16ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * but WITHOUT ANY WARRANTY; without even the implied warranty of
17ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * General Public License for more details.
19ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh *
20ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * You should have received a copy of the GNU General Public
21ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * License along with this program; if not, write to the
22ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh * Boston, MA 021110-1307, USA.
24ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh */
25ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh
26ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh#ifndef OCFS2_DIR_H
27ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh#define OCFS2_DIR_H
28ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh
299b7895efac906d66d19856194e1ba61f37e231a4Mark Fashehstruct ocfs2_dx_hinfo {
309b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh	u32	major_hash;
319b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh	u32	minor_hash;
329b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh};
339b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh
344a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fashehstruct ocfs2_dir_lookup_result {
359b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh	struct buffer_head		*dl_leaf_bh;	/* Unindexed leaf
369b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh							 * block */
379b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh	struct ocfs2_dir_entry		*dl_entry;	/* Target dirent in
389b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh							 * unindexed leaf */
399b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh
404ed8a6bb083bfcc21f1ed66a474b03c0386e4b34Mark Fasheh	struct buffer_head		*dl_dx_root_bh;	/* Root of indexed
414ed8a6bb083bfcc21f1ed66a474b03c0386e4b34Mark Fasheh							 * tree */
42e7c17e43090afe558c40bfb66637744c27bd2aebMark Fasheh
439b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh	struct buffer_head		*dl_dx_leaf_bh;	/* Indexed leaf block */
449b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh	struct ocfs2_dx_entry		*dl_dx_entry;	/* Target dx_entry in
459b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh							 * indexed leaf */
469b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh	struct ocfs2_dx_hinfo		dl_hinfo;	/* Name hash results */
47e7c17e43090afe558c40bfb66637744c27bd2aebMark Fasheh
48e7c17e43090afe558c40bfb66637744c27bd2aebMark Fasheh	struct buffer_head		*dl_prev_leaf_bh;/* Previous entry in
49e7c17e43090afe558c40bfb66637744c27bd2aebMark Fasheh							  * dir free space
50e7c17e43090afe558c40bfb66637744c27bd2aebMark Fasheh							  * list. NULL if
51e7c17e43090afe558c40bfb66637744c27bd2aebMark Fasheh							  * previous entry is
52e7c17e43090afe558c40bfb66637744c27bd2aebMark Fasheh							  * dx root block. */
534a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh};
54e7c17e43090afe558c40bfb66637744c27bd2aebMark Fasheh
554a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fashehvoid ocfs2_free_dir_lookup_result(struct ocfs2_dir_lookup_result *res);
564a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh
574a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fashehint ocfs2_find_entry(const char *name, int namelen,
584a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh		     struct inode *dir,
594a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh		     struct ocfs2_dir_lookup_result *lookup);
60316f4b9f98a353ac1be93199694fd97272378815Mark Fashehint ocfs2_delete_entry(handle_t *handle,
61316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh		       struct inode *dir,
624a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh		       struct ocfs2_dir_lookup_result *res);
63316f4b9f98a353ac1be93199694fd97272378815Mark Fashehint __ocfs2_add_entry(handle_t *handle,
64316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh		      struct inode *dir,
65316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh		      const char *name, int namelen,
66316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh		      struct inode *inode, u64 blkno,
67316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh		      struct buffer_head *parent_fe_bh,
684a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh		      struct ocfs2_dir_lookup_result *lookup);
69316f4b9f98a353ac1be93199694fd97272378815Mark Fashehstatic inline int ocfs2_add_entry(handle_t *handle,
70316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh				  struct dentry *dentry,
71316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh				  struct inode *inode, u64 blkno,
72316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh				  struct buffer_head *parent_fe_bh,
734a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh				  struct ocfs2_dir_lookup_result *lookup)
74316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh{
75316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh	return __ocfs2_add_entry(handle, dentry->d_parent->d_inode,
76316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh				 dentry->d_name.name, dentry->d_name.len,
774a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh				 inode, blkno, parent_fe_bh, lookup);
78316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh}
7938760e243249f03b4c6d78ca624dd846a2681b67Mark Fashehint ocfs2_update_entry(struct inode *dir, handle_t *handle,
804a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh		       struct ocfs2_dir_lookup_result *res,
8138760e243249f03b4c6d78ca624dd846a2681b67Mark Fasheh		       struct inode *new_entry_inode);
82316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh
83ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fashehint ocfs2_check_dir_for_entry(struct inode *dir,
84ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh			      const char *name,
85ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh			      int namelen);
860bfbbf62a8b5a129ba2c689283bfece80a601abaMark Fashehint ocfs2_empty_dir(struct inode *inode);
874a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh
88ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fashehint ocfs2_find_files_on_disk(const char *name,
89ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh			     int namelen,
90ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh			     u64 *blkno,
91ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh			     struct inode *inode,
924a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh			     struct ocfs2_dir_lookup_result *res);
93be94d11704ef79030fd2e6a0c41b4a7f65f9e860Mark Fashehint ocfs2_lookup_ino_from_name(struct inode *dir, const char *name,
94be94d11704ef79030fd2e6a0c41b4a7f65f9e860Mark Fasheh			       int namelen, u64 *blkno);
953704412bdbf37ec836152f571ac74fe72220c05aAl Viroint ocfs2_readdir(struct file *file, struct dir_context *ctx);
963704412bdbf37ec836152f571ac74fe72220c05aAl Viroint ocfs2_dir_foreach(struct inode *inode, struct dir_context *ctx);
97ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fashehint ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb,
98ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh				 struct inode *dir,
99ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh				 struct buffer_head *parent_fe_bh,
100ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh				 const char *name,
101ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh				 int namelen,
1024a12ca3a00a244e1fd1e673d151ea38b71e11d55Mark Fasheh				 struct ocfs2_dir_lookup_result *lookup);
103ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fashehstruct ocfs2_alloc_context;
104316f4b9f98a353ac1be93199694fd97272378815Mark Fashehint ocfs2_fill_new_dir(struct ocfs2_super *osb,
105316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh		       handle_t *handle,
106316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh		       struct inode *parent,
107316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh		       struct inode *inode,
108316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh		       struct buffer_head *fe_bh,
1099b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh		       struct ocfs2_alloc_context *data_ac,
1109b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh		       struct ocfs2_alloc_context *meta_ac);
1119b7895efac906d66d19856194e1ba61f37e231a4Mark Fasheh
1129b7895efac906d66d19856194e1ba61f37e231a4Mark Fashehint ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh);
113316f4b9f98a353ac1be93199694fd97272378815Mark Fasheh
114c175a518b4a1d514483abf61813ce5d855917164Joel Beckerstruct ocfs2_dir_block_trailer *ocfs2_dir_trailer_from_size(int blocksize,
115c175a518b4a1d514483abf61813ce5d855917164Joel Becker							    void *data);
116ccd979bdbce9fba8412beb3f1de68a9d0171b12cMark Fasheh#endif /* OCFS2_DIR_H */
117