home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1998 February / PCOnline_02_1998.iso / filesbbs / dos / lread10.exe / EXT2.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-23  |  3.7 KB  |  137 lines

  1. /* ext2.h
  2.  * David Lutz
  3.  *
  4.  * This file contains important file system information like
  5.  * the superblock, inode and group structures and a few global
  6.  * variables.
  7.  */
  8.  
  9. #ifndef _EXT2_H_
  10. #define _EXT2_H_
  11.  
  12. /* This is screwy because under Linux (at least on Jason't system) 
  13.  * sys/stat.h calls sys/types.h which calls Linux/types.h which is 
  14.  * asm/types.h which already has __xx.  Get that?  So I made it _xx here
  15.  * to avoid conflicts.
  16.  * --Jason
  17. */
  18.  
  19. typedef signed char _s8;
  20. typedef unsigned char _u8;
  21. typedef _u8 byte;
  22.  
  23. typedef signed short _s16;
  24. typedef unsigned short _u16;
  25.  
  26. typedef signed long _s32;
  27. typedef unsigned long _u32;
  28. /*
  29. typedef _u32 ulong;
  30. */
  31.  
  32. #define EXT2_SUPER_MAGIC 0xEF53
  33. #define EXT2_MIN_BLOCK 1024
  34. #define EXT2_MIN_FRAG 1024
  35.  
  36. /*
  37.  * Super Block Structure
  38.  */
  39. typedef struct
  40. {
  41.   _u32    s_inodes_count;        /* Inodes count */
  42.   _u32    s_blocks_count;        /* Blocks count */
  43.   _u32    s_r_blocks_count;    /* Reserved blocks count */
  44.   _u32    s_free_blocks_count;    /* Free blocks count */
  45.   _u32    s_free_inodes_count;    /* Free inodes count */
  46.   _u32    s_first_data_block;    /* First Data Block */
  47.   _u32    s_log_block_size;    /* Block size */
  48.   _s32    s_log_frag_size;    /* Fragment size */
  49.   _u32    s_blocks_per_group;    /* # Blocks per group */
  50.   _u32    s_frags_per_group;    /* # Fragments per group */
  51.   _u32    s_inodes_per_group;    /* # Inodes per group */
  52.   _u32    s_mtime;        /* Mount time */
  53.   _u32    s_wtime;        /* Write time */
  54.   _u16    s_mnt_count;        /* Mount count */
  55.   _s16    s_max_mnt_count;    /* Maximal mount count */
  56.   _u16    s_magic;        /* Magic signature */
  57.   _u16    s_state;        /* File system state */
  58.   _u16    s_errors;        /* Behaviour when detecting errors */
  59.   _u16    s_pad;
  60.   _u32    s_lastcheck;        /* time of last check */
  61.   _u32    s_checkinterval;    /* max. time between checks */
  62.   _u32    s_creator_os;        /* OS */
  63.   _u32    s_rev_level;        /* Revision level */
  64.   _u16    s_def_resuid;        /* Default uid for reserved blocks */
  65.   _u16    s_def_resgid;        /* Default gid for reserved blocks */
  66.   _u32    s_reserved[235];    /* Padding to the end of the block */
  67. } super_block;
  68.  
  69. /*
  70.  * Group Descriptor Structure
  71.  */
  72. typedef struct
  73. {
  74.   _u32    bg_block_bitmap;    /* Blocks bitmap block */
  75.   _u32    bg_inode_bitmap;    /* Inodes bitmap block */
  76.   _u32    bg_inode_table;        /* Inodes table block */
  77.   _u16    bg_free_blocks_count;    /* Free blocks count */
  78.   _u16    bg_free_inodes_count;    /* Free inodes count */
  79.   _u16    bg_used_dirs_count;    /* Directories count */
  80.   _u16    bg_pad;
  81.   _u32    bg_reserved[3];
  82. } group_desc;
  83.  
  84. /*
  85.  * Inode Structure
  86.  */
  87. typedef struct
  88. {
  89.   _u16 i_mode;            /* File mode */
  90.   _u16 i_uid;            /* Owner Uid */
  91.   _u32 i_size;            /* Size in bytes */
  92.   _u32 i_atime;            /* Access time */
  93.   _u32 i_ctime;            /* Creation time */
  94.   _u32 i_mtime;            /* Modification time */
  95.   _u32 i_dtime;            /* Deletion Time */
  96.   _u16 i_gid;            /* Group Id */
  97.   _u16 i_links_count;        /* Links count */
  98.   _u32 i_blocks;        /* Blocks count */
  99.   _u32 i_flags;            /* File flags */
  100.   _u32 i_reserved1;        /* Reserved 1 */
  101.   _u32    i_block[15];        /* Pointers to blocks */
  102.   _u32    i_version;        /* File version (for NFS) */
  103.   _u32    i_file_acl;        /* File ACL */
  104.   _u32    i_dir_acl;        /* Directory ACL */
  105.   _u32    i_faddr;        /* Fragment address */
  106.   _u8  i_frag;            /* Fragment number */
  107.   _u8  i_fsize;            /* Fragment size */
  108.   _u32 i_reserved2[2];        /* Reserved 2 */
  109. } inode;
  110.  
  111. /*
  112.  * Directory Structure
  113.  */
  114. struct dir
  115. {
  116.   long inode_num;
  117.   char *name;        /* between 0 and 256 chars */
  118.   struct dir *next;
  119. };
  120.  
  121.  
  122. /*
  123.  * Global Variables, not many
  124.  */
  125. #ifndef _SUPER_C_
  126.  extern super_block sb;
  127.  extern int BLOCK_SIZE;
  128.  extern int FRAG_SIZE;
  129. #endif
  130.  
  131. #ifndef _GROUP_C_
  132.  extern group_desc *gt;
  133.  extern int num_groups;
  134. #endif
  135.  
  136. #endif /* _EXT2_H_ */
  137.