root/include/linux/ext2_fs.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  *  linux/include/linux/ext2_fs.h
   3  *
   4  *  Copyright (C) 1992, 1993, 1994  Remy Card (card@masi.ibp.fr)
   5  *                                  Laboratoire MASI - Institut Blaise Pascal
   6  *                                  Universite Pierre et Marie Curie (Paris VI)
   7  *
   8  *  from
   9  *
  10  *  linux/include/linux/minix_fs.h
  11  *
  12  *  Copyright (C) 1991, 1992  Linus Torvalds
  13  */
  14 
  15 #ifndef _LINUX_EXT2_FS_H
  16 #define _LINUX_EXT2_FS_H
  17 
  18 /*
  19  * The second extended filesystem constants/structures
  20  */
  21 
  22 /*
  23  * Define EXT2FS_DEBUG to produce debug messages
  24  */
  25 #undef EXT2FS_DEBUG
  26 
  27 /*
  28  * Define EXT2FS_DEBUG_CACHE to produce cache debug messages
  29  */
  30 #undef EXT2FS_DEBUG_CACHE
  31 
  32 /*
  33  * Define EXT2FS_CHECK_CACHE to add some checks to the name cache code
  34  */
  35 #undef EXT2FS_CHECK_CACHE
  36 
  37 /*
  38  * Define EXT2FS_PRE_02B_COMPAT to convert ext 2 fs prior to 0.2b
  39  */
  40 #undef EXT2FS_PRE_02B_COMPAT
  41 
  42 /*
  43  * Define DONT_USE_DCACHE to inhibit the directory cache
  44  */
  45 #define DONT_USE_DCACHE
  46 
  47 /*
  48  * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files
  49  */
  50 #define EXT2_PREALLOCATE
  51 
  52 /*
  53  * The second extended file system version
  54  */
  55 #define EXT2FS_DATE             "94/01/08"
  56 #define EXT2FS_VERSION          "0.4b"
  57 
  58 /*
  59  * Debug code
  60  */
  61 #ifdef EXT2FS_DEBUG
  62 #       define ext2_debug(f, a...)      { \
  63                                         printk ("EXT2-fs DEBUG (%s, %d): %s:", \
  64                                                 __FILE__, __LINE__, __FUNCTION__); \
  65                                         printk (f, ## a); \
  66                                         }
  67 #else
  68 #       define ext2_debug(f, a...)      /**/
  69 #endif
  70 
  71 /*
  72  * Special inodes numbers
  73  */
  74 #define EXT2_BAD_INO             1      /* Bad blocks inode */
  75 #define EXT2_ROOT_INO            2      /* Root inode */
  76 #define EXT2_ACL_IDX_INO         3      /* ACL inode */
  77 #define EXT2_ACL_DATA_INO        4      /* ACL inode */
  78 #define EXT2_BOOT_LOADER_INO     5      /* Boot loader inode */
  79 #define EXT2_UNDEL_DIR_INO       6      /* Undelete directory inode */
  80 #define EXT2_FIRST_INO          11      /* First non reserved inode */
  81 
  82 /*
  83  * The second extended file system magic number
  84  */
  85 #define EXT2_PRE_02B_MAGIC      0xEF51
  86 #define EXT2_SUPER_MAGIC        0xEF53
  87 
  88 /*
  89  * Maximal count of links to a file
  90  */
  91 #define EXT2_LINK_MAX           32000
  92 
  93 /*
  94  * Macro-instructions used to manage several block sizes
  95  */
  96 #define EXT2_MIN_BLOCK_SIZE             1024
  97 #define EXT2_MAX_BLOCK_SIZE             4096
  98 #define EXT2_MIN_BLOCK_LOG_SIZE           10
  99 #ifdef __KERNEL__
 100 # define EXT2_BLOCK_SIZE(s)             ((s)->s_blocksize)
 101 #else
 102 # define EXT2_BLOCK_SIZE(s)             (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
 103 #endif
 104 #define EXT2_ACLE_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
 105 #define EXT2_ADDR_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof (unsigned long))
 106 #ifdef __KERNEL__
 107 # define EXT2_BLOCK_SIZE_BITS(s)        ((s)->u.ext2_sb.s_es->s_log_block_size + 10)
 108 #else
 109 # define EXT2_BLOCK_SIZE_BITS(s)        ((s)->s_log_block_size + 10)
 110 #endif
 111 #define EXT2_INODES_PER_BLOCK(s)        (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_inode))
 112 
 113 /*
 114  * Macro-instructions used to manage fragments
 115  */
 116 #define EXT2_MIN_FRAG_SIZE              1024
 117 #define EXT2_MAX_FRAG_SIZE              4096
 118 #define EXT2_MIN_FRAG_LOG_SIZE            10
 119 #ifdef __KERNEL__
 120 # define EXT2_FRAG_SIZE(s)              ((s)->u.ext2_sb.s_frag_size)
 121 # define EXT2_FRAGS_PER_BLOCK(s)        ((s)->u.ext2_sb.s_frags_per_block)
 122 #else
 123 # define EXT2_FRAG_SIZE(s)              (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
 124 # define EXT2_FRAGS_PER_BLOCK(s)        (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
 125 #endif
 126 
 127 /*
 128  * ACL structures
 129  */
 130 struct ext2_acl_header  /* Header of Access Control Lists */
 131 {
 132         unsigned long aclh_size;
 133         unsigned long aclh_file_count;
 134         unsigned long aclh_acle_count;
 135         unsigned long aclh_first_acle;
 136 };
 137 
 138 struct ext2_acl_entry   /* Access Control List Entry */
 139 {
 140         unsigned long  acle_size;
 141         unsigned short acle_perms;      /* Access permissions */
 142         unsigned short acle_type;       /* Type of entry */
 143         unsigned short acle_tag;        /* User or group identity */
 144         unsigned short acle_pad1;
 145         unsigned long  acle_next;       /* Pointer on next entry for the */
 146                                         /* same inode or on next free entry */
 147 };
 148 
 149 /*
 150  * Structure of a blocks group descriptor
 151  */
 152 struct ext2_old_group_desc
 153 {
 154         unsigned long  bg_block_bitmap;         /* Blocks bitmap block */
 155         unsigned long  bg_inode_bitmap;         /* Inodes bitmap block */
 156         unsigned long  bg_inode_table;          /* Inodes table block */
 157         unsigned short bg_free_blocks_count;    /* Free blocks count */
 158         unsigned short bg_free_inodes_count;    /* Free inodes count */
 159 };
 160 
 161 struct ext2_group_desc
 162 {
 163         unsigned long  bg_block_bitmap;         /* Blocks bitmap block */
 164         unsigned long  bg_inode_bitmap;         /* Inodes bitmap block */
 165         unsigned long  bg_inode_table;          /* Inodes table block */
 166         unsigned short bg_free_blocks_count;    /* Free blocks count */
 167         unsigned short bg_free_inodes_count;    /* Free inodes count */
 168         unsigned short bg_used_dirs_count;      /* Directories count */
 169         unsigned short bg_pad;
 170         unsigned long  bg_reserved[3];
 171 };
 172 
 173 /*
 174  * Macro-instructions used to manage group descriptors
 175  */
 176 #ifdef __KERNEL__
 177 # define EXT2_BLOCKS_PER_GROUP(s)       ((s)->u.ext2_sb.s_blocks_per_group)
 178 # define EXT2_DESC_PER_BLOCK(s)         ((s)->u.ext2_sb.s_desc_per_block)
 179 # define EXT2_INODES_PER_GROUP(s)       ((s)->u.ext2_sb.s_inodes_per_group)
 180 #else
 181 # define EXT2_BLOCKS_PER_GROUP(s)       ((s)->s_blocks_per_group)
 182 # define EXT2_DESC_PER_BLOCK(s)         (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
 183 # define EXT2_INODES_PER_GROUP(s)       ((s)->s_inodes_per_group)
 184 #endif
 185 
 186 /*
 187  * Constants relative to the data blocks
 188  */
 189 #define EXT2_NDIR_BLOCKS                12
 190 #define EXT2_IND_BLOCK                  EXT2_NDIR_BLOCKS
 191 #define EXT2_DIND_BLOCK                 (EXT2_IND_BLOCK + 1)
 192 #define EXT2_TIND_BLOCK                 (EXT2_DIND_BLOCK + 1)
 193 #define EXT2_N_BLOCKS                   (EXT2_TIND_BLOCK + 1)
 194 
 195 /*
 196  * Inode flags
 197  */
 198 #define EXT2_SECRM_FL                   0x0001  /* Secure deletion */
 199 #define EXT2_UNRM_FL                    0x0002  /* Undelete */
 200 #define EXT2_COMPR_FL                   0x0004  /* Compress file */
 201 #define EXT2_SYNC_FL                    0x0008  /* Synchronous updates */
 202 
 203 /*
 204  * ioctl commands
 205  */
 206 #define EXT2_IOC_GETFLAGS               _IOR('f', 1, long)
 207 #define EXT2_IOC_SETFLAGS               _IOW('f', 2, long)
 208 #define EXT2_IOC_GETVERSION             _IOR('v', 1, long)
 209 #define EXT2_IOC_SETVERSION             _IOW('v', 2, long)
 210 
 211 /*
 212  * Structure of an inode on the disk
 213  */
 214 struct ext2_inode {
 215         unsigned short i_mode;          /* File mode */
 216         unsigned short i_uid;           /* Owner Uid */
 217         unsigned long  i_size;          /* Size in bytes */
 218         unsigned long  i_atime;         /* Access time */
 219         unsigned long  i_ctime;         /* Creation time */
 220         unsigned long  i_mtime;         /* Modification time */
 221         unsigned long  i_dtime;         /* Deletion Time */
 222         unsigned short i_gid;           /* Group Id */
 223         unsigned short i_links_count;   /* Links count */
 224         unsigned long  i_blocks;        /* Blocks count */
 225         unsigned long  i_flags;         /* File flags */
 226         unsigned long  i_reserved1;
 227         unsigned long  i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
 228         unsigned long  i_version;       /* File version (for NFS) */
 229         unsigned long  i_file_acl;      /* File ACL */
 230         unsigned long  i_dir_acl;       /* Directory ACL */
 231         unsigned long  i_faddr;         /* Fragment address */
 232         unsigned char  i_frag;          /* Fragment number */
 233         unsigned char  i_fsize;         /* Fragment size */
 234         unsigned short i_pad1;
 235         unsigned long  i_reserved2[2];
 236 };
 237 
 238 /*
 239  * File system states
 240  */
 241 #define EXT2_VALID_FS                   0x0001  /* Unmounted cleany */
 242 #define EXT2_ERROR_FS                   0x0002  /* Errors detected */
 243 
 244 /*
 245  * Mount flags
 246  */
 247 #define EXT2_MOUNT_CHECK_NORMAL         0x0001  /* Do some more checks */
 248 #define EXT2_MOUNT_CHECK_STRICT         0x0002  /* Do again more checks */
 249 #define EXT2_MOUNT_CHECK                (EXT2_MOUNT_CHECK_NORMAL | \
 250                                          EXT2_MOUNT_CHECK_STRICT)
 251 #define EXT2_MOUNT_GRPID                0x0004  /* Create files with directory's group */
 252 #define EXT2_MOUNT_DEBUG                0x0008  /* Some debugging messages */
 253 #define EXT2_MOUNT_ERRORS_CONT          0x0010  /* Continue on errors */
 254 #define EXT2_MOUNT_ERRORS_RO            0x0020  /* Remount fs ro on errors */
 255 #define EXT2_MOUNT_ERRORS_PANIC         0x0040  /* Panic on errors */
 256 
 257 #define clear_opt(o, opt)               o &= ~EXT2_MOUNT_##opt
 258 #define set_opt(o, opt)                 o |= EXT2_MOUNT_##opt
 259 #define test_opt(sb, opt)               ((sb)->u.ext2_sb.s_mount_opt & \
 260                                          EXT2_MOUNT_##opt)
 261 /*
 262  * Maximal mount counts between two filesystem checks
 263  */
 264 #define EXT2_DFL_MAX_MNT_COUNT          20      /* Allow 20 mounts */
 265 
 266 /*
 267  * Behaviour when detecting errors
 268  */
 269 #define EXT2_ERRORS_CONTINUE            1       /* Continue execution */
 270 #define EXT2_ERRORS_RO                  2       /* Remount fs read-only */
 271 #define EXT2_ERRORS_PANIC               3       /* Panic */
 272 #define EXT2_ERRORS_DEFAULT             EXT2_ERRORS_CONTINUE
 273 
 274 /*
 275  * Structure of the super block
 276  */
 277 struct ext2_super_block {
 278         unsigned long  s_inodes_count;  /* Inodes count */
 279         unsigned long  s_blocks_count;  /* Blocks count */
 280         unsigned long  s_r_blocks_count;/* Reserved blocks count */
 281         unsigned long  s_free_blocks_count;/* Free blocks count */
 282         unsigned long  s_free_inodes_count;/* Free inodes count */
 283         unsigned long  s_first_data_block;/* First Data Block */
 284         unsigned long  s_log_block_size;/* Block size */
 285         long           s_log_frag_size; /* Fragment size */
 286         unsigned long  s_blocks_per_group;/* # Blocks per group */
 287         unsigned long  s_frags_per_group;/* # Fragments per group */
 288         unsigned long  s_inodes_per_group;/* # Inodes per group */
 289         unsigned long  s_mtime;         /* Mount time */
 290         unsigned long  s_wtime;         /* Write time */
 291         unsigned short s_mnt_count;     /* Mount count */
 292         short          s_max_mnt_count; /* Maximal mount count */
 293         unsigned short s_magic;         /* Magic signature */
 294         unsigned short s_state;         /* File system state */
 295         unsigned short s_errors;        /* Behaviour when detecting errors */
 296         unsigned short s_pad;
 297         unsigned long  s_reserved[240]; /* Padding to the end of the block */
 298 };
 299 
 300 /*
 301  * Structure of a directory entry
 302  */
 303 #define EXT2_NAME_LEN 255
 304 
 305 struct ext2_dir_entry {
 306         unsigned long  inode;                   /* Inode number */
 307         unsigned short rec_len;                 /* Directory entry length */
 308         unsigned short name_len;                /* Name length */
 309         char           name[EXT2_NAME_LEN];     /* File name */
 310 };
 311 
 312 /*
 313  * EXT2_DIR_PAD defines the directory entries boundaries
 314  *
 315  * NOTE: It must be a multiple of 4
 316  */
 317 #define EXT2_DIR_PAD                    4
 318 #define EXT2_DIR_ROUND                  (EXT2_DIR_PAD - 1)
 319 #define EXT2_DIR_REC_LEN(name_len)      (((name_len) + 8 + EXT2_DIR_ROUND) & \
 320                                          ~EXT2_DIR_ROUND)
 321 
 322 #ifdef __KERNEL__
 323 /*
 324  * Function prototypes
 325  */
 326 
 327 /*
 328  * Ok, these declarations are also in <linux/kernel.h> but none of the
 329  * ext2 source programs needs to include it so they are duplicated here.
 330  */
 331 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
 332 # define NORET_TYPE    __volatile__
 333 # define ATTRIB_NORET  /**/
 334 # define NORET_AND     /**/
 335 #else
 336 # define NORET_TYPE    /**/
 337 # define ATTRIB_NORET  __attribute__((noreturn))
 338 # define NORET_AND     noreturn,
 339 #endif
 340 
 341 /* acl.c */
 342 extern int ext2_permission (struct inode *, int);
 343 
 344 /* balloc.c */
 345 extern int ext2_new_block (struct super_block *, unsigned long,
 346                            unsigned long *, unsigned long *);
 347 extern void ext2_free_blocks (struct super_block *, unsigned long,
 348                               unsigned long);
 349 extern unsigned long ext2_count_free_blocks (struct super_block *);
 350 extern void ext2_check_blocks_bitmap (struct super_block *);
 351 
 352 /* bitmap.c */
 353 extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
 354 
 355 #ifndef DONT_USE_DCACHE
 356 /* dcache.c */
 357 extern void ext2_dcache_invalidate (unsigned short);
 358 extern unsigned long ext2_dcache_lookup (unsigned short, unsigned long,
 359                                          const char *, int);
 360 extern void ext2_dcache_add (unsigned short, unsigned long, const char *,
 361                              int, unsigned long);
 362 extern void ext2_dcache_remove (unsigned short, unsigned long, const char *,
 363                                 int);
 364 #endif
 365 
 366 /* dir.c */
 367 extern int ext2_check_dir_entry (char *, struct inode *,
 368                                  struct ext2_dir_entry *, struct buffer_head *,
 369                                  unsigned long);
 370 
 371 /* file.c */
 372 extern int ext2_read (struct inode *, struct file *, char *, int);
 373 extern int ext2_write (struct inode *, struct file *, char *, int);
 374 
 375 /* fsync.c */
 376 extern int ext2_sync_file (struct inode *, struct file *);
 377 
 378 /* ialloc.c */
 379 extern struct inode * ext2_new_inode (const struct inode *, int);
 380 extern void ext2_free_inode (struct inode *);
 381 extern unsigned long ext2_count_free_inodes (struct super_block *);
 382 extern void ext2_check_inodes_bitmap (struct super_block *);
 383 
 384 /* inode.c */
 385 extern int ext2_bmap (struct inode *, int);
 386 
 387 extern struct buffer_head * ext2_getblk (struct inode *, long, int, int *);
 388 extern struct buffer_head * ext2_bread (struct inode *, int, int, int *);
 389 
 390 extern void ext2_read_inode (struct inode *);
 391 extern void ext2_write_inode (struct inode *);
 392 extern void ext2_put_inode (struct inode *);
 393 extern int ext2_sync_inode (struct inode *);
 394 extern void ext2_discard_prealloc (struct inode *);
 395 
 396 /* ioctl.c */
 397 extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
 398                        unsigned long);
 399 
 400 /* namei.c */
 401 extern int ext2_open (struct inode *, struct file *);
 402 extern void ext2_release (struct inode *, struct file *);
 403 extern int ext2_lookup (struct inode *,const char *, int, struct inode **);
 404 extern int ext2_create (struct inode *,const char *, int, int,
 405                         struct inode **);
 406 extern int ext2_mkdir (struct inode *, const char *, int, int);
 407 extern int ext2_rmdir (struct inode *, const char *, int);
 408 extern int ext2_unlink (struct inode *, const char *, int);
 409 extern int ext2_symlink (struct inode *, const char *, int, const char *);
 410 extern int ext2_link (struct inode *, struct inode *, const char *, int);
 411 extern int ext2_mknod (struct inode *, const char *, int, int, int);
 412 extern int ext2_rename (struct inode *, const char *, int,
 413                         struct inode *, const char *, int);
 414 
 415 /* super.c */
 416 extern void ext2_error (struct super_block *, const char *, const char *, ...)
 417         __attribute__ ((format (printf, 3, 4)));
 418 extern NORET_TYPE void ext2_panic (struct super_block *, const char *,
 419                                    const char *, ...)
 420         __attribute__ ((NORET_AND format (printf, 3, 4)));
 421 extern void ext2_warning (struct super_block *, const char *, const char *, ...)
 422         __attribute__ ((format (printf, 3, 4)));
 423 extern void ext2_put_super (struct super_block *);
 424 extern void ext2_write_super (struct super_block *);
 425 extern int ext2_remount (struct super_block *, int *, char *);
 426 extern struct super_block * ext2_read_super (struct super_block *,void *,int);
 427 extern void ext2_statfs (struct super_block *, struct statfs *);
 428 
 429 /* truncate.c */
 430 extern void ext2_truncate (struct inode *);
 431 
 432 /*
 433  * Inodes and files operations
 434  */
 435 
 436 /* dir.c */
 437 extern struct inode_operations ext2_dir_inode_operations;
 438 
 439 /* file.c */
 440 extern struct inode_operations ext2_file_inode_operations;
 441 
 442 /* symlink.c */
 443 extern struct inode_operations ext2_symlink_inode_operations;
 444 
 445 #endif  /* __KERNEL__ */
 446 
 447 #endif  /* _LINUX_EXT2_FS_H */

/* [previous][next][first][last][top][bottom][index][help] */