Improve include policy
[lwext4.git] / lwext4 / ext4_inode.h
1 /*\r
2  * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)\r
3  *\r
4  *\r
5  * HelenOS:\r
6  * Copyright (c) 2012 Martin Sucha\r
7  * Copyright (c) 2012 Frantisek Princ\r
8  * All rights reserved.\r
9  *\r
10  * Redistribution and use in source and binary forms, with or without\r
11  * modification, are permitted provided that the following conditions\r
12  * are met:\r
13  *\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
21  *\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
32  */\r
33 \r
34 /** @addtogroup lwext4\r
35  * @{\r
36  */\r
37 /**\r
38  * @file  ext4_inode.h\r
39  * @brief Inode handle functions\r
40  */\r
41 \r
42 #ifndef EXT4_INODE_H_\r
43 #define EXT4_INODE_H_\r
44 \r
45 #include "ext4_config.h"\r
46 \r
47 #include <stdint.h>\r
48 \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
53  */\r
54 uint32_t ext4_inode_get_mode(struct ext4_sblock *sb, struct ext4_inode *inode);\r
55 \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
60  */\r
61 void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode,\r
62                          uint32_t mode);\r
63 \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
67  */\r
68 uint32_t ext4_inode_get_uid(struct ext4_inode *inode);\r
69 \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
73  */\r
74 void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid);\r
75 \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
80  */\r
81 uint64_t ext4_inode_get_size(struct ext4_sblock *sb, struct ext4_inode *inode);\r
82 \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
86  */\r
87 void ext4_inode_set_size(struct ext4_inode *inode, uint64_t size);\r
88 \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
92  */\r
93 uint32_t ext4_inode_get_access_time(struct ext4_inode *inode);\r
94 \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
98  */\r
99 void ext4_inode_set_access_time(struct ext4_inode *inode, uint32_t time);\r
100 \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
104  */\r
105 uint32_t ext4_inode_get_change_inode_time(struct ext4_inode *inode);\r
106 \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
110  */\r
111 void ext4_inode_set_change_inode_time(struct ext4_inode *inode, uint32_t time);\r
112 \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
116  */\r
117 uint32_t ext4_inode_get_modification_time(struct ext4_inode *inode);\r
118 \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
122  */\r
123 void ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time);\r
124 \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
128  */\r
129 uint32_t ext4_inode_get_deletion_time(struct ext4_inode *inode);\r
130 \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
134  */\r
135 void ext4_inode_set_deletion_time(struct ext4_inode *inode, uint32_t time);\r
136 \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
140  */\r
141 uint32_t ext4_inode_get_gid(struct ext4_inode *inode);\r
142 \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
146  */\r
147 void ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid);\r
148 \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
152  */\r
153 uint16_t ext4_inode_get_links_count(struct ext4_inode *inode);\r
154 \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
158  */\r
159 void ext4_inode_set_links_count(struct ext4_inode *inode, uint16_t cnt);\r
160 \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
165  */\r
166 uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,\r
167                                      struct ext4_inode *inode);\r
168 \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
174  */\r
175 int ext4_inode_set_blocks_count(struct ext4_sblock *sb,\r
176                                 struct ext4_inode *inode, uint64_t cnt);\r
177 \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
181  */\r
182 uint32_t ext4_inode_get_flags(struct ext4_inode *inode);\r
183 \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
187  */\r
188 void ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags);\r
189 \r
190 /**@brief Get file generation (used by NFS).\r
191  * @param inode I-node\r
192  * @return File generation\r
193  */\r
194 uint32_t ext4_inode_get_generation(struct ext4_inode *inode);\r
195 \r
196 /**@brief Set file generation (used by NFS).\r
197  * @param inode      I-node\r
198  * @param generation File generation\r
199  */\r
200 void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen);\r
201 \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
206  */\r
207 uint64_t ext4_inode_get_file_acl(struct ext4_inode *inode,\r
208                                  struct ext4_sblock *sb);\r
209 \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
214  */\r
215 void ext4_inode_set_file_acl(struct ext4_inode *inode, struct ext4_sblock *sb,\r
216                              uint64_t acl);\r
217 \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
222  */\r
223 uint32_t ext4_inode_get_direct_block(struct ext4_inode *inode, uint32_t idx);\r
224 \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
229  */\r
230 void ext4_inode_set_direct_block(struct ext4_inode *inode, uint32_t idx,\r
231                                  uint32_t block);\r
232 \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
237  */\r
238 uint32_t ext4_inode_get_indirect_block(struct ext4_inode *inode, uint32_t idx);\r
239 \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
244  */\r
245 void ext4_inode_set_indirect_block(struct ext4_inode *inode, uint32_t idx,\r
246                                    uint32_t block);\r
247 \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
253  */\r
254 bool ext4_inode_is_type(struct ext4_sblock *sb, struct ext4_inode *inode,\r
255                         uint32_t type);\r
256 \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
261  */\r
262 bool ext4_inode_has_flag(struct ext4_inode *inode, uint32_t f);\r
263 \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
267  */\r
268 void ext4_inode_clear_flag(struct ext4_inode *inode, uint32_t f);\r
269 \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
273  */\r
274 void ext4_inode_set_flag(struct ext4_inode *inode, uint32_t f);\r
275 \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
280  */\r
281 bool ext4_inode_can_truncate(struct ext4_sblock *sb, struct ext4_inode *inode);\r
282 \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
286  */\r
287 struct ext4_extent_header *\r
288 ext4_inode_get_extent_header(struct ext4_inode *inode);\r
289 \r
290 #endif /* EXT4_INODE_H_ */\r
291 \r
292 /**\r
293  * @}\r
294  */\r