2 * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
6 * Copyright (c) 2012 Martin Sucha
7 * Copyright (c) 2012 Frantisek Princ
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * - Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * - Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * - The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 /** @addtogroup lwext4
39 * @brief Inode handle functions
45 #include "ext4_config.h"
49 /**@brief Get mode of the i-node.
50 * @param sb Superblock
51 * @param inode I-node to load mode from
52 * @return Mode of the i-node
54 uint32_t ext4_inode_get_mode(struct ext4_sblock *sb, struct ext4_inode *inode);
56 /**@brief Set mode of the i-node.
57 * @param sb Superblock
58 * @param inode I-node to set mode to
59 * @param mode Mode to set to i-node
61 void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode,
64 /**@brief Get ID of the i-node owner (user id).
65 * @param inode I-node to load uid from
66 * @return User ID of the i-node owner
68 uint32_t ext4_inode_get_uid(struct ext4_inode *inode);
70 /**@brief Set ID of the i-node owner.
71 * @param inode I-node to set uid to
72 * @param uid ID of the i-node owner
74 void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid);
76 /**@brief Get real i-node size.
77 * @param sb Superblock
78 * @param inode I-node to load size from
79 * @return Real size of i-node
81 uint64_t ext4_inode_get_size(struct ext4_sblock *sb, struct ext4_inode *inode);
83 /**@brief Set real i-node size.
84 * @param inode I-node to set size to
85 * @param size Size of the i-node
87 void ext4_inode_set_size(struct ext4_inode *inode, uint64_t size);
89 /**@brief Get time, when i-node was last accessed.
91 * @return Time of the last access (POSIX)
93 uint32_t ext4_inode_get_access_time(struct ext4_inode *inode);
95 /**@brief Set time, when i-node was last accessed.
97 * @param time Time of the last access (POSIX)
99 void ext4_inode_set_access_time(struct ext4_inode *inode, uint32_t time);
101 /**@brief Get time, when i-node was last changed.
102 * @param inode I-node
103 * @return Time of the last change (POSIX)
105 uint32_t ext4_inode_get_change_inode_time(struct ext4_inode *inode);
107 /**@brief Set time, when i-node was last changed.
108 * @param inode I-node
109 * @param time Time of the last change (POSIX)
111 void ext4_inode_set_change_inode_time(struct ext4_inode *inode, uint32_t time);
113 /**@brief Get time, when i-node content was last modified.
114 * @param inode I-node
115 * @return Time of the last content modification (POSIX)
117 uint32_t ext4_inode_get_modification_time(struct ext4_inode *inode);
119 /**@brief Set time, when i-node content was last modified.
120 * @param inode I-node
121 * @param time Time of the last content modification (POSIX)
123 void ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time);
125 /**@brief Get time, when i-node was deleted.
126 * @param inode I-node
127 * @return Time of the delete action (POSIX)
129 uint32_t ext4_inode_get_deletion_time(struct ext4_inode *inode);
131 /**@brief Set time, when i-node was deleted.
132 * @param inode I-node
133 * @param time Time of the delete action (POSIX)
135 void ext4_inode_set_deletion_time(struct ext4_inode *inode, uint32_t time);
137 /**@brief Get ID of the i-node owner's group.
138 * @param inode I-node to load gid from
139 * @return Group ID of the i-node owner
141 uint32_t ext4_inode_get_gid(struct ext4_inode *inode);
143 /**@brief Set ID to the i-node owner's group.
144 * @param inode I-node to set gid to
145 * @param gid Group ID of the i-node owner
147 void ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid);
149 /**@brief Get number of links to i-node.
150 * @param inode I-node to load number of links from
151 * @return Number of links to i-node
153 uint16_t ext4_inode_get_links_count(struct ext4_inode *inode);
155 /**@brief Set number of links to i-node.
156 * @param inode I-node to set number of links to
157 * @param count Number of links to i-node
159 void ext4_inode_set_links_count(struct ext4_inode *inode, uint16_t cnt);
161 /**@brief Get number of 512-bytes blocks used for i-node.
162 * @param sb Superblock
163 * @param inode I-node
164 * @return Number of 512-bytes blocks
166 uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,
167 struct ext4_inode *inode);
169 /**@brief Set number of 512-bytes blocks used for i-node.
170 * @param sb Superblock
171 * @param inode I-node
172 * @param count Number of 512-bytes blocks
175 int ext4_inode_set_blocks_count(struct ext4_sblock *sb,
176 struct ext4_inode *inode, uint64_t cnt);
178 /**@brief Get flags (features) of i-node.
179 * @param inode I-node to get flags from
180 * @return Flags (bitmap)
182 uint32_t ext4_inode_get_flags(struct ext4_inode *inode);
184 /**@brief Set flags (features) of i-node.
185 * @param inode I-node to set flags to
186 * @param flags Flags to set to i-node
188 void ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags);
190 /**@brief Get file generation (used by NFS).
191 * @param inode I-node
192 * @return File generation
194 uint32_t ext4_inode_get_generation(struct ext4_inode *inode);
196 /**@brief Set file generation (used by NFS).
197 * @param inode I-node
198 * @param generation File generation
200 void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen);
202 /**@brief Get extra I-node size field.
203 * @param inode I-node
204 * @return extra I-node size
206 uint16_t ext4_inode_get_extra_isize(struct ext4_inode *inode);
208 /**@brief Set extra I-node size field.
209 * @param inode I-node
210 * @param size extra I-node size
212 void ext4_inode_set_extra_isize(struct ext4_inode *inode, uint16_t size);
214 /**@brief Get address of block, where are extended attributes located.
215 * @param inode I-node
216 * @param sb Superblock
217 * @return Block address
219 uint64_t ext4_inode_get_file_acl(struct ext4_inode *inode,
220 struct ext4_sblock *sb);
222 /**@brief Set address of block, where are extended attributes located.
223 * @param inode I-node
224 * @param sb Superblock
225 * @param file_acl Block address
227 void ext4_inode_set_file_acl(struct ext4_inode *inode, struct ext4_sblock *sb,
230 /**@brief Get block address of specified direct block.
231 * @param inode I-node to load block from
232 * @param idx Index of logical block
233 * @return Physical block address
235 uint32_t ext4_inode_get_direct_block(struct ext4_inode *inode, uint32_t idx);
237 /**@brief Set block address of specified direct block.
238 * @param inode I-node to set block address to
239 * @param idx Index of logical block
240 * @param fblock Physical block address
242 void ext4_inode_set_direct_block(struct ext4_inode *inode, uint32_t idx,
245 /**@brief Get block address of specified indirect block.
246 * @param inode I-node to get block address from
247 * @param idx Index of indirect block
248 * @return Physical block address
250 uint32_t ext4_inode_get_indirect_block(struct ext4_inode *inode, uint32_t idx);
252 /**@brief Set block address of specified indirect block.
253 * @param inode I-node to set block address to
254 * @param idx Index of indirect block
255 * @param fblock Physical block address
257 void ext4_inode_set_indirect_block(struct ext4_inode *inode, uint32_t idx,
260 /**@brief return the type of i-node
261 * @param sb Superblock
262 * @param inode I-node to return the type of
263 * @return Result of check operation
265 uint32_t ext4_inode_type(struct ext4_sblock *sb, struct ext4_inode *inode);
267 /**@brief Check if i-node has specified type.
268 * @param sb Superblock
269 * @param inode I-node to check type of
270 * @param type Type to check
271 * @return Result of check operation
273 bool ext4_inode_is_type(struct ext4_sblock *sb, struct ext4_inode *inode,
276 /**@brief Check if i-node has specified flag.
277 * @param inode I-node to check flags of
278 * @param flag Flag to check
279 * @return Result of check operation
281 bool ext4_inode_has_flag(struct ext4_inode *inode, uint32_t f);
283 /**@brief Remove specified flag from i-node.
284 * @param inode I-node to clear flag on
285 * @param clear_flag Flag to be cleared
287 void ext4_inode_clear_flag(struct ext4_inode *inode, uint32_t f);
289 /**@brief Set specified flag to i-node.
290 * @param inode I-node to set flag on
291 * @param set_flag Flag to be set
293 void ext4_inode_set_flag(struct ext4_inode *inode, uint32_t f);
295 /**@brief Get inode checksum(crc32)
296 * @param sb Superblock
297 * @param inode I-node to get checksum value from
300 ext4_inode_get_checksum(struct ext4_sblock *sb, struct ext4_inode *inode);
302 /**@brief Get inode checksum(crc32)
303 * @param sb Superblock
304 * @param inode I-node to get checksum value from
307 ext4_inode_set_checksum(struct ext4_sblock *sb, struct ext4_inode *inode,
310 /**@brief Check if i-node can be truncated.
311 * @param sb Superblock
312 * @param inode I-node to check
313 * @return Result of the check operation
315 bool ext4_inode_can_truncate(struct ext4_sblock *sb, struct ext4_inode *inode);
317 /**@brief Get extent header from the root of the extent tree.
318 * @param inode I-node to get extent header from
319 * @return Pointer to extent header of the root node
321 struct ext4_extent_header *
322 ext4_inode_get_extent_header(struct ext4_inode *inode);
324 #endif /* EXT4_INODE_H_ */