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
49 /**@brief Get mode of the i-node.
\r
50 * @param sb Superblock
\r
51 * @param inode I-node to load mode from
\r
52 * @return Mode of the i-node
\r
54 uint32_t ext4_inode_get_mode(struct ext4_sblock *sb, struct ext4_inode *inode);
\r
56 /**@brief Set mode of the i-node.
\r
57 * @param sb Superblock
\r
58 * @param inode I-node to set mode to
\r
59 * @param mode Mode to set to i-node
\r
61 void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode,
\r
64 /**@brief Get ID of the i-node owner (user id).
\r
65 * @param inode I-node to load uid from
\r
66 * @return User ID of the i-node owner
\r
68 uint32_t ext4_inode_get_uid(struct ext4_inode *inode);
\r
70 /**@brief Set ID of the i-node owner.
\r
71 * @param inode I-node to set uid to
\r
72 * @param uid ID of the i-node owner
\r
74 void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid);
\r
76 /**@brief Get real i-node size.
\r
77 * @param sb Superblock
\r
78 * @param inode I-node to load size from
\r
79 * @return Real size of i-node
\r
81 uint64_t ext4_inode_get_size(struct ext4_sblock *sb, struct ext4_inode *inode);
\r
83 /**@brief Set real i-node size.
\r
84 * @param inode I-node to set size to
\r
85 * @param size Size of the i-node
\r
87 void ext4_inode_set_size(struct ext4_inode *inode, uint64_t size);
\r
89 /**@brief Get time, when i-node was last accessed.
\r
90 * @param inode I-node
\r
91 * @return Time of the last access (POSIX)
\r
93 uint32_t ext4_inode_get_access_time(struct ext4_inode *inode);
\r
95 /**@brief Set time, when i-node was last accessed.
\r
96 * @param inode I-node
\r
97 * @param time Time of the last access (POSIX)
\r
99 void ext4_inode_set_access_time(struct ext4_inode *inode, uint32_t time);
\r
101 /**@brief Get time, when i-node was last changed.
\r
102 * @param inode I-node
\r
103 * @return Time of the last change (POSIX)
\r
105 uint32_t ext4_inode_get_change_inode_time(struct ext4_inode *inode);
\r
107 /**@brief Set time, when i-node was last changed.
\r
108 * @param inode I-node
\r
109 * @param time Time of the last change (POSIX)
\r
111 void ext4_inode_set_change_inode_time(struct ext4_inode *inode, uint32_t time);
\r
113 /**@brief Get time, when i-node content was last modified.
\r
114 * @param inode I-node
\r
115 * @return Time of the last content modification (POSIX)
\r
117 uint32_t ext4_inode_get_modification_time(struct ext4_inode *inode);
\r
119 /**@brief Set time, when i-node content was last modified.
\r
120 * @param inode I-node
\r
121 * @param time Time of the last content modification (POSIX)
\r
123 void ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time);
\r
125 /**@brief Get time, when i-node was deleted.
\r
126 * @param inode I-node
\r
127 * @return Time of the delete action (POSIX)
\r
129 uint32_t ext4_inode_get_deletion_time(struct ext4_inode *inode);
\r
131 /**@brief Set time, when i-node was deleted.
\r
132 * @param inode I-node
\r
133 * @param time Time of the delete action (POSIX)
\r
135 void ext4_inode_set_deletion_time(struct ext4_inode *inode, uint32_t time);
\r
137 /**@brief Get ID of the i-node owner's group.
\r
138 * @param inode I-node to load gid from
\r
139 * @return Group ID of the i-node owner
\r
141 uint32_t ext4_inode_get_gid(struct ext4_inode *inode);
\r
143 /**@brief Set ID ot the i-node owner's group.
\r
144 * @param inode I-node to set gid to
\r
145 * @param gid Group ID of the i-node owner
\r
147 void ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid);
\r
149 /**@brief Get number of links to i-node.
\r
150 * @param inode I-node to load number of links from
\r
151 * @return Number of links to i-node
\r
153 uint16_t ext4_inode_get_links_count(struct ext4_inode *inode);
\r
155 /**@brief Set number of links to i-node.
\r
156 * @param inode I-node to set number of links to
\r
157 * @param count Number of links to i-node
\r
159 void ext4_inode_set_links_count(struct ext4_inode *inode, uint16_t cnt);
\r
161 /**@brief Get number of 512-bytes blocks used for i-node.
\r
162 * @param sb Superblock
\r
163 * @param inode I-node
\r
164 * @return Number of 512-bytes blocks
\r
166 uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,
\r
167 struct ext4_inode *inode);
\r
169 /**@brief Set number of 512-bytes blocks used for i-node.
\r
170 * @param sb Superblock
\r
171 * @param inode I-node
\r
172 * @param count Number of 512-bytes blocks
\r
173 * @return Error code
\r
175 int ext4_inode_set_blocks_count(struct ext4_sblock *sb,
\r
176 struct ext4_inode *inode, uint64_t cnt);
\r
178 /**@brief Get flags (features) of i-node.
\r
179 * @param inode I-node to get flags from
\r
180 * @return Flags (bitmap)
\r
182 uint32_t ext4_inode_get_flags(struct ext4_inode *inode);
\r
184 /**@brief Set flags (features) of i-node.
\r
185 * @param inode I-node to set flags to
\r
186 * @param flags Flags to set to i-node
\r
188 void ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags);
\r
190 /**@brief Get file generation (used by NFS).
\r
191 * @param inode I-node
\r
192 * @return File generation
\r
194 uint32_t ext4_inode_get_generation(struct ext4_inode *inode);
\r
196 /**@brief Set file generation (used by NFS).
\r
197 * @param inode I-node
\r
198 * @param generation File generation
\r
200 void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen);
\r
202 /**@brief Get address of block, where are extended attributes located.
\r
203 * @param inode I-node
\r
204 * @param sb Superblock
\r
205 * @return Block address
\r
207 uint64_t ext4_inode_get_file_acl(struct ext4_inode *inode,
\r
208 struct ext4_sblock *sb);
\r
210 /**@brief Set address of block, where are extended attributes located.
\r
211 * @param inode I-node
\r
212 * @param sb Superblock
\r
213 * @param file_acl Block address
\r
215 void ext4_inode_set_file_acl(struct ext4_inode *inode, struct ext4_sblock *sb,
\r
218 /**@brief Get block address of specified direct block.
\r
219 * @param inode I-node to load block from
\r
220 * @param idx Index of logical block
\r
221 * @return Physical block address
\r
223 uint32_t ext4_inode_get_direct_block(struct ext4_inode *inode, uint32_t idx);
\r
225 /**@brief Set block address of specified direct block.
\r
226 * @param inode I-node to set block address to
\r
227 * @param idx Index of logical block
\r
228 * @param fblock Physical block address
\r
230 void ext4_inode_set_direct_block(struct ext4_inode *inode, uint32_t idx,
\r
233 /**@brief Get block address of specified indirect block.
\r
234 * @param inode I-node to get block address from
\r
235 * @param idx Index of indirect block
\r
236 * @return Physical block address
\r
238 uint32_t ext4_inode_get_indirect_block(struct ext4_inode *inode, uint32_t idx);
\r
240 /**@brief Set block address of specified indirect block.
\r
241 * @param inode I-node to set block address to
\r
242 * @param idx Index of indirect block
\r
243 * @param fblock Physical block address
\r
245 void ext4_inode_set_indirect_block(struct ext4_inode *inode, uint32_t idx,
\r
248 /**@brief Check if i-node has specified type.
\r
249 * @param sb Superblock
\r
250 * @param inode I-node to check type of
\r
251 * @param type Type to check
\r
252 * @return Result of check operation
\r
254 bool ext4_inode_is_type(struct ext4_sblock *sb, struct ext4_inode *inode,
\r
257 /**@brief Check if i-node has specified flag.
\r
258 * @param inode I-node to check flags of
\r
259 * @param flag Flag to check
\r
260 * @return Result of check operation
\r
262 bool ext4_inode_has_flag(struct ext4_inode *inode, uint32_t f);
\r
264 /**@brief Remove specified flag from i-node.
\r
265 * @param inode I-node to clear flag on
\r
266 * @param clear_flag Flag to be cleared
\r
268 void ext4_inode_clear_flag(struct ext4_inode *inode, uint32_t f);
\r
270 /**@brief Set specified flag to i-node.
\r
271 * @param inode I-node to set flag on
\r
272 * @param set_flag Flag to be set
\r
274 void ext4_inode_set_flag(struct ext4_inode *inode, uint32_t f);
\r
276 /**@brief Check if i-node can be truncated.
\r
277 * @param sb Superblock
\r
278 * @param inode I-node to check
\r
279 * @return Result of the check operation
\r
281 bool ext4_inode_can_truncate(struct ext4_sblock *sb, struct ext4_inode *inode);
\r
283 /**@brief Get extent header from the root of the extent tree.
\r
284 * @param inode I-node to get extent header from
\r
285 * @return Pointer to extent header of the root node
\r
287 struct ext4_extent_header *
\r
288 ext4_inode_get_extent_header(struct ext4_inode *inode);
\r
290 #endif /* EXT4_INODE_H_ */
\r