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/03/10"
  56 #define EXT2FS_VERSION          "0.5"
  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 #define EXT2_DFL_CHECKINTERVAL          0       /* Don't use interval check */
 266 
 267 /*
 268  * Behaviour when detecting errors
 269  */
 270 #define EXT2_ERRORS_CONTINUE            1       /* Continue execution */
 271 #define EXT2_ERRORS_RO                  2       /* Remount fs read-only */
 272 #define EXT2_ERRORS_PANIC               3       /* Panic */
 273 #define EXT2_ERRORS_DEFAULT             EXT2_ERRORS_CONTINUE
 274 
 275 /*
 276  * Structure of the super block
 277  */
 278 struct ext2_super_block {
 279         unsigned long  s_inodes_count;  /* Inodes count */
 280         unsigned long  s_blocks_count;  /* Blocks count */
 281         unsigned long  s_r_blocks_count;/* Reserved blocks count */
 282         unsigned long  s_free_blocks_count;/* Free blocks count */
 283         unsigned long  s_free_inodes_count;/* Free inodes count */
 284         unsigned long  s_first_data_block;/* First Data Block */
 285         unsigned long  s_log_block_size;/* Block size */
 286         long           s_log_frag_size; /* Fragment size */
 287         unsigned long  s_blocks_per_group;/* # Blocks per group */
 288         unsigned long  s_frags_per_group;/* # Fragments per group */
 289         unsigned long  s_inodes_per_group;/* # Inodes per group */
 290         unsigned long  s_mtime;         /* Mount time */
 291         unsigned long  s_wtime;         /* Write time */
 292         unsigned short s_mnt_count;     /* Mount count */
 293         short          s_max_mnt_count; /* Maximal mount count */
 294         unsigned short s_magic;         /* Magic signature */
 295         unsigned short s_state;         /* File system state */
 296         unsigned short s_errors;        /* Behaviour when detecting errors */
 297         unsigned short s_pad;
 298         unsigned long  s_lastcheck;     /* time of last check */
 299         unsigned long  s_checkinterval; /* max. time between checks */
 300         unsigned long  s_reserved[238]; /* Padding to the end of the block */
 301 };
 302 
 303 /*
 304  * Structure of a directory entry
 305  */
 306 #define EXT2_NAME_LEN 255
 307 
 308 struct ext2_dir_entry {
 309         unsigned long  inode;                   /* Inode number */
 310         unsigned short rec_len;                 /* Directory entry length */
 311         unsigned short name_len;                /* Name length */
 312         char           name[EXT2_NAME_LEN];     /* File name */
 313 };
 314 
 315 /*
 316  * EXT2_DIR_PAD defines the directory entries boundaries
 317  *
 318  * NOTE: It must be a multiple of 4
 319  */
 320 #define EXT2_DIR_PAD                    4
 321 #define EXT2_DIR_ROUND                  (EXT2_DIR_PAD - 1)
 322 #define EXT2_DIR_REC_LEN(name_len)      (((name_len) + 8 + EXT2_DIR_ROUND) & \
 323                                          ~EXT2_DIR_ROUND)
 324 
 325 #ifdef __KERNEL__
 326 /*
 327  * Function prototypes
 328  */
 329 
 330 /*
 331  * Ok, these declarations are also in <linux/kernel.h> but none of the
 332  * ext2 source programs needs to include it so they are duplicated here.
 333  */
 334 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
 335 # define NORET_TYPE    __volatile__
 336 # define ATTRIB_NORET  /**/
 337 # define NORET_AND     /**/
 338 #else
 339 # define NORET_TYPE    /**/
 340 # define ATTRIB_NORET  __attribute__((noreturn))
 341 # define NORET_AND     noreturn,
 342 #endif
 343 
 344 /* acl.c */
 345 extern int ext2_permission (struct inode *, int);
 346 
 347 /* balloc.c */
 348 extern int ext2_new_block (struct super_block *, unsigned long,
 349                            unsigned long *, unsigned long *);
 350 extern void ext2_free_blocks (struct super_block *, unsigned long,
 351                               unsigned long);
 352 extern unsigned long ext2_count_free_blocks (struct super_block *);
 353 extern void ext2_check_blocks_bitmap (struct super_block *);
 354 
 355 /* bitmap.c */
 356 extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
 357 
 358 #ifndef DONT_USE_DCACHE
 359 /* dcache.c */
 360 extern void ext2_dcache_invalidate (unsigned short);
 361 extern unsigned long ext2_dcache_lookup (unsigned short, unsigned long,
 362                                          const char *, int);
 363 extern void ext2_dcache_add (unsigned short, unsigned long, const char *,
 364                              int, unsigned long);
 365 extern void ext2_dcache_remove (unsigned short, unsigned long, const char *,
 366                                 int);
 367 #endif
 368 
 369 /* dir.c */
 370 extern int ext2_check_dir_entry (char *, struct inode *,
 371                                  struct ext2_dir_entry *, struct buffer_head *,
 372                                  unsigned long);
 373 
 374 /* file.c */
 375 extern int ext2_read (struct inode *, struct file *, char *, int);
 376 extern int ext2_write (struct inode *, struct file *, char *, int);
 377 
 378 /* fsync.c */
 379 extern int ext2_sync_file (struct inode *, struct file *);
 380 
 381 /* ialloc.c */
 382 extern struct inode * ext2_new_inode (const struct inode *, int);
 383 extern void ext2_free_inode (struct inode *);
 384 extern unsigned long ext2_count_free_inodes (struct super_block *);
 385 extern void ext2_check_inodes_bitmap (struct super_block *);
 386 
 387 /* inode.c */
 388 extern int ext2_bmap (struct inode *, int);
 389 
 390 extern struct buffer_head * ext2_getblk (struct inode *, long, int, int *);
 391 extern struct buffer_head * ext2_bread (struct inode *, int, int, int *);
 392 
 393 extern void ext2_read_inode (struct inode *);
 394 extern void ext2_write_inode (struct inode *);
 395 extern void ext2_put_inode (struct inode *);
 396 extern int ext2_sync_inode (struct inode *);
 397 extern void ext2_discard_prealloc (struct inode *);
 398 
 399 /* ioctl.c */
 400 extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
 401                        unsigned long);
 402 
 403 /* namei.c */
 404 extern int ext2_open (struct inode *, struct file *);
 405 extern void ext2_release (struct inode *, struct file *);
 406 extern int ext2_lookup (struct inode *,const char *, int, struct inode **);
 407 extern int ext2_create (struct inode *,const char *, int, int,
 408                         struct inode **);
 409 extern int ext2_mkdir (struct inode *, const char *, int, int);
 410 extern int ext2_rmdir (struct inode *, const char *, int);
 411 extern int ext2_unlink (struct inode *, const char *, int);
 412 extern int ext2_symlink (struct inode *, const char *, int, const char *);
 413 extern int ext2_link (struct inode *, struct inode *, const char *, int);
 414 extern int ext2_mknod (struct inode *, const char *, int, int, int);
 415 extern int ext2_rename (struct inode *, const char *, int,
 416                         struct inode *, const char *, int);
 417 
 418 /* super.c */
 419 extern void ext2_error (struct super_block *, const char *, const char *, ...)
 420         __attribute__ ((format (printf, 3, 4)));
 421 extern NORET_TYPE void ext2_panic (struct super_block *, const char *,
 422                                    const char *, ...)
 423         __attribute__ ((NORET_AND format (printf, 3, 4)));
 424 extern void ext2_warning (struct super_block *, const char *, const char *, ...)
 425         __attribute__ ((format (printf, 3, 4)));
 426 extern void ext2_put_super (struct super_block *);
 427 extern void ext2_write_super (struct super_block *);
 428 extern int ext2_remount (struct super_block *, int *, char *);
 429 extern struct super_block * ext2_read_super (struct super_block *,void *,int);
 430 extern void ext2_statfs (struct super_block *, struct statfs *);
 431 
 432 /* truncate.c */
 433 extern void ext2_truncate (struct inode *);
 434 
 435 /*
 436  * Inodes and files operations
 437  */
 438 
 439 /* dir.c */
 440 extern struct inode_operations ext2_dir_inode_operations;
 441 
 442 /* file.c */
 443 extern struct inode_operations ext2_file_inode_operations;
 444 
 445 /* symlink.c */
 446 extern struct inode_operations ext2_symlink_inode_operations;
 447 
 448 #endif  /* __KERNEL__ */
 449 
 450 #endif  /* _LINUX_EXT2_FS_H */

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