Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenext2.h
Go to the documentation of this file.
00001 /* 00002 * FreeLoader 00003 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #pragma once 00021 00022 /* 00023 * grub/fs/ext2.c 00024 * 00025 * GRUB -- GRand Unified Bootloader 00026 * Copyright (C) 2003,2004,2005,2007 Free Software Foundation, Inc. 00027 * 00028 * This program is free software; you can redistribute it and/or modify 00029 * it under the terms of the GNU General Public License as published by 00030 * the Free Software Foundation; either version 2 of the License, or 00031 * (at your option) any later version. 00032 * 00033 * This program is distributed in the hope that it will be useful, 00034 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00035 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00036 * GNU General Public License for more details. 00037 * 00038 * You should have received a copy of the GNU General Public License 00039 * along with GRUB. If not, see <http://www.gnu.org/licenses/>. 00040 */ 00041 00042 /* Magic value used to identify an ext2 filesystem. */ 00043 #define EXT2_MAGIC 0xEF53 00044 /* Amount of indirect blocks in an inode. */ 00045 #define INDIRECT_BLOCKS 12 00046 /* Maximum lenght of a pathname. */ 00047 #define EXT2_PATH_MAX 4096 00048 /* Maximum nesting of symlinks, used to prevent a loop. */ 00049 #define EXT2_MAX_SYMLINKCNT 8 00050 00051 /* The good old revision and the default inode size. */ 00052 #define EXT2_GOOD_OLD_REVISION 0 00053 #define EXT2_DYNAMIC_REVISION 1 00054 #define EXT2_GOOD_OLD_INODE_SIZE 128 00055 00056 /* Filetype used in directory entry. */ 00057 #define FILETYPE_UNKNOWN 0 00058 #define FILETYPE_REG 1 00059 #define FILETYPE_DIRECTORY 2 00060 #define FILETYPE_SYMLINK 7 00061 00062 /* Filetype information as used in inodes. */ 00063 #define FILETYPE_INO_MASK 0170000 00064 #define FILETYPE_INO_REG 0100000 00065 #define FILETYPE_INO_DIRECTORY 0040000 00066 #define FILETYPE_INO_SYMLINK 0120000 00067 00068 /* The ext2 superblock. */ 00069 struct ext2_sblock 00070 { 00071 ULONG total_inodes; 00072 ULONG total_blocks; 00073 ULONG reserved_blocks; 00074 ULONG free_blocks; 00075 ULONG free_inodes; 00076 ULONG first_data_block; 00077 ULONG log2_block_size; 00078 LONG log2_fragment_size; 00079 ULONG blocks_per_group; 00080 ULONG fragments_per_group; 00081 ULONG inodes_per_group; 00082 ULONG mtime; 00083 ULONG utime; 00084 USHORT mnt_count; 00085 USHORT max_mnt_count; 00086 USHORT magic; 00087 USHORT fs_state; 00088 USHORT error_handling; 00089 USHORT minor_revision_level; 00090 ULONG lastcheck; 00091 ULONG checkinterval; 00092 ULONG creator_os; 00093 ULONG revision_level; 00094 USHORT uid_reserved; 00095 USHORT gid_reserved; 00096 ULONG first_inode; 00097 USHORT inode_size; 00098 USHORT block_group_number; 00099 ULONG feature_compatibility; 00100 ULONG feature_incompat; 00101 ULONG feature_ro_compat; 00102 ULONG unique_id[4]; 00103 char volume_name[16]; 00104 char last_mounted_on[64]; 00105 ULONG compression_info; 00106 ULONG padding[77]; 00107 }; 00108 00109 /* The ext2 blockgroup. */ 00110 struct ext2_block_group 00111 { 00112 ULONG block_id; 00113 ULONG inode_id; 00114 ULONG inode_table_id; 00115 USHORT free_blocks; 00116 USHORT free_inodes; 00117 USHORT used_dirs; 00118 USHORT pad; 00119 ULONG reserved[3]; 00120 }; 00121 00122 /* The ext2 inode. */ 00123 struct ext2_inode 00124 { 00125 USHORT mode; 00126 USHORT uid; 00127 ULONG size; 00128 ULONG atime; 00129 ULONG ctime; 00130 ULONG mtime; 00131 ULONG dtime; 00132 USHORT gid; 00133 USHORT nlinks; 00134 ULONG blockcnt; /* Blocks of 512 bytes!! */ 00135 ULONG flags; 00136 ULONG osd1; 00137 union 00138 { 00139 struct datablocks 00140 { 00141 ULONG dir_blocks[INDIRECT_BLOCKS]; 00142 ULONG indir_block; 00143 ULONG double_indir_block; 00144 ULONG tripple_indir_block; 00145 } blocks; 00146 char symlink[60]; 00147 }; 00148 ULONG version; 00149 ULONG acl; 00150 ULONG dir_acl; 00151 ULONG fragment_addr; 00152 ULONG osd2[3]; 00153 }; 00154 00155 /* The header of an ext2 directory entry. */ 00156 #define EXT2_NAME_LEN 255 00157 00158 struct ext2_dirent 00159 { 00160 ULONG inode; 00161 USHORT direntlen; 00162 UCHAR namelen; 00163 UCHAR filetype; 00164 CHAR name[EXT2_NAME_LEN]; 00165 }; 00166 00167 /* 00168 * End of code from grub/fs/ext2.c 00169 */ 00170 00171 typedef struct ext2_sblock EXT2_SUPER_BLOCK, *PEXT2_SUPER_BLOCK; 00172 typedef struct ext2_inode EXT2_INODE, *PEXT2_INODE; 00173 typedef struct ext2_block_group EXT2_GROUP_DESC, *PEXT2_GROUP_DESC; 00174 typedef struct ext2_dirent EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY; 00175 00176 /* Special inode numbers. */ 00177 #define EXT2_ROOT_INO 2 00178 00179 /* Feature set definitions. */ 00180 #define EXT3_FEATURE_INCOMPAT_SUPP 0x0002 00181 00182 /* Log2 size of ext2 block in bytes. */ 00183 #define LOG2_BLOCK_SIZE(sb) (sb->log2_block_size + 10) 00184 00185 /* The size of an ext2 block in bytes. */ 00186 #define EXT2_BLOCK_SIZE(sb) (((SIZE_T)1) << LOG2_BLOCK_SIZE(sb)) 00187 00188 /* The revision level. */ 00189 #define EXT2_REVISION(sb) (sb->revision_level) 00190 00191 /* The inode size. */ 00192 #define EXT2_INODE_SIZE(sb) (EXT2_REVISION(sb) == EXT2_GOOD_OLD_REVISION \ 00193 ? EXT2_GOOD_OLD_INODE_SIZE \ 00194 : sb->inode_size) 00195 00196 #define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(struct ext2_block_group)) 00197 00198 // EXT2_INODE::mode values 00199 #define EXT2_S_IRWXO 0x0007 // Other mask 00200 #define EXT2_S_IXOTH 0x0001 // ---------x execute 00201 #define EXT2_S_IWOTH 0x0002 // --------w- write 00202 #define EXT2_S_IROTH 0x0004 // -------r-- read 00203 00204 #define EXT2_S_IRWXG 0x0038 // Group mask 00205 #define EXT2_S_IXGRP 0x0008 // ------x--- execute 00206 #define EXT2_S_IWGRP 0x0010 // -----w---- write 00207 #define EXT2_S_IRGRP 0x0020 // ----r----- read 00208 00209 #define EXT2_S_IRWXU 0x01C0 // User mask 00210 #define EXT2_S_IXUSR 0x0040 // ---x------ execute 00211 #define EXT2_S_IWUSR 0x0080 // --w------- write 00212 #define EXT2_S_IRUSR 0x0100 // -r-------- read 00213 00214 #define EXT2_S_ISVTX 0x0200 // Sticky bit 00215 #define EXT2_S_ISGID 0x0400 // SGID 00216 #define EXT2_S_ISUID 0x0800 // SUID 00217 00218 #define EXT2_S_IFMT 0xF000 // Format mask 00219 #define EXT2_S_IFIFO 0x1000 // FIFO buffer 00220 #define EXT2_S_IFCHR 0x2000 // Character device 00221 #define EXT2_S_IFDIR 0x4000 // Directory 00222 #define EXT2_S_IFBLK 0x6000 // Block device 00223 #define EXT2_S_IFREG 0x8000 // Regular file 00224 #define EXT2_S_IFLNK 0xA000 // Symbolic link 00225 #define EXT2_S_IFSOCK 0xC000 // Socket 00226 00227 #define FAST_SYMLINK_MAX_NAME_SIZE 60 00228 00229 typedef struct 00230 { 00231 ULONGLONG FileSize; // File size 00232 ULONGLONG FilePointer; // File pointer 00233 ULONG* FileBlockList; // File block list 00234 UCHAR DriveNumber; // Drive number of open file 00235 EXT2_INODE Inode; // File's inode 00236 } EXT2_FILE_INFO, * PEXT2_FILE_INFO; 00237 00238 const DEVVTBL* Ext2Mount(ULONG DeviceId); Generated on Sun May 27 2012 04:19:14 for ReactOS by
1.7.6.1
|