Stop generating Eclipse project files by default
[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 #include <stdint.h>\r
47 \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
52  */\r
53 uint32_t ext4_inode_get_mode(struct ext4_sblock *sb, struct ext4_inode *inode);\r
54 \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
59  */\r
60 void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode,\r
61                          uint32_t mode);\r
62 \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
66  */\r
67 uint32_t ext4_inode_get_uid(struct ext4_inode *inode);\r
68 \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
72  */\r
73 void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid);\r
74 \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
79  */\r
80 uint64_t ext4_inode_get_size(struct ext4_sblock *sb, struct ext4_inode *inode);\r
81 \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
85  */\r
86 void ext4_inode_set_size(struct ext4_inode *inode, uint64_t size);\r
87 \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
91  */\r
92 uint32_t ext4_inode_get_access_time(struct ext4_inode *inode);\r
93 \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
97  */\r
98 void ext4_inode_set_access_time(struct ext4_inode *inode, uint32_t time);\r
99 \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
103  */\r
104 uint32_t ext4_inode_get_change_inode_time(struct ext4_inode *inode);\r
105 \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
109  */\r
110 void ext4_inode_set_change_inode_time(struct ext4_inode *inode, uint32_t time);\r
111 \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
115  */\r
116 uint32_t ext4_inode_get_modification_time(struct ext4_inode *inode);\r
117 \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
121  */\r
122 void ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time);\r
123 \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
127  */\r
128 uint32_t ext4_inode_get_deletion_time(struct ext4_inode *inode);\r
129 \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
133  */\r
134 void ext4_inode_set_deletion_time(struct ext4_inode *inode, uint32_t time);\r
135 \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
139  */\r
140 uint32_t ext4_inode_get_gid(struct ext4_inode *inode);\r
141 \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
145  */\r
146 void ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid);\r
147 \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
151  */\r
152 uint16_t ext4_inode_get_links_count(struct ext4_inode *inode);\r
153 \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
157  */\r
158 void ext4_inode_set_links_count(struct ext4_inode *inode, uint16_t cnt);\r
159 \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
164  */\r
165 uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,\r
166                                      struct ext4_inode *inode);\r
167 \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
173  */\r
174 int ext4_inode_set_blocks_count(struct ext4_sblock *sb,\r
175                                 struct ext4_inode *inode, uint64_t cnt);\r
176 \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
180  */\r
181 uint32_t ext4_inode_get_flags(struct ext4_inode *inode);\r
182 \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
186  */\r
187 void ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags);\r
188 \r
189 /**@brief Get file generation (used by NFS).\r
190  * @param inode I-node\r
191  * @return File generation\r
192  */\r
193 uint32_t ext4_inode_get_generation(struct ext4_inode *inode);\r
194 \r
195 /**@brief Set file generation (used by NFS).\r
196  * @param inode      I-node\r
197  * @param generation File generation\r
198  */\r
199 void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen);\r
200 \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
205  */\r
206 uint64_t ext4_inode_get_file_acl(struct ext4_inode *inode,\r
207                                  struct ext4_sblock *sb);\r
208 \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
213  */\r
214 void ext4_inode_set_file_acl(struct ext4_inode *inode, struct ext4_sblock *sb,\r
215                              uint64_t acl);\r
216 \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
221  */\r
222 uint32_t ext4_inode_get_direct_block(struct ext4_inode *inode, uint32_t idx);\r
223 \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
228  */\r
229 void ext4_inode_set_direct_block(struct ext4_inode *inode, uint32_t idx,\r
230                                  uint32_t block);\r
231 \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
236  */\r
237 uint32_t ext4_inode_get_indirect_block(struct ext4_inode *inode, uint32_t idx);\r
238 \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
243  */\r
244 void ext4_inode_set_indirect_block(struct ext4_inode *inode, uint32_t idx,\r
245                                    uint32_t block);\r
246 \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
252  */\r
253 bool ext4_inode_is_type(struct ext4_sblock *sb, struct ext4_inode *inode,\r
254                         uint32_t type);\r
255 \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
260  */\r
261 bool ext4_inode_has_flag(struct ext4_inode *inode, uint32_t f);\r
262 \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
266  */\r
267 void ext4_inode_clear_flag(struct ext4_inode *inode, uint32_t f);\r
268 \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
272  */\r
273 void ext4_inode_set_flag(struct ext4_inode *inode, uint32_t f);\r
274 \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
279  */\r
280 bool ext4_inode_can_truncate(struct ext4_sblock *sb, struct ext4_inode *inode);\r
281 \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
285  */\r
286 struct ext4_extent_header *\r
287 ext4_inode_get_extent_header(struct ext4_inode *inode);\r
288 \r
289 #endif /* EXT4_INODE_H_ */\r
290 \r
291 /**\r
292  * @}\r
293  */\r