blob: eb557d9dc8be973ae82c89feb274275202080059 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * fs/befs/befs_fs_types.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
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
Harvey Harrison152b95a2008-10-15 22:04:03 -070058#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)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61#define BEFS_SUPER_MAGIC BEFS_SUPER_MAGIC1
Harvey Harrison152b95a2008-10-15 22:04:03 -070062#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)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
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
Al Viro11518952005-12-24 01:32:03 -050086typedef u64 __bitwise fs64;
87typedef u32 __bitwise fs32;
88typedef u16 __bitwise fs16;
89
Linus Torvalds1da177e2005-04-16 15:20:36 -070090typedef u64 befs_off_t;
Al Viroa9721f32005-12-24 14:28:55 -050091typedef fs64 befs_time_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93/* Block runs */
94typedef struct {
Al Viroa9721f32005-12-24 14:28:55 -050095 fs32 allocation_group;
96 fs16 start;
97 fs16 len;
98} PACKED befs_disk_block_run;
99
100typedef struct {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 u32 allocation_group;
102 u16 start;
103 u16 len;
104} PACKED befs_block_run;
105
Al Viroa9721f32005-12-24 14:28:55 -0500106typedef befs_disk_block_run befs_disk_inode_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107typedef befs_block_run befs_inode_addr;
108
109/*
110 * The Superblock Structure
111 */
112typedef struct {
113 char name[B_OS_NAME_LENGTH];
Al Viroa9721f32005-12-24 14:28:55 -0500114 fs32 magic1;
115 fs32 fs_byte_order;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Al Viroa9721f32005-12-24 14:28:55 -0500117 fs32 block_size;
118 fs32 block_shift;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
Al Viroa9721f32005-12-24 14:28:55 -0500120 fs64 num_blocks;
121 fs64 used_blocks;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
Al Viroa9721f32005-12-24 14:28:55 -0500123 fs32 inode_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
Al Viroa9721f32005-12-24 14:28:55 -0500125 fs32 magic2;
126 fs32 blocks_per_ag;
127 fs32 ag_shift;
128 fs32 num_ags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
Al Viroa9721f32005-12-24 14:28:55 -0500130 fs32 flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
Al Viroa9721f32005-12-24 14:28:55 -0500132 befs_disk_block_run log_blocks;
133 fs64 log_start;
134 fs64 log_end;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
Al Viroa9721f32005-12-24 14:28:55 -0500136 fs32 magic3;
137 befs_disk_inode_addr root_dir;
138 befs_disk_inode_addr indices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
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 {
Al Viroa9721f32005-12-24 14:28:55 -0500147 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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 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 {
Al Viroa9721f32005-12-24 14:28:55 -0500168 fs32 type;
169 fs16 name_size;
170 fs16 data_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 char name[1];
172} PACKED befs_small_data;
173
174/* Inode structure */
175typedef struct {
Al Viroa9721f32005-12-24 14:28:55 -0500176 fs32 magic1;
177 befs_disk_inode_addr inode_num;
178 fs32 uid;
179 fs32 gid;
180 fs32 mode;
181 fs32 flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 befs_time_t create_time;
183 befs_time_t last_modified_time;
Al Viroa9721f32005-12-24 14:28:55 -0500184 befs_disk_inode_addr parent;
185 befs_disk_inode_addr attributes;
186 fs32 type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
Al Viroa9721f32005-12-24 14:28:55 -0500188 fs32 inode_size;
189 fs32 etc; /* not use */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
191 union {
Al Viroa9721f32005-12-24 14:28:55 -0500192 befs_disk_data_stream datastream;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 char symlink[BEFS_SYMLINK_LEN];
194 } data;
195
Al Viroa9721f32005-12-24 14:28:55 -0500196 fs32 pad[4]; /* not use */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 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 {
Al Viroa9721f32005-12-24 14:28:55 -0500217 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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 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/*
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300237 * Header structure of each btree node
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 */
239typedef struct {
Al Viroa9721f32005-12-24 14:28:55 -0500240 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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 befs_off_t left;
249 befs_off_t right;
250 befs_off_t overflow;
251 u16 all_key_count;
252 u16 all_key_length;
Al Viroa9721f32005-12-24 14:28:55 -0500253} PACKED befs_host_btree_nodehead;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
255#endif /* _LINUX_BEFS_FS_TYPES */