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_inode.h
\r
39 * @brief Inode handle functions
\r
42 #ifndef EXT4_INODE_H_
\r
43 #define EXT4_INODE_H_
\r
45 #include <ext4_config.h>
\r
48 /**@brief Get mode of the i-node.
\r
49 * @param sb Superblock
\r
50 * @param inode I-node to load mode from
\r
51 * @return Mode of the i-node
\r
53 uint32_t ext4_inode_get_mode(struct ext4_sblock *sb, struct ext4_inode *inode);
\r
55 /**@brief Set mode of the i-node.
\r
56 * @param sb Superblock
\r
57 * @param inode I-node to set mode to
\r
58 * @param mode Mode to set to i-node
\r
60 void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode,
\r
63 /**@brief Get ID of the i-node owner (user id).
\r
64 * @param inode I-node to load uid from
\r
65 * @return User ID of the i-node owner
\r
67 uint32_t ext4_inode_get_uid(struct ext4_inode *inode);
\r
69 /**@brief Set ID of the i-node owner.
\r
70 * @param inode I-node to set uid to
\r
71 * @param uid ID of the i-node owner
\r
73 void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid);
\r
75 /**@brief Get real i-node size.
\r
76 * @param sb Superblock
\r
77 * @param inode I-node to load size from
\r
78 * @return Real size of i-node
\r
80 uint64_t ext4_inode_get_size(struct ext4_sblock *sb, struct ext4_inode *inode);
\r
82 /**@brief Set real i-node size.
\r
83 * @param inode I-node to set size to
\r
84 * @param size Size of the i-node
\r
86 void ext4_inode_set_size(struct ext4_inode *inode, uint64_t size);
\r
88 /**@brief Get time, when i-node was last accessed.
\r
89 * @param inode I-node
\r
90 * @return Time of the last access (POSIX)
\r
92 uint32_t ext4_inode_get_access_time(struct ext4_inode *inode);
\r
94 /**@brief Set time, when i-node was last accessed.
\r
95 * @param inode I-node
\r
96 * @param time Time of the last access (POSIX)
\r
98 void ext4_inode_set_access_time(struct ext4_inode *inode, uint32_t time);
\r
100 /**@brief Get time, when i-node was last changed.
\r
101 * @param inode I-node
\r
102 * @return Time of the last change (POSIX)
\r
104 uint32_t ext4_inode_get_change_inode_time(struct ext4_inode *inode);
\r
106 /**@brief Set time, when i-node was last changed.
\r
107 * @param inode I-node
\r
108 * @param time Time of the last change (POSIX)
\r
110 void ext4_inode_set_change_inode_time(struct ext4_inode *inode, uint32_t time);
\r
112 /**@brief Get time, when i-node content was last modified.
\r
113 * @param inode I-node
\r
114 * @return Time of the last content modification (POSIX)
\r
116 uint32_t ext4_inode_get_modification_time(struct ext4_inode *inode);
\r
118 /**@brief Set time, when i-node content was last modified.
\r
119 * @param inode I-node
\r
120 * @param time Time of the last content modification (POSIX)
\r
122 void ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time);
\r
124 /**@brief Get time, when i-node was deleted.
\r
125 * @param inode I-node
\r
126 * @return Time of the delete action (POSIX)
\r
128 uint32_t ext4_inode_get_deletion_time(struct ext4_inode *inode);
\r
130 /**@brief Set time, when i-node was deleted.
\r
131 * @param inode I-node
\r
132 * @param time Time of the delete action (POSIX)
\r
134 void ext4_inode_set_deletion_time(struct ext4_inode *inode, uint32_t time);
\r
136 /**@brief Get ID of the i-node owner's group.
\r
137 * @param inode I-node to load gid from
\r
138 * @return Group ID of the i-node owner
\r
140 uint32_t ext4_inode_get_gid(struct ext4_inode *inode);
\r
142 /**@brief Set ID ot the i-node owner's group.
\r
143 * @param inode I-node to set gid to
\r
144 * @param gid Group ID of the i-node owner
\r
146 void ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid);
\r
148 /**@brief Get number of links to i-node.
\r
149 * @param inode I-node to load number of links from
\r
150 * @return Number of links to i-node
\r
152 uint16_t ext4_inode_get_links_count(struct ext4_inode *inode);
\r
154 /**@brief Set number of links to i-node.
\r
155 * @param inode I-node to set number of links to
\r
156 * @param count Number of links to i-node
\r
158 void ext4_inode_set_links_count(struct ext4_inode *inode, uint16_t cnt);
\r
160 /**@brief Get number of 512-bytes blocks used for i-node.
\r
161 * @param sb Superblock
\r
162 * @param inode I-node
\r
163 * @return Number of 512-bytes blocks
\r
165 uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,
\r
166 struct ext4_inode *inode);
\r
168 /**@brief Set number of 512-bytes blocks used for i-node.
\r
169 * @param sb Superblock
\r
170 * @param inode I-node
\r
171 * @param count Number of 512-bytes blocks
\r
172 * @return Error code
\r
174 int ext4_inode_set_blocks_count(struct ext4_sblock *sb,
\r
175 struct ext4_inode *inode, uint64_t cnt);
\r
177 /**@brief Get flags (features) of i-node.
\r
178 * @param inode I-node to get flags from
\r
179 * @return Flags (bitmap)
\r
181 uint32_t ext4_inode_get_flags(struct ext4_inode *inode);
\r
183 /**@brief Set flags (features) of i-node.
\r
184 * @param inode I-node to set flags to
\r
185 * @param flags Flags to set to i-node
\r
187 void ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags);
\r
189 /**@brief Get file generation (used by NFS).
\r
190 * @param inode I-node
\r
191 * @return File generation
\r
193 uint32_t ext4_inode_get_generation(struct ext4_inode *inode);
\r
195 /**@brief Set file generation (used by NFS).
\r
196 * @param inode I-node
\r
197 * @param generation File generation
\r
199 void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen);
\r
201 /**@brief Get address of block, where are extended attributes located.
\r
202 * @param inode I-node
\r
203 * @param sb Superblock
\r
204 * @return Block address
\r
206 uint64_t ext4_inode_get_file_acl(struct ext4_inode *inode,
\r
207 struct ext4_sblock *sb);
\r
209 /**@brief Set address of block, where are extended attributes located.
\r
210 * @param inode I-node
\r
211 * @param sb Superblock
\r
212 * @param file_acl Block address
\r
214 void ext4_inode_set_file_acl(struct ext4_inode *inode, struct ext4_sblock *sb,
\r
217 /**@brief Get block address of specified direct block.
\r
218 * @param inode I-node to load block from
\r
219 * @param idx Index of logical block
\r
220 * @return Physical block address
\r
222 uint32_t ext4_inode_get_direct_block(struct ext4_inode *inode, uint32_t idx);
\r
224 /**@brief Set block address of specified direct block.
\r
225 * @param inode I-node to set block address to
\r
226 * @param idx Index of logical block
\r
227 * @param fblock Physical block address
\r
229 void ext4_inode_set_direct_block(struct ext4_inode *inode, uint32_t idx,
\r
232 /**@brief Get block address of specified indirect block.
\r
233 * @param inode I-node to get block address from
\r
234 * @param idx Index of indirect block
\r
235 * @return Physical block address
\r
237 uint32_t ext4_inode_get_indirect_block(struct ext4_inode *inode, uint32_t idx);
\r
239 /**@brief Set block address of specified indirect block.
\r
240 * @param inode I-node to set block address to
\r
241 * @param idx Index of indirect block
\r
242 * @param fblock Physical block address
\r
244 void ext4_inode_set_indirect_block(struct ext4_inode *inode, uint32_t idx,
\r
247 /**@brief Check if i-node has specified type.
\r
248 * @param sb Superblock
\r
249 * @param inode I-node to check type of
\r
250 * @param type Type to check
\r
251 * @return Result of check operation
\r
253 bool ext4_inode_is_type(struct ext4_sblock *sb, struct ext4_inode *inode,
\r
256 /**@brief Check if i-node has specified flag.
\r
257 * @param inode I-node to check flags of
\r
258 * @param flag Flag to check
\r
259 * @return Result of check operation
\r
261 bool ext4_inode_has_flag(struct ext4_inode *inode, uint32_t f);
\r
263 /**@brief Remove specified flag from i-node.
\r
264 * @param inode I-node to clear flag on
\r
265 * @param clear_flag Flag to be cleared
\r
267 void ext4_inode_clear_flag(struct ext4_inode *inode, uint32_t f);
\r
269 /**@brief Set specified flag to i-node.
\r
270 * @param inode I-node to set flag on
\r
271 * @param set_flag Flag to be set
\r
273 void ext4_inode_set_flag(struct ext4_inode *inode, uint32_t f);
\r
275 /**@brief Check if i-node can be truncated.
\r
276 * @param sb Superblock
\r
277 * @param inode I-node to check
\r
278 * @return Result of the check operation
\r
280 bool ext4_inode_can_truncate(struct ext4_sblock *sb, struct ext4_inode *inode);
\r
282 /**@brief Get extent header from the root of the extent tree.
\r
283 * @param inode I-node to get extent header from
\r
284 * @return Pointer to extent header of the root node
\r
286 struct ext4_extent_header *
\r
287 ext4_inode_get_extent_header(struct ext4_inode *inode);
\r
289 #endif /* EXT4_INODE_H_ */
\r