2 * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
\r
6 * Copyright (c) 2012 Martin Sucha
\r
7 * Copyright (c) 2012 Frantisek Princ
\r
8 * All rights reserved.
\r
10 * Redistribution and use in source and binary forms, with or without
\r
11 * modification, are permitted provided that the following conditions
\r
14 * - Redistributions of source code must retain the above copyright
\r
15 * notice, this list of conditions and the following disclaimer.
\r
16 * - Redistributions in binary form must reproduce the above copyright
\r
17 * notice, this list of conditions and the following disclaimer in the
\r
18 * documentation and/or other materials provided with the distribution.
\r
19 * - The name of the author may not be used to endorse or promote products
\r
20 * derived from this software without specific prior written permission.
\r
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
\r
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
\r
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
\r
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
\r
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
\r
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
\r
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
\r
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
34 /** @addtogroup lwext4
\r
38 * @file ext4_dir_idx.h
\r
39 * @brief Directory indexing procedures.
\r
42 #ifndef EXT4_DIR_IDX_H_
\r
43 #define EXT4_DIR_IDX_H_
\r
45 #include <ext4_config.h>
\r
46 #include <ext4_types.h>
\r
49 #include <stdbool.h>
\r
51 /**@brief Get hash version used in directory index.
\r
52 * @param root_info Pointer to root info structure of index
\r
53 * @return Hash algorithm version
\r
55 uint8_t ext4_dir_dx_root_info_get_hash_version(
\r
56 struct ext4_directory_dx_root_info *root_info);
\r
58 /**@brief Set hash version, that will be used in directory index.
\r
59 * @param root_info Pointer to root info structure of index
\r
60 * @param v Hash algorithm version
\r
62 void ext4_dir_dx_root_info_set_hash_version(
\r
63 struct ext4_directory_dx_root_info *root_info, uint8_t v);
\r
65 /**@brief Get length of root_info structure in bytes.
\r
66 * @param root_info Pointer to root info structure of index
\r
67 * @return Length of the structure
\r
69 uint8_t ext4_dir_dx_root_info_get_info_length(
\r
70 struct ext4_directory_dx_root_info *root_info);
\r
72 /**@brief Set length of root_info structure in bytes.
\r
73 * @param root_info Pointer to root info structure of index
\r
74 * @param info_length Length of the structure
\r
76 void ext4_dir_dx_root_info_set_info_length(
\r
77 struct ext4_directory_dx_root_info *root_info, uint8_t len);
\r
79 /**@brief Get number of indirect levels of HTree.
\r
80 * @param root_info Pointer to root info structure of index
\r
81 * @return Height of HTree (actually only 0 or 1)
\r
83 uint8_t ext4_dir_dx_root_info_get_indirect_levels(
\r
84 struct ext4_directory_dx_root_info *root_info);
\r
86 /**@brief Set number of indirect levels of HTree.
\r
87 * @param root_info Pointer to root info structure of index
\r
88 * @param lvl Height of HTree (actually only 0 or 1)
\r
90 void ext4_dir_dx_root_info_set_indirect_levels(
\r
91 struct ext4_directory_dx_root_info *root_info, uint8_t lvl);
\r
93 /**@brief Get maximum number of index node entries.
\r
94 * @param climit Pointer to counlimit structure
\r
95 * @return Maximum of entries in node
\r
97 uint16_t ext4_dir_dx_countlimit_get_limit(
\r
98 struct ext4_directory_dx_countlimit *climit);
\r
100 /**@brief Set maximum number of index node entries.
\r
101 * @param climit Pointer to counlimit structure
\r
102 * @param limit Maximum of entries in node
\r
104 void ext4_dir_dx_countlimit_set_limit(
\r
105 struct ext4_directory_dx_countlimit *climit, uint16_t limit);
\r
107 /**@brief Get current number of index node entries.
\r
108 * @param climit Pointer to counlimit structure
\r
109 * @return Number of entries in node
\r
111 uint16_t ext4_dir_dx_countlimit_get_count(
\r
112 struct ext4_directory_dx_countlimit *climit);
\r
114 /**@brief Set current number of index node entries.
\r
115 * @param climit Pointer to counlimit structure
\r
116 * @param count Number of entries in node
\r
118 void ext4_dir_dx_countlimit_set_count(
\r
119 struct ext4_directory_dx_countlimit *climit, uint16_t count);
\r
121 /**@brief Get hash value of index entry.
\r
122 * @param entry Pointer to index entry
\r
123 * @return Hash value
\r
125 uint32_t ext4_dir_dx_entry_get_hash(
\r
126 struct ext4_directory_dx_entry *entry);
\r
128 /**@brief Set hash value of index entry.
\r
129 * @param entry Pointer to index entry
\r
130 * @param hash Hash value
\r
132 void ext4_dir_dx_entry_set_hash(
\r
133 struct ext4_directory_dx_entry *entry, uint32_t hash);
\r
135 /**@brief Get block address where child node is located.
\r
136 * @param entry Pointer to index entry
\r
137 * @return Block address of child node
\r
139 uint32_t ext4_dir_dx_entry_get_block(
\r
140 struct ext4_directory_dx_entry *entry);
\r
142 /**@brief Set block address where child node is located.
\r
143 * @param entry Pointer to index entry
\r
144 * @param block Block address of child node
\r
146 void ext4_dir_dx_entry_set_block(
\r
147 struct ext4_directory_dx_entry *entry, uint32_t block);
\r
149 /**@brief Initialize index structure of new directory.
\r
150 * @param dir Pointer to directory i-node
\r
151 * @return Error code
\r
153 int ext4_dir_dx_init(struct ext4_inode_ref *dir);
\r
155 /**@brief Try to find directory entry using directory index.
\r
156 * @param result Output value - if entry will be found,
\r
157 * than will be passed through this parameter
\r
158 * @param inode_ref Directory i-node
\r
159 * @param name_len Length of name to be found
\r
160 * @param name Name to be found
\r
161 * @return Error code
\r
163 int ext4_dir_dx_find_entry(struct ext4_directory_search_result * result,
\r
164 struct ext4_inode_ref *inode_ref, size_t name_len, const char *name);
\r
166 /**@brief Add new entry to indexed directory
\r
167 * @param parent Directory i-node
\r
168 * @param child I-node to be referenced from directory entry
\r
169 * @param name Name of new directory entry
\r
170 * @return Error code
\r
172 int ext4_dir_dx_add_entry(struct ext4_inode_ref *parent,
\r
173 struct ext4_inode_ref *child, const char *name);
\r
175 #endif /* EXT4_DIR_IDX_H_ */
\r