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

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