root/include/linux/ext2_fs.h

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

INCLUDED FROM


   1 #ifndef _LINUX_EXT2_FS_H
   2 #define _LINUX_EXT2_FS_H
   3 
   4 /*
   5  * The second extended filesystem constants/structures
   6  */
   7 
   8 /*
   9  * Define EXT2FS_DEBUG to produce debug messages
  10  */
  11 #undef EXT2FS_DEBUG
  12 
  13 /*
  14  * Define EXT2FS_PRE_02B_COMPAT to convert ext 2 fs prior to 0.2b
  15  */
  16 #undef EXT2FS_PRE_02B_COMPAT
  17 
  18 /*
  19  * Define DONT_USE_DCACHE to inhibit the directory cache
  20  */
  21 #undef DONT_USE_DCACHE
  22 
  23 /*
  24  * Define EXT2FS_DEBUG_CACHE to produce cache debug messages
  25  */
  26 #undef EXT2FS_DEBUG_CACHE
  27 
  28 /*
  29  * The second extended file system version
  30  */
  31 #define EXT2FS_DATE             "93/08/05"
  32 #define EXT2FS_VERSION          "0.3c"
  33 
  34 /*
  35  * Special inodes numbers
  36  */
  37 #define EXT2_BAD_INO             1      /* Bad blocks inode */
  38 #define EXT2_ROOT_INO            2      /* Root inode */
  39 #define EXT2_ACL_IDX_INO         3      /* ACL inode */
  40 #define EXT2_ACL_DATA_INO        4      /* ACL inode */
  41 #define EXT2_BOOT_LOADER_INO     5      /* Boot loader inode */
  42 #define EXT2_FIRST_INO          11      /* First non reserved inode */
  43 
  44 /*
  45  * The second extended file system magic number
  46  */
  47 #define EXT2_OLD_SUPER_MAGIC    0xEF51
  48 #define EXT2_SUPER_MAGIC        0xEF53
  49 
  50 /*
  51  * Maximal count of links to a file
  52  */
  53 #define EXT2_LINK_MAX           32000
  54 
  55 /*
  56  * Macro-instructions used to manage several block sizes
  57  */
  58 #define EXT2_MIN_BLOCK_SIZE             1024
  59 #define EXT2_MAX_BLOCK_SIZE             4096
  60 #define EXT2_MIN_BLOCK_LOG_SIZE           10
  61 #ifdef __KERNEL__
  62 # define EXT2_BLOCK_SIZE(s)             ((s)->s_blocksize)
  63 #else
  64 # define EXT2_BLOCK_SIZE(s)             (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  65 #endif
  66 #define EXT2_ACLE_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
  67 #define EXT2_ADDR_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof (unsigned long))
  68 #ifdef __KERNEL__
  69 # define EXT2_BLOCK_SIZE_BITS(s)        ((s)->u.ext2_sb.s_es->s_log_block_size + 10)
  70 #else
  71 # define EXT2_BLOCK_SIZE_BITS(s)        ((s)->s_log_block_size + 10)
  72 #endif
  73 #define EXT2_INODES_PER_BLOCK(s)        (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_inode))
  74 
  75 /*
  76  * Macro-instructions used to manage fragments
  77  */
  78 #define EXT2_MIN_FRAG_SIZE              1024
  79 #define EXT2_MAX_FRAG_SIZE              4096
  80 #define EXT2_MIN_FRAG_LOG_SIZE            10
  81 #ifdef __KERNEL__
  82 # define EXT2_FRAG_SIZE(s)              ((s)->u.ext2_sb.s_frag_size)
  83 # define EXT2_FRAGS_PER_BLOCK(s)        ((s)->u.ext2_sb.s_frags_per_block)
  84 #else
  85 # define EXT2_FRAG_SIZE(s)              (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
  86 # define EXT2_FRAGS_PER_BLOCK(s)        (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
  87 #endif
  88 
  89 /*
  90  * ACL structures
  91  */
  92 struct ext2_acl_header  /* Header of Access Control Lists */
  93 {
  94         unsigned long aclh_size;
  95         unsigned long aclh_file_count;
  96         unsigned long aclh_acle_count;
  97         unsigned long aclh_first_acle;
  98 };
  99 
 100 struct ext2_acl_entry   /* Access Control List Entry */
 101 {
 102         unsigned long  acle_size;
 103         unsigned short acle_perms;      /* Access permissions */
 104         unsigned short acle_type;       /* Type of entry */
 105         unsigned short acle_tag;        /* User or group identity */
 106         unsigned short acle_pad1;
 107         unsigned long  acle_next;       /* Pointer on next entry for the */
 108                                         /* same inode or on next free entry */
 109 };
 110 
 111 /*
 112  * Structure of a blocks group descriptor
 113  */
 114 struct ext2_old_group_desc
 115 {
 116         unsigned long  bg_block_bitmap;         /* Blocks bitmap block */
 117         unsigned long  bg_inode_bitmap;         /* Inodes bitmap block */
 118         unsigned long  bg_inode_table;          /* Inodes table block */
 119         unsigned short bg_free_blocks_count;    /* Free blocks count */
 120         unsigned short bg_free_inodes_count;    /* Free inodes count */
 121 };
 122 
 123 struct ext2_group_desc
 124 {
 125         unsigned long  bg_block_bitmap;         /* Blocks bitmap block */
 126         unsigned long  bg_inode_bitmap;         /* Inodes bitmap block */
 127         unsigned long  bg_inode_table;          /* Inodes table block */
 128         unsigned short bg_free_blocks_count;    /* Free blocks count */
 129         unsigned short bg_free_inodes_count;    /* Free inodes count */
 130         unsigned short bg_used_dirs_count;      /* Directories count */
 131         unsigned short bg_pad;
 132         unsigned long  bg_reserved[3];
 133 };
 134 
 135 /*
 136  * Macro-instructions used to manage group descriptors
 137  */
 138 #ifdef __KERNEL__
 139 # define EXT2_BLOCKS_PER_GROUP(s)       ((s)->u.ext2_sb.s_blocks_per_group)
 140 # define EXT2_DESC_PER_BLOCK(s)         ((s)->u.ext2_sb.s_desc_per_block)
 141 # define EXT2_INODES_PER_GROUP(s)       ((s)->u.ext2_sb.s_inodes_per_group)
 142 #else
 143 # define EXT2_BLOCKS_PER_GROUP(s)       ((s)->s_blocks_per_group)
 144 # define EXT2_DESC_PER_BLOCK(s)         (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
 145 # define EXT2_INODES_PER_GROUP(s)       ((s)->s_inodes_per_group)
 146 #endif
 147 
 148 /*
 149  * Constants relative to the data blocks
 150  */
 151 #define EXT2_NDIR_BLOCKS                12
 152 #define EXT2_IND_BLOCK                  EXT2_NDIR_BLOCKS
 153 #define EXT2_DIND_BLOCK                 (EXT2_IND_BLOCK + 1)
 154 #define EXT2_TIND_BLOCK                 (EXT2_DIND_BLOCK + 1)
 155 #define EXT2_N_BLOCKS                   (EXT2_TIND_BLOCK + 1)
 156 
 157 /*
 158  * Structure of an inode on the disk
 159  */
 160 struct ext2_inode {
 161         unsigned short i_mode;          /* File mode */
 162         unsigned short i_uid;           /* Owner Uid */
 163         unsigned long  i_size;          /* Size in bytes */
 164         unsigned long  i_atime;         /* Access time */
 165         unsigned long  i_ctime;         /* Creation time */
 166         unsigned long  i_mtime;         /* Modification time */
 167         unsigned long  i_dtime;         /* Deletion Time */
 168         unsigned short i_gid;           /* Group Id */
 169         unsigned short i_links_count;   /* Links count */
 170         unsigned long  i_blocks;        /* Blocks count */
 171         unsigned long  i_flags;         /* File flags */
 172         unsigned long  i_reserved1;
 173         unsigned long  i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
 174         unsigned long  i_version;       /* File version (for NFS) */
 175         unsigned long  i_file_acl;      /* File ACL */
 176         unsigned long  i_dir_acl;       /* Directory ACL */
 177         unsigned long  i_faddr;         /* Fragment address */
 178         unsigned char  i_frag;          /* Fragment number */
 179         unsigned char  i_fsize;         /* Fragment size */
 180         unsigned short i_pad1;
 181         unsigned long  i_reserved2[2];
 182 };
 183 
 184 /*
 185  * Structure of the super block
 186  */
 187 struct ext2_super_block {
 188         unsigned long  s_inodes_count;  /* Inodes count */
 189         unsigned long  s_blocks_count;  /* Blocks count */
 190         unsigned long  s_r_blocks_count;/* Reserved blocks count */
 191         unsigned long  s_free_blocks_count;/* Free blocks count */
 192         unsigned long  s_free_inodes_count;/* Free inodes count */
 193         unsigned long  s_first_data_block;/* First Data Block */
 194         unsigned long  s_log_block_size;/* Block size */
 195         long           s_log_frag_size; /* Fragment size */
 196         unsigned long  s_blocks_per_group;/* # Blocks per group */
 197         unsigned long  s_frags_per_group;/* # Fragments per group */
 198         unsigned long  s_inodes_per_group;/* # Inodes per group */
 199         unsigned long  s_mtime;         /* Mount time */
 200         unsigned long  s_wtime;         /* Write time */
 201         unsigned long  s_pad;           /* Padding to get the magic signature*/
 202                                         /* at the same offset as in the */
 203                                         /* previous ext fs */
 204         unsigned short s_magic;         /* Magic signature */
 205         unsigned short s_valid;         /* Flag */
 206         unsigned long  s_reserved[243]; /* Padding to the end of the block */
 207 };
 208 
 209 /*
 210  * Structure of a directory entry
 211  */
 212 #define EXT2_NAME_LEN 255
 213 
 214 struct ext2_dir_entry {
 215         unsigned long  inode;                   /* Inode number */
 216         unsigned short rec_len;                 /* Directory entry length */
 217         unsigned short name_len;                /* Name length */
 218         char           name[EXT2_NAME_LEN];     /* File name */
 219 };
 220 
 221 /*
 222  * EXT2_DIR_PAD defines the directory entries boundaries
 223  *
 224  * NOTE: It must be a multiple of 4
 225  */
 226 #define EXT2_DIR_PAD                    4
 227 #define EXT2_DIR_ROUND                  (EXT2_DIR_PAD - 1)
 228 #define EXT2_DIR_REC_LEN(name_len)      (((name_len) + 8 + EXT2_DIR_ROUND) & \
 229                                          ~EXT2_DIR_ROUND)
 230 
 231 #ifdef __KERNEL__
 232 /*
 233  * Function prototypes
 234  */
 235 
 236 /* acl.c */
 237 extern int ext2_permission (struct inode *, int);
 238 
 239 /* balloc.c */
 240 extern int ext2_new_block (struct super_block *, unsigned long);
 241 extern void ext2_free_block (struct super_block *, unsigned long);
 242 extern unsigned long ext2_count_free_blocks (struct super_block *);
 243 
 244 /* bitmap.c */
 245 extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
 246 
 247 /* dcache.c */
 248 extern void ext2_dcache_invalidate (unsigned short);
 249 extern unsigned long ext2_dcache_lookup (unsigned short, unsigned long,
 250                                          const char *, int);
 251 extern void ext2_dcache_add (unsigned short, unsigned long, const char *,
 252                              int, int);
 253 extern void ext2_dcache_remove (unsigned short, unsigned long, const char *,
 254                                 int);
 255 
 256 /* dir.c */
 257 extern int ext2_check_dir_entry (char *, struct inode *,
 258                                  struct ext2_dir_entry *, struct buffer_head *,
 259                                  unsigned int);
 260 
 261 /* file.c */
 262 extern int ext2_read (struct inode *, struct file *, char *, int);
 263 extern int ext2_write (struct inode *, struct file *, char *, int);
 264 
 265 /* fsync.c */
 266 extern int ext2_sync_file (struct inode *, struct file *);
 267 
 268 /* ialloc.c */
 269 extern struct inode * ext2_new_inode (const struct inode *, int);
 270 extern void ext2_free_inode (struct inode *);
 271 extern unsigned long ext2_count_free_inodes (struct super_block *);
 272 
 273 /* inode.c */
 274 extern int ext2_bmap (struct inode *, int);
 275 
 276 extern struct buffer_head * ext2_getblk (struct inode *, int, int, int *);
 277 extern struct buffer_head * ext2_bread (struct inode *, int, int, int *);
 278 
 279 extern void ext2_put_super (struct super_block *);
 280 extern void ext2_write_super (struct super_block *);
 281 extern int ext2_remount (struct super_block *, int *);
 282 extern struct super_block * ext2_read_super (struct super_block *,void *,int);
 283 extern void ext2_read_inode (struct inode *);
 284 extern void ext2_write_inode (struct inode *);
 285 extern void ext2_put_inode (struct inode *);
 286 extern void ext2_statfs (struct super_block *, struct statfs *);
 287 extern int ext2_sync_inode(struct inode *);
 288 
 289 /* ioctl.c */
 290 extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
 291                        unsigned long);
 292 
 293 /* namei.c */
 294 extern int ext2_open (struct inode *, struct file *);
 295 extern void ext2_release (struct inode *, struct file *);
 296 extern int ext2_lookup (struct inode *,const char *, int, struct inode **);
 297 extern int ext2_create (struct inode *,const char *, int, int,
 298                         struct inode **);
 299 extern int ext2_mkdir (struct inode *, const char *, int, int);
 300 extern int ext2_rmdir (struct inode *, const char *, int);
 301 extern int ext2_unlink (struct inode *, const char *, int);
 302 extern int ext2_symlink (struct inode *, const char *, int, const char *);
 303 extern int ext2_link (struct inode *, struct inode *, const char *, int);
 304 extern int ext2_mknod (struct inode *, const char *, int, int, int);
 305 extern int ext2_rename (struct inode *, const char *, int,
 306                         struct inode *, const char *, int);
 307 
 308 /* truncate.c */
 309 extern void ext2_truncate (struct inode *);
 310 
 311 /*
 312  * Inodes and files operations
 313  */
 314 
 315 /* dir.c */
 316 extern struct inode_operations ext2_dir_inode_operations;
 317 
 318 /* file.c */
 319 extern struct inode_operations ext2_file_inode_operations;
 320 
 321 /* symlink.c */
 322 extern struct inode_operations ext2_symlink_inode_operations;
 323 
 324 #endif
 325 
 326 #endif

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