ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / fs / befs / befs.h
1 /*
2  * befs.h
3  *
4  * Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
5  * Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
6  */
7
8 #ifndef _LINUX_BEFS_H
9 #define _LINUX_BEFS_H
10
11 #include "befs_fs_types.h"
12
13 /* used in debug.c */
14 #define BEFS_VERSION "0.9.3"
15
16
17 /* Sector_t makes this sillyness obsolete */
18 typedef u64 befs_blocknr_t;
19 typedef u32 vfs_blocknr_t;
20
21 /*
22  * BeFS in memory structures
23  */
24
25 typedef struct befs_mount_options {
26         gid_t gid;
27         uid_t uid;
28         int use_gid;
29         int use_uid;
30         int debug;
31         char *iocharset;
32 } befs_mount_options;
33
34 typedef struct befs_sb_info {
35         u32 magic1;
36         u32 block_size;
37         u32 block_shift;
38         int byte_order;
39         befs_off_t num_blocks;
40         befs_off_t used_blocks;
41         u32 inode_size;
42         u32 magic2;
43
44         /* Allocation group information */
45         u32 blocks_per_ag;
46         u32 ag_shift;
47         u32 num_ags;
48
49         /* jornal log entry */
50         befs_block_run log_blocks;
51         befs_off_t log_start;
52         befs_off_t log_end;
53
54         befs_inode_addr root_dir;
55         befs_inode_addr indices;
56         u32 magic3;
57
58         befs_mount_options mount_opts;
59         struct nls_table *nls;
60
61 } befs_sb_info;
62
63 typedef struct befs_inode_info {
64         u32 i_flags;
65         u32 i_type;
66
67         befs_inode_addr i_inode_num;
68         befs_inode_addr i_parent;
69         befs_inode_addr i_attribute;
70
71         union {
72                 befs_data_stream ds;
73                 char symlink[BEFS_SYMLINK_LEN];
74         } i_data;
75
76         struct inode vfs_inode;
77
78 } befs_inode_info;
79
80 enum befs_err {
81         BEFS_OK,
82         BEFS_ERR,
83         BEFS_BAD_INODE,
84         BEFS_BT_END,
85         BEFS_BT_EMPTY,
86         BEFS_BT_MATCH,
87         BEFS_BT_PARMATCH,
88         BEFS_BT_NOT_FOUND
89 };
90
91
92 /****************************/
93 /* debug.c */
94 void befs_error(const struct super_block *sb, const char *fmt, ...);
95 void befs_warning(const struct super_block *sb, const char *fmt, ...);
96 void befs_debug(const struct super_block *sb, const char *fmt, ...);
97
98 void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
99 void befs_dump_inode(const struct super_block *sb, befs_inode *);
100 void befs_dump_index_entry(const struct super_block *sb, befs_btree_super *);
101 void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
102 void befs_dump_inode_addr(const struct super_block *sb, befs_inode_addr);
103 /****************************/
104
105
106 /* Gets a pointer to the private portion of the super_block
107  * structure from the public part
108  */
109 static inline befs_sb_info *
110 BEFS_SB(const struct super_block *super)
111 {
112         return (befs_sb_info *) super->s_fs_info;
113 }
114
115 static inline befs_inode_info *
116 BEFS_I(const struct inode *inode)
117 {
118         return list_entry(inode, struct befs_inode_info, vfs_inode);
119 }
120
121 static inline befs_blocknr_t
122 iaddr2blockno(struct super_block *sb, befs_inode_addr * iaddr)
123 {
124         return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
125                 iaddr->start);
126 }
127
128 static inline befs_inode_addr
129 blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
130 {
131         befs_inode_addr iaddr;
132         iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
133         iaddr.start =
134             blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
135         iaddr.len = 1;
136
137         return iaddr;
138 }
139
140 static inline unsigned int
141 befs_iaddrs_per_block(struct super_block *sb)
142 {
143         return BEFS_SB(sb)->block_size / sizeof (befs_inode_addr);
144 }
145
146 static inline int
147 befs_iaddr_is_empty(befs_inode_addr * iaddr)
148 {
149         return (!iaddr->allocation_group) && (!iaddr->start) && (!iaddr->len);
150 }
151
152 static inline size_t
153 befs_brun_size(struct super_block *sb, befs_block_run run)
154 {
155         return BEFS_SB(sb)->block_size * run.len;
156 }
157
158 #endif                          /* _LINUX_BEFS_H */