Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * linux/include/linux/ext2_fs.h |
| 3 | * |
| 4 | * Copyright (C) 1992, 1993, 1994, 1995 |
| 5 | * Remy Card (card@masi.ibp.fr) |
| 6 | * Laboratoire MASI - Institut Blaise Pascal |
| 7 | * Universite Pierre et Marie Curie (Paris VI) |
| 8 | * |
| 9 | * from |
| 10 | * |
| 11 | * linux/include/linux/minix_fs.h |
| 12 | * |
| 13 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 14 | */ |
| 15 | |
| 16 | #ifndef _LINUX_EXT2_FS_H |
| 17 | #define _LINUX_EXT2_FS_H |
| 18 | |
Theodore Ts'o | defde78 | 1999-01-04 07:39:19 +0000 | [diff] [blame] | 19 | #include <asm/types.h> /* Changed from linux/types.h */ |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 20 | |
| 21 | /* |
| 22 | * The second extended filesystem constants/structures |
| 23 | */ |
| 24 | |
| 25 | /* |
| 26 | * Define EXT2FS_DEBUG to produce debug messages |
| 27 | */ |
| 28 | #undef EXT2FS_DEBUG |
| 29 | |
| 30 | /* |
| 31 | * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files |
| 32 | */ |
| 33 | #define EXT2_PREALLOCATE |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 34 | #define EXT2_DEFAULT_PREALLOC_BLOCKS 8 |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 35 | |
| 36 | /* |
| 37 | * The second extended file system version |
| 38 | */ |
| 39 | #define EXT2FS_DATE "95/08/09" |
| 40 | #define EXT2FS_VERSION "0.5b" |
| 41 | |
| 42 | /* |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 43 | * Special inodes numbers |
| 44 | */ |
| 45 | #define EXT2_BAD_INO 1 /* Bad blocks inode */ |
| 46 | #define EXT2_ROOT_INO 2 /* Root inode */ |
| 47 | #define EXT2_ACL_IDX_INO 3 /* ACL inode */ |
| 48 | #define EXT2_ACL_DATA_INO 4 /* ACL inode */ |
| 49 | #define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ |
| 50 | #define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 51 | |
| 52 | /* First non-reserved inode for old ext2 filesystems */ |
| 53 | #define EXT2_GOOD_OLD_FIRST_INO 11 |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 54 | |
| 55 | /* |
| 56 | * The second extended file system magic number |
| 57 | */ |
| 58 | #define EXT2_SUPER_MAGIC 0xEF53 |
| 59 | |
| 60 | /* |
| 61 | * Maximal count of links to a file |
| 62 | */ |
| 63 | #define EXT2_LINK_MAX 32000 |
| 64 | |
| 65 | /* |
| 66 | * Macro-instructions used to manage several block sizes |
| 67 | */ |
| 68 | #define EXT2_MIN_BLOCK_SIZE 1024 |
| 69 | #define EXT2_MAX_BLOCK_SIZE 4096 |
| 70 | #define EXT2_MIN_BLOCK_LOG_SIZE 10 |
| 71 | #ifdef __KERNEL__ |
| 72 | # define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize) |
| 73 | #else |
| 74 | # define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) |
| 75 | #endif |
| 76 | #define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry)) |
| 77 | #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32)) |
| 78 | #ifdef __KERNEL__ |
| 79 | # define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) |
| 80 | #else |
| 81 | # define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) |
| 82 | #endif |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 83 | #ifdef __KERNEL__ |
| 84 | #define EXT2_ADDR_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_addr_per_block_bits) |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 85 | #define EXT2_INODE_SIZE(s) ((s)->u.ext2_sb.s_inode_size) |
| 86 | #define EXT2_FIRST_INO(s) ((s)->u.ext2_sb.s_first_ino) |
| 87 | #else |
| 88 | #define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ |
| 89 | EXT2_GOOD_OLD_INODE_SIZE : \ |
| 90 | (s)->s_inode_size) |
| 91 | #define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ |
| 92 | EXT2_GOOD_OLD_FIRST_INO : \ |
| 93 | (s)->s_first_ino) |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 94 | #endif |
| 95 | |
| 96 | /* |
| 97 | * Macro-instructions used to manage fragments |
| 98 | */ |
| 99 | #define EXT2_MIN_FRAG_SIZE 1024 |
| 100 | #define EXT2_MAX_FRAG_SIZE 4096 |
| 101 | #define EXT2_MIN_FRAG_LOG_SIZE 10 |
| 102 | #ifdef __KERNEL__ |
| 103 | # define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size) |
| 104 | # define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block) |
| 105 | #else |
| 106 | # define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) |
| 107 | # define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) |
| 108 | #endif |
| 109 | |
| 110 | /* |
| 111 | * ACL structures |
| 112 | */ |
| 113 | struct ext2_acl_header /* Header of Access Control Lists */ |
| 114 | { |
| 115 | __u32 aclh_size; |
| 116 | __u32 aclh_file_count; |
| 117 | __u32 aclh_acle_count; |
| 118 | __u32 aclh_first_acle; |
| 119 | }; |
| 120 | |
| 121 | struct ext2_acl_entry /* Access Control List Entry */ |
| 122 | { |
| 123 | __u32 acle_size; |
| 124 | __u16 acle_perms; /* Access permissions */ |
| 125 | __u16 acle_type; /* Type of entry */ |
| 126 | __u16 acle_tag; /* User or group identity */ |
| 127 | __u16 acle_pad1; |
| 128 | __u32 acle_next; /* Pointer on next entry for the */ |
| 129 | /* same inode or on next free entry */ |
| 130 | }; |
| 131 | |
| 132 | /* |
| 133 | * Structure of a blocks group descriptor |
| 134 | */ |
| 135 | struct ext2_group_desc |
| 136 | { |
| 137 | __u32 bg_block_bitmap; /* Blocks bitmap block */ |
| 138 | __u32 bg_inode_bitmap; /* Inodes bitmap block */ |
| 139 | __u32 bg_inode_table; /* Inodes table block */ |
| 140 | __u16 bg_free_blocks_count; /* Free blocks count */ |
| 141 | __u16 bg_free_inodes_count; /* Free inodes count */ |
| 142 | __u16 bg_used_dirs_count; /* Directories count */ |
| 143 | __u16 bg_pad; |
| 144 | __u32 bg_reserved[3]; |
| 145 | }; |
| 146 | |
| 147 | /* |
| 148 | * Macro-instructions used to manage group descriptors |
| 149 | */ |
| 150 | #ifdef __KERNEL__ |
| 151 | # define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group) |
| 152 | # define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block) |
| 153 | # define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group) |
| 154 | # define EXT2_DESC_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_desc_per_block_bits) |
| 155 | #else |
| 156 | # define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) |
| 157 | # define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) |
| 158 | # define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) |
| 159 | #endif |
| 160 | |
| 161 | /* |
| 162 | * Constants relative to the data blocks |
| 163 | */ |
| 164 | #define EXT2_NDIR_BLOCKS 12 |
| 165 | #define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS |
| 166 | #define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) |
| 167 | #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) |
| 168 | #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) |
| 169 | |
| 170 | /* |
| 171 | * Inode flags |
| 172 | */ |
| 173 | #define EXT2_SECRM_FL 0x00000001 /* Secure deletion */ |
| 174 | #define EXT2_UNRM_FL 0x00000002 /* Undelete */ |
| 175 | #define EXT2_COMPR_FL 0x00000004 /* Compress file */ |
| 176 | #define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */ |
| 177 | #define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */ |
| 178 | #define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */ |
| 179 | #define EXT2_NODUMP_FL 0x00000040 /* do not dump file */ |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 180 | #define EXT2_NOATIME_FL 0x00000080 /* do not update atime */ |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 181 | /* Reserved for compression usage... */ |
| 182 | #define EXT2_DIRTY_FL 0x00000100 |
| 183 | #define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */ |
Theodore Ts'o | 906e1f1 | 2000-04-03 13:48:52 +0000 | [diff] [blame] | 184 | #define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */ |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 185 | #define EXT2_ECOMPR_FL 0x00000800 /* Compression error */ |
| 186 | /* End compression flags --- maybe not all used */ |
| 187 | #define EXT2_BTREE_FL 0x00001000 /* btree format dir */ |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 188 | #define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 189 | |
| 190 | #define EXT2_FL_USER_VISIBLE 0x00001FFF /* User visible flags */ |
| 191 | #define EXT2_FL_USER_MODIFIABLE 0x000000FF /* User modifiable flags */ |
| 192 | |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 193 | /* |
| 194 | * ioctl commands |
| 195 | */ |
| 196 | #define EXT2_IOC_GETFLAGS _IOR('f', 1, long) |
| 197 | #define EXT2_IOC_SETFLAGS _IOW('f', 2, long) |
| 198 | #define EXT2_IOC_GETVERSION _IOR('v', 1, long) |
| 199 | #define EXT2_IOC_SETVERSION _IOW('v', 2, long) |
| 200 | |
| 201 | /* |
| 202 | * Structure of an inode on the disk |
| 203 | */ |
| 204 | struct ext2_inode { |
| 205 | __u16 i_mode; /* File mode */ |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 206 | __u16 i_uid; /* Low 16 bits of Owner Uid */ |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 207 | __u32 i_size; /* Size in bytes */ |
| 208 | __u32 i_atime; /* Access time */ |
| 209 | __u32 i_ctime; /* Creation time */ |
| 210 | __u32 i_mtime; /* Modification time */ |
| 211 | __u32 i_dtime; /* Deletion Time */ |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 212 | __u16 i_gid; /* Low 16 bits of Group Id */ |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 213 | __u16 i_links_count; /* Links count */ |
| 214 | __u32 i_blocks; /* Blocks count */ |
| 215 | __u32 i_flags; /* File flags */ |
| 216 | union { |
| 217 | struct { |
| 218 | __u32 l_i_reserved1; |
| 219 | } linux1; |
| 220 | struct { |
| 221 | __u32 h_i_translator; |
| 222 | } hurd1; |
| 223 | struct { |
| 224 | __u32 m_i_reserved1; |
| 225 | } masix1; |
| 226 | } osd1; /* OS dependent 1 */ |
| 227 | __u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 228 | __u32 i_generation; /* File version (for NFS) */ |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 229 | __u32 i_file_acl; /* File ACL */ |
| 230 | __u32 i_dir_acl; /* Directory ACL */ |
| 231 | __u32 i_faddr; /* Fragment address */ |
| 232 | union { |
| 233 | struct { |
| 234 | __u8 l_i_frag; /* Fragment number */ |
| 235 | __u8 l_i_fsize; /* Fragment size */ |
| 236 | __u16 i_pad1; |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 237 | __u16 l_i_uid_high; /* these 2 fields */ |
| 238 | __u16 l_i_gid_high; /* were reserved2[0] */ |
| 239 | __u32 l_i_reserved2; |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 240 | } linux2; |
| 241 | struct { |
| 242 | __u8 h_i_frag; /* Fragment number */ |
| 243 | __u8 h_i_fsize; /* Fragment size */ |
| 244 | __u16 h_i_mode_high; |
| 245 | __u16 h_i_uid_high; |
| 246 | __u16 h_i_gid_high; |
| 247 | __u32 h_i_author; |
| 248 | } hurd2; |
| 249 | struct { |
| 250 | __u8 m_i_frag; /* Fragment number */ |
| 251 | __u8 m_i_fsize; /* Fragment size */ |
| 252 | __u16 m_pad1; |
| 253 | __u32 m_i_reserved2[2]; |
| 254 | } masix2; |
| 255 | } osd2; /* OS dependent 2 */ |
| 256 | }; |
| 257 | |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 258 | #define i_size_high i_dir_acl |
| 259 | |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 260 | #if defined(__KERNEL__) || defined(__linux__) |
| 261 | #define i_reserved1 osd1.linux1.l_i_reserved1 |
| 262 | #define i_frag osd2.linux2.l_i_frag |
| 263 | #define i_fsize osd2.linux2.l_i_fsize |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 264 | #define i_uid_low i_uid |
| 265 | #define i_gid_low i_gid |
| 266 | #define i_uid_high osd2.linux2.l_i_uid_high |
| 267 | #define i_gid_high osd2.linux2.l_i_gid_high |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 268 | #define i_reserved2 osd2.linux2.l_i_reserved2 |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 269 | |
Theodore Ts'o | 601002b | 1999-10-26 02:06:39 +0000 | [diff] [blame] | 270 | #elif defined(__GNU__) |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 271 | |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 272 | #define i_translator osd1.hurd1.h_i_translator |
| 273 | #define i_frag osd2.hurd2.h_i_frag; |
| 274 | #define i_fsize osd2.hurd2.h_i_fsize; |
| 275 | #define i_uid_high osd2.hurd2.h_i_uid_high |
| 276 | #define i_gid_high osd2.hurd2.h_i_gid_high |
| 277 | #define i_author osd2.hurd2.h_i_author |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 278 | |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 279 | #elif defined(__masix__) |
| 280 | |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 281 | #define i_reserved1 osd1.masix1.m_i_reserved1 |
| 282 | #define i_frag osd2.masix2.m_i_frag |
| 283 | #define i_fsize osd2.masix2.m_i_fsize |
| 284 | #define i_reserved2 osd2.masix2.m_i_reserved2 |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 285 | |
| 286 | #endif /* defined(__KERNEL) || defined(__linux__) */ |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 287 | |
| 288 | /* |
| 289 | * File system states |
| 290 | */ |
| 291 | #define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ |
| 292 | #define EXT2_ERROR_FS 0x0002 /* Errors detected */ |
| 293 | |
| 294 | /* |
| 295 | * Mount flags |
| 296 | */ |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 297 | #define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */ |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 298 | #define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ |
| 299 | #define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ |
| 300 | #define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ |
| 301 | #define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ |
| 302 | #define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ |
| 303 | #define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */ |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 304 | #define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */ |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 305 | |
| 306 | #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt |
| 307 | #define set_opt(o, opt) o |= EXT2_MOUNT_##opt |
| 308 | #define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \ |
| 309 | EXT2_MOUNT_##opt) |
| 310 | /* |
| 311 | * Maximal mount counts between two filesystem checks |
| 312 | */ |
| 313 | #define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ |
| 314 | #define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ |
| 315 | |
| 316 | /* |
| 317 | * Behaviour when detecting errors |
| 318 | */ |
| 319 | #define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ |
| 320 | #define EXT2_ERRORS_RO 2 /* Remount fs read-only */ |
| 321 | #define EXT2_ERRORS_PANIC 3 /* Panic */ |
| 322 | #define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE |
| 323 | |
| 324 | /* |
| 325 | * Structure of the super block |
| 326 | */ |
| 327 | struct ext2_super_block { |
| 328 | __u32 s_inodes_count; /* Inodes count */ |
| 329 | __u32 s_blocks_count; /* Blocks count */ |
| 330 | __u32 s_r_blocks_count; /* Reserved blocks count */ |
| 331 | __u32 s_free_blocks_count; /* Free blocks count */ |
| 332 | __u32 s_free_inodes_count; /* Free inodes count */ |
| 333 | __u32 s_first_data_block; /* First Data Block */ |
| 334 | __u32 s_log_block_size; /* Block size */ |
| 335 | __s32 s_log_frag_size; /* Fragment size */ |
| 336 | __u32 s_blocks_per_group; /* # Blocks per group */ |
| 337 | __u32 s_frags_per_group; /* # Fragments per group */ |
| 338 | __u32 s_inodes_per_group; /* # Inodes per group */ |
| 339 | __u32 s_mtime; /* Mount time */ |
| 340 | __u32 s_wtime; /* Write time */ |
| 341 | __u16 s_mnt_count; /* Mount count */ |
| 342 | __s16 s_max_mnt_count; /* Maximal mount count */ |
| 343 | __u16 s_magic; /* Magic signature */ |
| 344 | __u16 s_state; /* File system state */ |
| 345 | __u16 s_errors; /* Behaviour when detecting errors */ |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 346 | __u16 s_minor_rev_level; /* minor revision level */ |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 347 | __u32 s_lastcheck; /* time of last check */ |
| 348 | __u32 s_checkinterval; /* max. time between checks */ |
| 349 | __u32 s_creator_os; /* OS */ |
| 350 | __u32 s_rev_level; /* Revision level */ |
| 351 | __u16 s_def_resuid; /* Default uid for reserved blocks */ |
| 352 | __u16 s_def_resgid; /* Default gid for reserved blocks */ |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 353 | /* |
| 354 | * These fields are for EXT2_DYNAMIC_REV superblocks only. |
| 355 | * |
| 356 | * Note: the difference between the compatible feature set and |
| 357 | * the incompatible feature set is that if there is a bit set |
| 358 | * in the incompatible feature set that the kernel doesn't |
| 359 | * know about, it should refuse to mount the filesystem. |
| 360 | * |
| 361 | * e2fsck's requirements are more strict; if it doesn't know |
| 362 | * about a feature in either the compatible or incompatible |
| 363 | * feature set, it must abort and not try to meddle with |
| 364 | * things it doesn't understand... |
| 365 | */ |
| 366 | __u32 s_first_ino; /* First non-reserved inode */ |
| 367 | __u16 s_inode_size; /* size of inode structure */ |
| 368 | __u16 s_block_group_nr; /* block group # of this superblock */ |
| 369 | __u32 s_feature_compat; /* compatible feature set */ |
| 370 | __u32 s_feature_incompat; /* incompatible feature set */ |
| 371 | __u32 s_feature_ro_compat; /* readonly-compatible feature set */ |
| 372 | __u8 s_uuid[16]; /* 128-bit uuid for volume */ |
| 373 | char s_volume_name[16]; /* volume name */ |
| 374 | char s_last_mounted[64]; /* directory where last mounted */ |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 375 | __u32 s_algorithm_usage_bitmap; /* For compression */ |
| 376 | /* |
| 377 | * Performance hints. Directory preallocation should only |
Theodore Ts'o | 8f13d8c | 2000-07-04 19:41:29 +0000 | [diff] [blame^] | 378 | * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on. |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 379 | */ |
| 380 | __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ |
| 381 | __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ |
| 382 | __u16 s_padding1; |
Theodore Ts'o | 8f13d8c | 2000-07-04 19:41:29 +0000 | [diff] [blame^] | 383 | /* |
| 384 | * Journaling support. |
| 385 | */ |
| 386 | __u8 s_journal_uuid[16]; /* uuid of journal superblock */ |
| 387 | __u32 s_journal_inum; /* inode number of journal file */ |
| 388 | __u32 s_journal_dev; /* device number of journal file */ |
| 389 | __u32 s_last_orphan; /* start of list of inodes to delete */ |
| 390 | |
| 391 | __u32 s_reserved[197]; /* Padding to the end of the block */ |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 392 | }; |
| 393 | |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 394 | #ifdef __KERNEL__ |
| 395 | #define EXT2_SB(sb) (&((sb)->u.ext2_sb)) |
| 396 | #else |
| 397 | /* Assume that user mode programs are passing in an ext2fs superblock, not |
| 398 | * a kernel struct super_block. This will allow us to call the feature-test |
| 399 | * macros from user land. */ |
| 400 | #define EXT2_SB(sb) (sb) |
| 401 | #endif |
| 402 | |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 403 | /* |
| 404 | * Codes for operating systems |
| 405 | */ |
| 406 | #define EXT2_OS_LINUX 0 |
| 407 | #define EXT2_OS_HURD 1 |
| 408 | #define EXT2_OS_MASIX 2 |
| 409 | #define EXT2_OS_FREEBSD 3 |
| 410 | #define EXT2_OS_LITES 4 |
| 411 | |
| 412 | /* |
| 413 | * Revision levels |
| 414 | */ |
| 415 | #define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 416 | #define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 417 | |
| 418 | #define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 419 | #define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV |
| 420 | |
| 421 | #define EXT2_GOOD_OLD_INODE_SIZE 128 |
| 422 | |
| 423 | /* |
| 424 | * Feature set definitions |
| 425 | */ |
| 426 | |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 427 | #define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ |
| 428 | ( EXT2_SB(sb)->s_feature_compat & (mask) ) |
| 429 | #define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ |
| 430 | ( EXT2_SB(sb)->s_feature_ro_compat & (mask) ) |
| 431 | #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ |
| 432 | ( EXT2_SB(sb)->s_feature_incompat & (mask) ) |
| 433 | |
| 434 | #define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 |
| 435 | |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 436 | #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 437 | #define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 |
| 438 | #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 |
| 439 | |
| 440 | #define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 |
| 441 | #define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 442 | |
| 443 | #define EXT2_FEATURE_COMPAT_SUPP 0 |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 444 | #define EXT2_FEATURE_INCOMPAT_SUPP EXT2_FEATURE_INCOMPAT_FILETYPE |
| 445 | #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ |
| 446 | EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ |
| 447 | EXT2_FEATURE_RO_COMPAT_BTREE_DIR) |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 448 | |
| 449 | /* |
| 450 | * Default values for user and/or group using reserved blocks |
| 451 | */ |
| 452 | #define EXT2_DEF_RESUID 0 |
| 453 | #define EXT2_DEF_RESGID 0 |
| 454 | |
| 455 | /* |
| 456 | * Structure of a directory entry |
| 457 | */ |
| 458 | #define EXT2_NAME_LEN 255 |
| 459 | |
| 460 | struct ext2_dir_entry { |
| 461 | __u32 inode; /* Inode number */ |
| 462 | __u16 rec_len; /* Directory entry length */ |
| 463 | __u16 name_len; /* Name length */ |
| 464 | char name[EXT2_NAME_LEN]; /* File name */ |
| 465 | }; |
| 466 | |
| 467 | /* |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 468 | * The new version of the directory entry. Since EXT2 structures are |
| 469 | * stored in intel byte order, and the name_len field could never be |
| 470 | * bigger than 255 chars, it's safe to reclaim the extra byte for the |
| 471 | * file_type field. |
| 472 | */ |
| 473 | struct ext2_dir_entry_2 { |
| 474 | __u32 inode; /* Inode number */ |
| 475 | __u16 rec_len; /* Directory entry length */ |
| 476 | __u8 name_len; /* Name length */ |
| 477 | __u8 file_type; |
| 478 | char name[EXT2_NAME_LEN]; /* File name */ |
| 479 | }; |
| 480 | |
| 481 | /* |
| 482 | * Ext2 directory file types. Only the low 3 bits are used. The |
| 483 | * other bits are reserved for now. |
| 484 | */ |
| 485 | #define EXT2_FT_UNKNOWN 0 |
| 486 | #define EXT2_FT_REG_FILE 1 |
| 487 | #define EXT2_FT_DIR 2 |
| 488 | #define EXT2_FT_CHRDEV 3 |
| 489 | #define EXT2_FT_BLKDEV 4 |
| 490 | #define EXT2_FT_FIFO 5 |
| 491 | #define EXT2_FT_SOCK 6 |
| 492 | #define EXT2_FT_SYMLINK 7 |
| 493 | |
| 494 | #define EXT2_FT_MAX 8 |
| 495 | |
| 496 | /* |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 497 | * EXT2_DIR_PAD defines the directory entries boundaries |
| 498 | * |
| 499 | * NOTE: It must be a multiple of 4 |
| 500 | */ |
| 501 | #define EXT2_DIR_PAD 4 |
| 502 | #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) |
| 503 | #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ |
| 504 | ~EXT2_DIR_ROUND) |
| 505 | |
| 506 | #ifdef __KERNEL__ |
| 507 | /* |
| 508 | * Function prototypes |
| 509 | */ |
| 510 | |
| 511 | /* |
| 512 | * Ok, these declarations are also in <linux/kernel.h> but none of the |
| 513 | * ext2 source programs needs to include it so they are duplicated here. |
| 514 | */ |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 515 | # define NORET_TYPE /**/ |
| 516 | # define ATTRIB_NORET __attribute__((noreturn)) |
| 517 | # define NORET_AND noreturn, |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 518 | |
| 519 | /* acl.c */ |
| 520 | extern int ext2_permission (struct inode *, int); |
| 521 | |
| 522 | /* balloc.c */ |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 523 | extern int ext2_group_sparse(int group); |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 524 | extern int ext2_new_block (const struct inode *, unsigned long, |
| 525 | __u32 *, __u32 *, int *); |
| 526 | extern void ext2_free_blocks (const struct inode *, unsigned long, |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 527 | unsigned long); |
| 528 | extern unsigned long ext2_count_free_blocks (struct super_block *); |
| 529 | extern void ext2_check_blocks_bitmap (struct super_block *); |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 530 | extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, |
| 531 | unsigned int block_group, |
| 532 | struct buffer_head ** bh); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 533 | |
| 534 | /* bitmap.c */ |
| 535 | extern unsigned long ext2_count_free (struct buffer_head *, unsigned); |
| 536 | |
| 537 | /* dir.c */ |
| 538 | extern int ext2_check_dir_entry (const char *, struct inode *, |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 539 | struct ext2_dir_entry_2 *, struct buffer_head *, |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 540 | unsigned long); |
| 541 | |
| 542 | /* file.c */ |
| 543 | extern int ext2_read (struct inode *, struct file *, char *, int); |
| 544 | extern int ext2_write (struct inode *, struct file *, char *, int); |
| 545 | |
| 546 | /* fsync.c */ |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 547 | extern int ext2_sync_file (struct file *, struct dentry *); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 548 | |
| 549 | /* ialloc.c */ |
Theodore Ts'o | 521e368 | 1997-04-29 17:48:10 +0000 | [diff] [blame] | 550 | extern struct inode * ext2_new_inode (const struct inode *, int, int *); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 551 | extern void ext2_free_inode (struct inode *); |
| 552 | extern unsigned long ext2_count_free_inodes (struct super_block *); |
| 553 | extern void ext2_check_inodes_bitmap (struct super_block *); |
| 554 | |
| 555 | /* inode.c */ |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 556 | extern long ext2_bmap (struct inode *, long); |
| 557 | extern int ext2_get_block (struct inode *, long, struct buffer_head *, int); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 558 | |
| 559 | extern struct buffer_head * ext2_getblk (struct inode *, long, int, int *); |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 560 | extern int ext2_getblk_block (struct inode *, long, int, int *, int *); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 561 | extern struct buffer_head * ext2_bread (struct inode *, int, int, int *); |
| 562 | |
| 563 | extern int ext2_getcluster (struct inode * inode, long block); |
| 564 | extern void ext2_read_inode (struct inode *); |
| 565 | extern void ext2_write_inode (struct inode *); |
| 566 | extern void ext2_put_inode (struct inode *); |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 567 | extern void ext2_delete_inode (struct inode *); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 568 | extern int ext2_sync_inode (struct inode *); |
| 569 | extern void ext2_discard_prealloc (struct inode *); |
| 570 | |
| 571 | /* ioctl.c */ |
| 572 | extern int ext2_ioctl (struct inode *, struct file *, unsigned int, |
| 573 | unsigned long); |
| 574 | |
| 575 | /* namei.c */ |
| 576 | extern void ext2_release (struct inode *, struct file *); |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 577 | extern struct dentry *ext2_lookup (struct inode *, struct dentry *); |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 578 | extern int ext2_create (struct inode *,struct dentry *,int); |
| 579 | extern int ext2_mkdir (struct inode *,struct dentry *,int); |
| 580 | extern int ext2_rmdir (struct inode *,struct dentry *); |
| 581 | extern int ext2_unlink (struct inode *,struct dentry *); |
| 582 | extern int ext2_symlink (struct inode *,struct dentry *,const char *); |
| 583 | extern int ext2_link (struct dentry *, struct inode *, struct dentry *); |
| 584 | extern int ext2_mknod (struct inode *, struct dentry *, int, int); |
| 585 | extern int ext2_rename (struct inode *, struct dentry *, |
| 586 | struct inode *, struct dentry *); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 587 | |
| 588 | /* super.c */ |
| 589 | extern void ext2_error (struct super_block *, const char *, const char *, ...) |
| 590 | __attribute__ ((format (printf, 3, 4))); |
| 591 | extern NORET_TYPE void ext2_panic (struct super_block *, const char *, |
| 592 | const char *, ...) |
| 593 | __attribute__ ((NORET_AND format (printf, 3, 4))); |
| 594 | extern void ext2_warning (struct super_block *, const char *, const char *, ...) |
| 595 | __attribute__ ((format (printf, 3, 4))); |
| 596 | extern void ext2_put_super (struct super_block *); |
| 597 | extern void ext2_write_super (struct super_block *); |
| 598 | extern int ext2_remount (struct super_block *, int *, char *); |
| 599 | extern struct super_block * ext2_read_super (struct super_block *,void *,int); |
Theodore Ts'o | 89fe431 | 1998-03-24 16:09:18 +0000 | [diff] [blame] | 600 | extern int ext2_statfs (struct super_block *, struct statfs *, int); |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 601 | |
| 602 | /* truncate.c */ |
| 603 | extern void ext2_truncate (struct inode *); |
| 604 | |
| 605 | /* |
| 606 | * Inodes and files operations |
| 607 | */ |
| 608 | |
| 609 | /* dir.c */ |
| 610 | extern struct inode_operations ext2_dir_inode_operations; |
| 611 | |
| 612 | /* file.c */ |
| 613 | extern struct inode_operations ext2_file_inode_operations; |
| 614 | |
| 615 | /* symlink.c */ |
| 616 | extern struct inode_operations ext2_symlink_inode_operations; |
Theodore Ts'o | 41a817e | 2000-02-02 16:06:35 +0000 | [diff] [blame] | 617 | extern struct inode_operations ext2_fast_symlink_inode_operations; |
Theodore Ts'o | 50e1e10 | 1997-04-26 13:58:21 +0000 | [diff] [blame] | 618 | |
| 619 | #endif /* __KERNEL__ */ |
| 620 | |
| 621 | #endif /* _LINUX_EXT2_FS_H */ |