1 | /*
|
---|
2 | * Copyright (c) 2011 Frantisek Princ
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup libext4
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 |
|
---|
33 | #ifndef LIBEXT4_LIBEXT4_INODE_H_
|
---|
34 | #define LIBEXT4_LIBEXT4_INODE_H_
|
---|
35 |
|
---|
36 | #include <libblock.h>
|
---|
37 | #include <sys/types.h>
|
---|
38 |
|
---|
39 | // TODO better constant definition !!!
|
---|
40 | #define EXT4_N_BLOCKS 15
|
---|
41 |
|
---|
42 | /*
|
---|
43 | * Structure of an inode on the disk
|
---|
44 | */
|
---|
45 | typedef struct ext4_inode {
|
---|
46 | uint16_t i_mode; // File mode
|
---|
47 | uint16_t i_uid; // Low 16 bits of owner uid
|
---|
48 | uint32_t i_size_lo; // Size in bytes
|
---|
49 | uint32_t i_atime; // Access time
|
---|
50 | uint32_t i_ctime; // Inode change time
|
---|
51 | uint32_t i_mtime; // Modification time
|
---|
52 | uint32_t i_dtime; // Deletion time
|
---|
53 | uint16_t i_gid; // Low 16 bits of group id
|
---|
54 | uint16_t i_links_count; // Links count
|
---|
55 | uint32_t i_blocks_lo; // Blocks count
|
---|
56 | uint32_t i_flags; // File flags
|
---|
57 |
|
---|
58 | /*
|
---|
59 | union {
|
---|
60 | struct {
|
---|
61 | __le32 l_i_version;
|
---|
62 | } linux1;
|
---|
63 | struct {
|
---|
64 | __u32 h_i_translator;
|
---|
65 | } hurd1;
|
---|
66 | struct {
|
---|
67 | __u32 m_i_reserved1;
|
---|
68 | } masix1;
|
---|
69 | } osd1;
|
---|
70 | */
|
---|
71 | uint32_t unused_osd1; // OS dependent - not used in HelenOS
|
---|
72 |
|
---|
73 | uint32_t i_block[EXT4_N_BLOCKS]; // Pointers to blocks
|
---|
74 | uint32_t i_generation; // File version (for NFS)
|
---|
75 | uint32_t i_file_acl_lo; // File ACL
|
---|
76 | uint32_t i_size_high;
|
---|
77 | uint32_t i_obso_faddr; // Obsoleted fragment address
|
---|
78 |
|
---|
79 | /*
|
---|
80 | union {
|
---|
81 | struct {
|
---|
82 | __le16 l_i_blocks_high;
|
---|
83 | __le16 l_i_file_acl_high;
|
---|
84 | __le16 l_i_uid_high;
|
---|
85 | __le16 l_i_gid_high;
|
---|
86 | __u32 l_i_reserved2;
|
---|
87 | } linux2;
|
---|
88 | struct {
|
---|
89 | __le16 h_i_reserved1;
|
---|
90 | __u16 h_i_mode_high;
|
---|
91 | __u16 h_i_uid_high;
|
---|
92 | __u16 h_i_gid_high;
|
---|
93 | __u32 h_i_author;
|
---|
94 | } hurd2;
|
---|
95 | struct {
|
---|
96 | __le16 h_i_reserved1;
|
---|
97 | __le16 m_i_file_acl_high;
|
---|
98 | __u32 m_i_reserved2[2];
|
---|
99 | } masix2;
|
---|
100 | } osd2;
|
---|
101 | */
|
---|
102 |
|
---|
103 | uint32_t unused_osd2[3]; // OS dependent - not used in HelenOS
|
---|
104 | uint16_t i_extra_isize;
|
---|
105 | uint16_t i_pad1;
|
---|
106 | uint32_t i_ctime_extra; // Extra change time (nsec << 2 | epoch)
|
---|
107 | uint32_t i_mtime_extra; // Extra Modification time (nsec << 2 | epoch)
|
---|
108 | uint32_t i_atime_extra; // Extra Access time (nsec << 2 | epoch)
|
---|
109 | uint32_t i_crtime; // File creation time
|
---|
110 | uint32_t i_crtime_extra; // Extra file creation time (nsec << 2 | epoch)
|
---|
111 | uint32_t i_version_hi; // High 32 bits for 64-bit version
|
---|
112 | } __attribute__ ((packed)) ext4_inode_t;
|
---|
113 |
|
---|
114 |
|
---|
115 | // TODO check value
|
---|
116 | #define EXT4_INODE_ROOT_INDEX 2
|
---|
117 |
|
---|
118 | typedef struct ext4_inode_ref {
|
---|
119 | block_t *block; // Reference to a block containing this inode
|
---|
120 | ext4_inode_t *inode;
|
---|
121 | uint32_t index; // Index number of this inode
|
---|
122 | } ext4_inode_ref_t;
|
---|
123 |
|
---|
124 | extern uint16_t ext4_inode_get_usage_count(ext4_inode_t *);
|
---|
125 |
|
---|
126 | #endif
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * @}
|
---|
130 | */
|
---|