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

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