00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _LINUX_EXT2_FS_H
00020 #define _LINUX_EXT2_FS_H
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #undef EXT2FS_DEBUG
00038
00039
00040
00041
00042
00043
00044
00045
00046 #undef EXT2FS_DEBUG_CACHE
00047
00048
00049
00050
00051
00052
00053
00054
00055 #undef EXT2FS_CHECK_CACHE
00056
00057
00058
00059
00060
00061
00062
00063
00064 #undef EXT2FS_PRE_02B_COMPAT
00065
00066
00067
00068
00069
00070
00071
00072
00073 #define DONT_USE_DCACHE
00074
00075
00076
00077
00078
00079
00080
00081
00082 #define EXT2_PREALLOCATE
00083
00084
00085
00086
00087
00088
00089
00090
00091 #define EXT2FS_DATE "94/03/10"
00092 #define EXT2FS_VERSION "0.5"
00093
00094
00095
00096
00097
00098
00099
00100
00101 #ifdef EXT2FS_DEBUG
00102 # define ext2_debug(f, a...) { \
00103 printk ("EXT2-fs DEBUG (%s, %d): %s:", \
00104 __FILE__, __LINE__, __FUNCTION__); \
00105 printk (f, ## a); \
00106 }
00107 #else
00108 # define ext2_debug(f, a...)
00109 #endif
00110
00111
00112
00113
00114
00115
00116
00117
00118 #define EXT2_BAD_INO 1
00119 #define EXT2_ROOT_INO 2
00120 #define EXT2_ACL_IDX_INO 3
00121 #define EXT2_ACL_DATA_INO 4
00122 #define EXT2_BOOT_LOADER_INO 5
00123 #define EXT2_UNDEL_DIR_INO 6
00124 #define EXT2_FIRST_INO 11
00125
00126
00127
00128
00129
00130
00131
00132
00133 #define EXT2_PRE_02B_MAGIC 0xEF51
00134 #define EXT2_SUPER_MAGIC 0xEF53
00135
00136
00137
00138
00139
00140
00141
00142
00143 #define EXT2_LINK_MAX 32000
00144
00145
00146
00147
00148
00149
00150
00151
00152 #define EXT2_MIN_BLOCK_SIZE 1024
00153 #define EXT2_MAX_BLOCK_SIZE 4096
00154 #define EXT2_MIN_BLOCK_LOG_SIZE 10
00155 #ifdef __KERNEL__
00156 # define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
00157 #else
00158 # define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
00159 #endif
00160 #define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
00161 #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (unsigned long))
00162 #ifdef __KERNEL__
00163 # define EXT2_BLOCK_SIZE_BITS(s) ((s)->u.ext2_sb.s_es->s_log_block_size + 10)
00164 #else
00165 # define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
00166 #endif
00167 #define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_inode))
00168
00169
00170
00171
00172
00173
00174
00175
00176 #define EXT2_MIN_FRAG_SIZE 1024
00177 #define EXT2_MAX_FRAG_SIZE 4096
00178 #define EXT2_MIN_FRAG_LOG_SIZE 10
00179 #ifdef __KERNEL__
00180 # define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size)
00181 # define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block)
00182 #else
00183 # define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
00184 # define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
00185 #endif
00186
00187
00188
00189
00190
00191
00192
00193
00194 struct ext2_acl_header
00195 {
00196 unsigned long aclh_size;
00197 unsigned long aclh_file_count;
00198 unsigned long aclh_acle_count;
00199 unsigned long aclh_first_acle;
00200 };
00201
00202 struct ext2_acl_entry
00203 {
00204 unsigned long acle_size;
00205 unsigned short acle_perms;
00206 unsigned short acle_type;
00207 unsigned short acle_tag;
00208 unsigned short acle_pad1;
00209 unsigned long acle_next;
00210
00211 };
00212
00213
00214
00215
00216
00217
00218
00219
00220 struct ext2_old_group_desc
00221 {
00222 unsigned long bg_block_bitmap;
00223 unsigned long bg_inode_bitmap;
00224 unsigned long bg_inode_table;
00225 unsigned short bg_free_blocks_count;
00226 unsigned short bg_free_inodes_count;
00227 };
00228
00229 struct ext2_group_desc
00230 {
00231 unsigned long bg_block_bitmap;
00232 unsigned long bg_inode_bitmap;
00233 unsigned long bg_inode_table;
00234 unsigned short bg_free_blocks_count;
00235 unsigned short bg_free_inodes_count;
00236 unsigned short bg_used_dirs_count;
00237 unsigned short bg_pad;
00238 unsigned long bg_reserved[3];
00239 };
00240
00241
00242
00243
00244
00245
00246
00247
00248 #ifdef __KERNEL__
00249 # define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group)
00250 # define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block)
00251 # define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group)
00252 #else
00253 # define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
00254 # define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
00255 # define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
00256 #endif
00257
00258
00259
00260
00261
00262
00263
00264
00265 #define EXT2_NDIR_BLOCKS 12
00266 #define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
00267 #define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
00268 #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
00269 #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
00270
00271
00272
00273
00274
00275
00276
00277
00278 #define EXT2_SECRM_FL 0x0001
00279 #define EXT2_UNRM_FL 0x0002
00280 #define EXT2_COMPR_FL 0x0004
00281 #define EXT2_SYNC_FL 0x0008
00282
00283
00284
00285
00286
00287
00288
00289
00290 #define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
00291 #define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
00292 #define EXT2_IOC_GETVERSION _IOR('v', 1, long)
00293 #define EXT2_IOC_SETVERSION _IOW('v', 2, long)
00294
00295
00296
00297
00298
00299
00300
00301
00302 struct ext2_inode {
00303 unsigned short i_mode;
00304 unsigned short i_uid;
00305 unsigned long i_size;
00306 unsigned long i_atime;
00307 unsigned long i_ctime;
00308 unsigned long i_mtime;
00309 unsigned long i_dtime;
00310 unsigned short i_gid;
00311 unsigned short i_links_count;
00312 unsigned long i_blocks;
00313 unsigned long i_flags;
00314 unsigned long i_reserved1;
00315 unsigned long i_block[EXT2_N_BLOCKS];
00316 unsigned long i_version;
00317 unsigned long i_file_acl;
00318 unsigned long i_dir_acl;
00319 unsigned long i_faddr;
00320 unsigned char i_frag;
00321 unsigned char i_fsize;
00322 unsigned short i_pad1;
00323 unsigned long i_reserved2[2];
00324 };
00325
00326
00327
00328
00329
00330
00331
00332
00333 #define EXT2_VALID_FS 0x0001
00334 #define EXT2_ERROR_FS 0x0002
00335
00336
00337
00338
00339
00340
00341
00342
00343 #define EXT2_MOUNT_CHECK_NORMAL 0x0001
00344 #define EXT2_MOUNT_CHECK_STRICT 0x0002
00345 #define EXT2_MOUNT_CHECK (EXT2_MOUNT_CHECK_NORMAL | \
00346 EXT2_MOUNT_CHECK_STRICT)
00347 #define EXT2_MOUNT_GRPID 0x0004
00348 #define EXT2_MOUNT_DEBUG 0x0008
00349 #define EXT2_MOUNT_ERRORS_CONT 0x0010
00350 #define EXT2_MOUNT_ERRORS_RO 0x0020
00351 #define EXT2_MOUNT_ERRORS_PANIC 0x0040
00352
00353 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
00354 #define set_opt(o, opt) o |= EXT2_MOUNT_##opt
00355 #define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \
00356 EXT2_MOUNT_##opt)
00357
00358
00359
00360
00361
00362
00363
00364 #define EXT2_DFL_MAX_MNT_COUNT 20
00365 #define EXT2_DFL_CHECKINTERVAL 0
00366
00367
00368
00369
00370
00371
00372
00373
00374 #define EXT2_ERRORS_CONTINUE 1
00375 #define EXT2_ERRORS_RO 2
00376 #define EXT2_ERRORS_PANIC 3
00377 #define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
00378
00379
00380
00381
00382
00383
00384
00385
00386 struct ext2_super_block {
00387 unsigned long s_inodes_count;
00388 unsigned long s_blocks_count;
00389 unsigned long s_r_blocks_count;
00390 unsigned long s_free_blocks_count;
00391 unsigned long s_free_inodes_count;
00392 unsigned long s_first_data_block;
00393 unsigned long s_log_block_size;
00394 long s_log_frag_size;
00395 unsigned long s_blocks_per_group;
00396 unsigned long s_frags_per_group;
00397 unsigned long s_inodes_per_group;
00398 unsigned long s_mtime;
00399 unsigned long s_wtime;
00400 unsigned short s_mnt_count;
00401 short s_max_mnt_count;
00402 unsigned short s_magic;
00403 unsigned short s_state;
00404 unsigned short s_errors;
00405 unsigned short s_pad;
00406 unsigned long s_lastcheck;
00407 unsigned long s_checkinterval;
00408 unsigned long s_reserved[238];
00409 };
00410
00411
00412
00413
00414
00415
00416
00417
00418 #define EXT2_NAME_LEN 255
00419
00420 struct ext2_dir_entry {
00421 unsigned long inode;
00422 unsigned short rec_len;
00423 unsigned short name_len;
00424 char name[EXT2_NAME_LEN];
00425 };
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436 #define EXT2_DIR_PAD 4
00437 #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
00438 #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
00439 ~EXT2_DIR_ROUND)
00440
00441 #ifdef __KERNEL__
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
00459 # define NORET_TYPE __volatile__
00460 # define ATTRIB_NORET
00461 # define NORET_AND
00462 #else
00463 # define NORET_TYPE
00464 # define ATTRIB_NORET __attribute__((noreturn))
00465 # define NORET_AND noreturn,
00466 #endif
00467
00468
00469 extern int ext2_permission (struct inode *, int);
00470
00471
00472 extern int ext2_new_block (struct super_block *, unsigned long,
00473 unsigned long *, unsigned long *);
00474 extern void ext2_free_blocks (struct super_block *, unsigned long,
00475 unsigned long);
00476 extern unsigned long ext2_count_free_blocks (struct super_block *);
00477 extern void ext2_check_blocks_bitmap (struct super_block *);
00478
00479
00480 extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
00481
00482 #ifndef DONT_USE_DCACHE
00483
00484 extern void ext2_dcache_invalidate (unsigned short);
00485 extern unsigned long ext2_dcache_lookup (unsigned short, unsigned long,
00486 const char *, int);
00487 extern void ext2_dcache_add (unsigned short, unsigned long, const char *,
00488 int, unsigned long);
00489 extern void ext2_dcache_remove (unsigned short, unsigned long, const char *,
00490 int);
00491 #endif
00492
00493
00494 extern int ext2_check_dir_entry (char *, struct inode *,
00495 struct ext2_dir_entry *, struct buffer_head *,
00496 unsigned long);
00497
00498
00499 extern int ext2_read (struct inode *, struct file *, char *, int);
00500 extern int ext2_write (struct inode *, struct file *, char *, int);
00501
00502
00503 extern int ext2_sync_file (struct inode *, struct file *);
00504
00505
00506 extern struct inode * ext2_new_inode (const struct inode *, int);
00507 extern void ext2_free_inode (struct inode *);
00508 extern unsigned long ext2_count_free_inodes (struct super_block *);
00509 extern void ext2_check_inodes_bitmap (struct super_block *);
00510
00511
00512 extern int ext2_bmap (struct inode *, int);
00513
00514 extern struct buffer_head * ext2_getblk (struct inode *, long, int, int *);
00515 extern struct buffer_head * ext2_bread (struct inode *, int, int, int *);
00516
00517 extern void ext2_read_inode (struct inode *);
00518 extern void ext2_write_inode (struct inode *);
00519 extern void ext2_put_inode (struct inode *);
00520 extern int ext2_sync_inode (struct inode *);
00521 extern void ext2_discard_prealloc (struct inode *);
00522
00523
00524 extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
00525 unsigned long);
00526
00527
00528 extern int ext2_open (struct inode *, struct file *);
00529 extern void ext2_release (struct inode *, struct file *);
00530 extern int ext2_lookup (struct inode *,const char *, int, struct inode **);
00531 extern int ext2_create (struct inode *,const char *, int, int,
00532 struct inode **);
00533 extern int ext2_mkdir (struct inode *, const char *, int, int);
00534 extern int ext2_rmdir (struct inode *, const char *, int);
00535 extern int ext2_unlink (struct inode *, const char *, int);
00536 extern int ext2_symlink (struct inode *, const char *, int, const char *);
00537 extern int ext2_link (struct inode *, struct inode *, const char *, int);
00538 extern int ext2_mknod (struct inode *, const char *, int, int, int);
00539 extern int ext2_rename (struct inode *, const char *, int,
00540 struct inode *, const char *, int);
00541
00542
00543 extern void ext2_error (struct super_block *, const char *, const char *, ...)
00544 __attribute__ ((format (printf, 3, 4)));
00545 extern NORET_TYPE void ext2_panic (struct super_block *, const char *,
00546 const char *, ...)
00547 __attribute__ ((NORET_AND format (printf, 3, 4)));
00548 extern void ext2_warning (struct super_block *, const char *, const char *, ...)
00549 __attribute__ ((format (printf, 3, 4)));
00550 extern void ext2_put_super (struct super_block *);
00551 extern void ext2_write_super (struct super_block *);
00552 extern int ext2_remount (struct super_block *, int *, char *);
00553 extern struct super_block * ext2_read_super (struct super_block *,void *,int);
00554 extern void ext2_statfs (struct super_block *, struct statfs *);
00555
00556
00557 extern void ext2_truncate (struct inode *);
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568 extern struct inode_operations ext2_dir_inode_operations;
00569
00570
00571 extern struct inode_operations ext2_file_inode_operations;
00572
00573
00574 extern struct inode_operations ext2_symlink_inode_operations;
00575
00576 #endif // __KERNEL__
00577
00578 #endif // _LINUX_EXT2_FS_H