Merge branch 'master' of ted.mutabah.net:acess2
[tpg/acess2.git] / KernelLand / Modules / Filesystems / Ext2 / ext2fs.h
1 /**\r
2  * Acess2\r
3  * \file ext2fs.h\r
4  * \brief EXT2 Filesystem Driver\r
5  */\r
6 #ifndef _EXT2FS_H_\r
7 #define _EXT2FS_H_\r
8 \r
9 /**\r
10  \name Inode Flag Values\r
11  \{\r
12 */\r
13 #define EXT2_S_IFMT             0xF000  //!< Format Mask\r
14 #define EXT2_S_IFSOCK   0xC000  //!< Socket\r
15 #define EXT2_S_IFLNK    0xA000  //!< Symbolic Link\r
16 #define EXT2_S_IFREG    0x8000  //!< Regular File\r
17 #define EXT2_S_IFBLK    0x6000  //!< Block Device\r
18 #define EXT2_S_IFDIR    0x4000  //!< Directory\r
19 #define EXT2_S_IFCHR    0x2000  //!< Character Device\r
20 #define EXT2_S_IFIFO    0x1000  //!< FIFO\r
21 #define EXT2_S_ISUID    0x0800  //!< SUID\r
22 #define EXT2_S_ISGID    0x0400  //!< SGID\r
23 #define EXT2_S_ISVTX    0x0200  //!< sticky bit\r
24 #define EXT2_S_IRWXU    0700    //!< user access rights mask\r
25 #define EXT2_S_IRUSR    0400    //!< Owner Read\r
26 #define EXT2_S_IWUSR    0200    //!< Owner Write\r
27 #define EXT2_S_IXUSR    0100    //!< Owner Execute\r
28 #define EXT2_S_IRWXG    0070    //!< Group Access rights mask\r
29 #define EXT2_S_IRGRP    0040    //!< Group Read\r
30 #define EXT2_S_IWGRP    0020    //!< Group Write\r
31 #define EXT2_S_IXGRP    0010    //!< Group Execute\r
32 #define EXT2_S_IRWXO    0007    //!< Global Access rights mask\r
33 #define EXT2_S_IROTH    0004    //!< Global Read\r
34 #define EXT2_S_IWOTH    0002    //!< Global Write\r
35 #define EXT2_S_IXOTH    0001    //!< Global Execute\r
36 //! \}\r
37 \r
38 #define EXT2_NAME_LEN 255       //!< Maximum Name Length\r
39 \r
40 // === TYPEDEFS ===\r
41 typedef struct ext2_inode_s                     tExt2_Inode;    //!< Inode Type\r
42 typedef struct ext2_super_block_s       tExt2_SuperBlock;       //!< Superblock Type\r
43 typedef struct ext2_group_desc_s        tExt2_Group;    //!< Group Descriptor Type\r
44 typedef struct ext2_dir_entry_s         tExt2_DirEnt;   //!< Directory Entry Type\r
45 \r
46 // === STRUCTURES ===\r
47 /**\r
48  * \brief EXT2 Superblock Structure\r
49  */\r
50 struct ext2_super_block_s {\r
51         Uint32  s_inodes_count;         //!< Inodes count\r
52         Uint32  s_blocks_count;         //!< Blocks count\r
53         Uint32  s_r_blocks_count;       //!< Reserved blocks count\r
54         Uint32  s_free_blocks_count;    //!< Free blocks count\r
55         \r
56         Uint32  s_free_inodes_count;    //!< Free inodes count\r
57         Uint32  s_first_data_block;     //!< First Data Block\r
58         Uint32  s_log_block_size;       //!< Block size\r
59         Sint32  s_log_frag_size;        //!< Fragment size\r
60         \r
61         Uint32  s_blocks_per_group;     //!< Number Blocks per group\r
62         Uint32  s_frags_per_group;      //!< Number Fragments per group\r
63         Uint32  s_inodes_per_group;     //!< Number Inodes per group\r
64         Uint32  s_mtime;                        //!< Mount time\r
65         \r
66         Uint32  s_wtime;                        //!< Write time\r
67         Uint16  s_mnt_count;            //!< Mount count\r
68         Sint16  s_max_mnt_count;        //!< Maximal mount count\r
69         Uint16  s_magic;                        //!< Magic signature\r
70         Uint16  s_state;                        //!< File system state\r
71         Uint16  s_errors;                       //!< Behaviour when detecting errors\r
72         Uint16  s_pad;                          //!< Padding\r
73         \r
74         Uint32  s_lastcheck;            //!< time of last check\r
75         Uint32  s_checkinterval;        //!< max. time between checks\r
76         Uint32  s_creator_os;           //!< Formatting OS\r
77         Uint32  s_rev_level;            //!< Revision level\r
78         \r
79         Uint16  s_def_resuid;           //!< Default uid for reserved blocks\r
80         Uint16  s_def_resgid;           //!< Default gid for reserved blocks\r
81         Uint32  s_reserved[235];        //!< Padding to the end of the block\r
82 };\r
83 \r
84 /**\r
85  * \struct ext2_inode_s\r
86  * \brief EXT2 Inode Definition\r
87  */\r
88 struct ext2_inode_s {\r
89         Uint16 i_mode;  //!< File mode\r
90         Uint16 i_uid;   //!< Owner Uid\r
91         Uint32 i_size;  //!< Size in bytes\r
92         Uint32 i_atime; //!< Access time\r
93         Uint32 i_ctime; //!< Creation time\r
94         Uint32 i_mtime; //!< Modification time\r
95         Uint32 i_dtime; //!< Deletion Time\r
96         Uint16 i_gid;   //!< Group Id\r
97         Uint16 i_links_count;   //!< Links count\r
98         Uint32 i_blocks;        //!< Number of blocks allocated for the file\r
99         Uint32 i_flags; //!< File flags\r
100         union {\r
101                 Uint32 linux_reserved1; //!< Linux: Reserved\r
102                 Uint32 hurd_translator; //!< HURD: Translator\r
103                 Uint32 masix_reserved1; //!< Masix: Reserved\r
104         } osd1; //!< OS dependent 1\r
105         Uint32 i_block[15];     //!< Pointers to blocks\r
106         Uint32 i_version;       //!< File version (for NFS)\r
107         Uint32 i_file_acl;      //!< File ACL\r
108         Uint32 i_dir_acl;       //!< Directory ACL / Extended File Size\r
109         Uint32 i_faddr;         //!< Fragment address\r
110         union {\r
111                 struct {\r
112                         Uint8 l_i_frag; //!< Fragment number\r
113                         Uint8 l_i_fsize;        //!< Fragment size\r
114                         Uint16 i_pad1;  //!< Padding\r
115                         Uint32 l_i_reserved2[2];        //!< Reserved\r
116                 } linux2;\r
117                 struct {\r
118                         Uint8 h_i_frag; //!< Fragment number\r
119                         Uint8 h_i_fsize; //!< Fragment size\r
120                         Uint16 h_i_mode_high;   //!< Mode High Bits\r
121                         Uint16 h_i_uid_high;    //!< UID High Bits\r
122                         Uint16 h_i_gid_high;    //!< GID High Bits\r
123                         Uint32 h_i_author;      //!< Creator ID\r
124                 } hurd2;\r
125                 struct {\r
126                         Uint8 m_i_frag; //!< Fragment number\r
127                         Uint8 m_i_fsize;        //!< Fragment size\r
128                         Uint16 m_pad1;  //!< Padding\r
129                         Uint32 m_i_reserved2[2];        //!< reserved\r
130                 } masix2;\r
131         } osd2; //!< OS dependent 2\r
132 };\r
133 \r
134 /**\r
135  * \struct ext2_group_desc_s\r
136  * \brief EXT2 Group Descriptor\r
137  */\r
138 struct ext2_group_desc_s {\r
139         Uint32  bg_block_bitmap;        //!< Blocks bitmap block\r
140         Uint32  bg_inode_bitmap;        //!< Inodes bitmap block\r
141         Uint32  bg_inode_table; //!< Inodes table block\r
142         Uint16  bg_free_blocks_count;   //!< Free blocks count\r
143         Uint16  bg_free_inodes_count;   //!< Free inodes count\r
144         Uint16  bg_used_dirs_count;     //!< Directories count\r
145         Uint16  bg_pad; //!< Padding\r
146         Uint32  bg_reserved[3]; //!< Reserved\r
147 };\r
148 \r
149 /**\r
150  * \brief EXT2 Directory Entry\r
151  * \note The name may take up less than 255 characters\r
152  */\r
153 struct ext2_dir_entry_s {\r
154         Uint32  inode;          //!< Inode number\r
155         Uint16  rec_len;        //!< Directory entry length\r
156         Uint8   name_len;       //!< Short Name Length\r
157         Uint8   type;           //!< File Type (Duplicate of ext2_inode_s.i_mode)\r
158         char    name[EXT2_NAME_LEN+1];          //!< File name\r
159 };\r
160 #define EXT2_DIRENT_SIZE        (sizeof(struct ext2_dir_entry_s)-EXT2_NAME_LEN+1)\r
161 \r
162 #endif\r

UCC git Repository :: git.ucc.asn.au