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

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