linux/fs/befs/befs_fs_types.h
<<
>>
Prefs
   1/*
   2 * fs/befs/befs_fs_types.h
   3 *
   4 * Copyright (C) 2001 Will Dyson (will@cs.earlham.edu)
   5 *
   6 *
   7 *
   8 * from linux/include/linux/befs_fs.h
   9 *
  10 * Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
  11 *
  12 */
  13
  14#ifndef _LINUX_BEFS_FS_TYPES
  15#define _LINUX_BEFS_FS_TYPES
  16
  17#ifdef __KERNEL__
  18#include <linux/types.h>
  19#endif /*__KERNEL__*/
  20
  21#define PACKED __attribute__ ((__packed__))
  22
  23/*
  24 * Max name lengths of BFS
  25 */
  26
  27#define BEFS_NAME_LEN 255
  28
  29#define BEFS_SYMLINK_LEN 144
  30#define BEFS_NUM_DIRECT_BLOCKS 12
  31#define B_OS_NAME_LENGTH 32
  32
  33/* The datastream blocks mapped by the double-indirect
  34 * block are always 4 fs blocks long.
  35 * This eliminates the need for linear searches among
  36 * the potentially huge number of indirect blocks
  37 *
  38 * Err. Should that be 4 fs blocks or 4k???
  39 * It matters on large blocksize volumes
  40 */
  41#define BEFS_DBLINDIR_BRUN_LEN 4
  42
  43/*
  44 * Flags of superblock
  45 */
  46
  47enum super_flags {
  48        BEFS_BYTESEX_BE,
  49        BEFS_BYTESEX_LE,
  50        BEFS_CLEAN = 0x434c454e,
  51        BEFS_DIRTY = 0x44495254,
  52        BEFS_SUPER_MAGIC1 = 0x42465331, /* BFS1 */
  53        BEFS_SUPER_MAGIC2 = 0xdd121031,
  54        BEFS_SUPER_MAGIC3 = 0x15b6830e,
  55};
  56
  57#define BEFS_BYTEORDER_NATIVE 0x42494745
  58#define BEFS_BYTEORDER_NATIVE_LE (__force fs32)cpu_to_le32(BEFS_BYTEORDER_NATIVE)
  59#define BEFS_BYTEORDER_NATIVE_BE (__force fs32)cpu_to_be32(BEFS_BYTEORDER_NATIVE)
  60
  61#define BEFS_SUPER_MAGIC BEFS_SUPER_MAGIC1
  62#define BEFS_SUPER_MAGIC1_LE (__force fs32)cpu_to_le32(BEFS_SUPER_MAGIC1)
  63#define BEFS_SUPER_MAGIC1_BE (__force fs32)cpu_to_be32(BEFS_SUPER_MAGIC1)
  64
  65/*
  66 * Flags of inode
  67 */
  68
  69#define BEFS_INODE_MAGIC1 0x3bbe0ad9
  70
  71enum inode_flags {
  72        BEFS_INODE_IN_USE = 0x00000001,
  73        BEFS_ATTR_INODE = 0x00000004,
  74        BEFS_INODE_LOGGED = 0x00000008,
  75        BEFS_INODE_DELETED = 0x00000010,
  76        BEFS_LONG_SYMLINK = 0x00000040,
  77        BEFS_PERMANENT_FLAG = 0x0000ffff,
  78        BEFS_INODE_NO_CREATE = 0x00010000,
  79        BEFS_INODE_WAS_WRITTEN = 0x00020000,
  80        BEFS_NO_TRANSACTION = 0x00040000,
  81};
  82/* 
  83 * On-Disk datastructures of BeFS
  84 */
  85
  86typedef u64 __bitwise fs64;
  87typedef u32 __bitwise fs32;
  88typedef u16 __bitwise fs16;
  89
  90typedef u64 befs_off_t;
  91typedef fs64 befs_time_t;
  92
  93/* Block runs */
  94typedef struct {
  95        fs32 allocation_group;
  96        fs16 start;
  97        fs16 len;
  98} PACKED befs_disk_block_run;
  99
 100typedef struct {
 101        u32 allocation_group;
 102        u16 start;
 103        u16 len;
 104} PACKED befs_block_run;
 105
 106typedef befs_disk_block_run befs_disk_inode_addr;
 107typedef befs_block_run befs_inode_addr;
 108
 109/*
 110 * The Superblock Structure
 111 */
 112typedef struct {
 113        char name[B_OS_NAME_LENGTH];
 114        fs32 magic1;
 115        fs32 fs_byte_order;
 116
 117        fs32 block_size;
 118        fs32 block_shift;
 119
 120        fs64 num_blocks;
 121        fs64 used_blocks;
 122
 123        fs32 inode_size;
 124
 125        fs32 magic2;
 126        fs32 blocks_per_ag;
 127        fs32 ag_shift;
 128        fs32 num_ags;
 129
 130        fs32 flags;
 131
 132        befs_disk_block_run log_blocks;
 133        fs64 log_start;
 134        fs64 log_end;
 135
 136        fs32 magic3;
 137        befs_disk_inode_addr root_dir;
 138        befs_disk_inode_addr indices;
 139
 140} PACKED befs_super_block;
 141
 142/* 
 143 * Note: the indirect and dbl_indir block_runs may
 144 * be longer than one block!
 145 */
 146typedef struct {
 147        befs_disk_block_run direct[BEFS_NUM_DIRECT_BLOCKS];
 148        fs64 max_direct_range;
 149        befs_disk_block_run indirect;
 150        fs64 max_indirect_range;
 151        befs_disk_block_run double_indirect;
 152        fs64 max_double_indirect_range;
 153        fs64 size;
 154} PACKED befs_disk_data_stream;
 155
 156typedef struct {
 157        befs_block_run direct[BEFS_NUM_DIRECT_BLOCKS];
 158        befs_off_t max_direct_range;
 159        befs_block_run indirect;
 160        befs_off_t max_indirect_range;
 161        befs_block_run double_indirect;
 162        befs_off_t max_double_indirect_range;
 163        befs_off_t size;
 164} PACKED befs_data_stream;
 165
 166/* Attribute */
 167typedef struct {
 168        fs32 type;
 169        fs16 name_size;
 170        fs16 data_size;
 171        char name[1];
 172} PACKED befs_small_data;
 173
 174/* Inode structure */
 175typedef struct {
 176        fs32 magic1;
 177        befs_disk_inode_addr inode_num;
 178        fs32 uid;
 179        fs32 gid;
 180        fs32 mode;
 181        fs32 flags;
 182        befs_time_t create_time;
 183        befs_time_t last_modified_time;
 184        befs_disk_inode_addr parent;
 185        befs_disk_inode_addr attributes;
 186        fs32 type;
 187
 188        fs32 inode_size;
 189        fs32 etc;               /* not use */
 190
 191        union {
 192                befs_disk_data_stream datastream;
 193                char symlink[BEFS_SYMLINK_LEN];
 194        } data;
 195
 196        fs32 pad[4];            /* not use */
 197        befs_small_data small_data[1];
 198} PACKED befs_inode;
 199
 200/*
 201 * B+tree superblock
 202 */
 203
 204#define BEFS_BTREE_MAGIC 0x69f6c2e8
 205
 206enum btree_types {
 207        BTREE_STRING_TYPE = 0,
 208        BTREE_INT32_TYPE = 1,
 209        BTREE_UINT32_TYPE = 2,
 210        BTREE_INT64_TYPE = 3,
 211        BTREE_UINT64_TYPE = 4,
 212        BTREE_FLOAT_TYPE = 5,
 213        BTREE_DOUBLE_TYPE = 6
 214};
 215
 216typedef struct {
 217        fs32 magic;
 218        fs32 node_size;
 219        fs32 max_depth;
 220        fs32 data_type;
 221        fs64 root_node_ptr;
 222        fs64 free_node_ptr;
 223        fs64 max_size;
 224} PACKED befs_disk_btree_super;
 225
 226typedef struct {
 227        u32 magic;
 228        u32 node_size;
 229        u32 max_depth;
 230        u32 data_type;
 231        befs_off_t root_node_ptr;
 232        befs_off_t free_node_ptr;
 233        befs_off_t max_size;
 234} PACKED befs_btree_super;
 235
 236/*
 237 * Header stucture of each btree node
 238 */
 239typedef struct {
 240        fs64 left;
 241        fs64 right;
 242        fs64 overflow;
 243        fs16 all_key_count;
 244        fs16 all_key_length;
 245} PACKED befs_btree_nodehead;
 246
 247typedef struct {
 248        befs_off_t left;
 249        befs_off_t right;
 250        befs_off_t overflow;
 251        u16 all_key_count;
 252        u16 all_key_length;
 253} PACKED befs_host_btree_nodehead;
 254
 255#endif                          /* _LINUX_BEFS_FS_TYPES */
 256