1 /*
2 * befs_fs.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 typedef u64 befs_blocknr_t;
17 typedef u32 vfs_blocknr_t;
18
19 /*
20 * BeFS in memory structures
21 */
22
23 typedef struct befs_mount_options {
24 gid_t gid;
25 uid_t uid;
26 int use_gid;
27 int use_uid;
28 int debug;
29 char *iocharset;
30 } befs_mount_options;
31
32 typedef struct befs_sb_info {
33 u32 magic1;
34 u32 block_size;
35 u32 block_shift;
36 int byte_order;
37 befs_off_t num_blocks;
38 befs_off_t used_blocks;
39 u32 inode_size;
40 u32 magic2;
41
42 /* Allocation group information */
43 u32 blocks_per_ag;
44 u32 ag_shift;
45 u32 num_ags;
46
47 /* jornal log entry */
48 befs_block_run log_blocks;
49 befs_off_t log_start;
50 befs_off_t log_end;
51
52 befs_inode_addr root_dir;
53 befs_inode_addr indices;
54 u32 magic3;
55
56 befs_mount_options mount_opts;
57 struct nls_table *nls;
58
59 } befs_sb_info;
60
61 typedef struct befs_inode_info {
62 u32 i_flags;
63 u32 i_type;
64
65 befs_inode_addr i_inode_num;
66 befs_inode_addr i_parent;
67 befs_inode_addr i_attribute;
68
69 union {
70 befs_data_stream ds;
71 char symlink[BEFS_SYMLINK_LEN];
72 } i_data;
73
74 } befs_inode_info;
75
76 enum befs_err {
77 BEFS_OK,
78 BEFS_ERR,
79 BEFS_BAD_INODE,
80 BEFS_BT_END,
81 BEFS_BT_EMPTY,
82 BEFS_BT_MATCH,
83 BEFS_BT_PARMATCH,
84 BEFS_BT_NOT_FOUND
85 };
86
87 /****************************/
88 /* debug.c */
89 void befs_error(const struct super_block *sb, const char *fmt, ...);
90 void befs_warning(const struct super_block *sb, const char *fmt, ...);
91 void befs_debug(const struct super_block *sb, const char *fmt, ...);
92
93 void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
94 void befs_dump_inode(const struct super_block *sb, befs_inode *);
95 void befs_dump_index_entry(const struct super_block *sb, befs_btree_super *);
96 void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
97 void befs_dump_inode_addr(const struct super_block *sb, befs_inode_addr);
98 /****************************/
99
100 /* Gets a pointer to the private portion of the super_block
101 * structure from the public part
102 */
103 static inline befs_sb_info *
BEFS_SB(const struct super_block * super)104 BEFS_SB(const struct super_block *super)
105 {
106 return (befs_sb_info *) super->u.generic_sbp;
107 }
108
109 static inline befs_inode_info *
BEFS_I(const struct inode * inode)110 BEFS_I(const struct inode *inode)
111 {
112 return (befs_inode_info *) inode->u.generic_ip;
113 }
114
115 static inline befs_blocknr_t
iaddr2blockno(struct super_block * sb,befs_inode_addr * iaddr)116 iaddr2blockno(struct super_block *sb, befs_inode_addr * iaddr)
117 {
118 return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
119 iaddr->start);
120 }
121
122 static inline befs_inode_addr
blockno2iaddr(struct super_block * sb,befs_blocknr_t blockno)123 blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
124 {
125 befs_inode_addr iaddr;
126 iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
127 iaddr.start =
128 blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
129 iaddr.len = 1;
130
131 return iaddr;
132 }
133
134 static inline unsigned int
befs_iaddrs_per_block(struct super_block * sb)135 befs_iaddrs_per_block(struct super_block *sb)
136 {
137 return BEFS_SB(sb)->block_size / sizeof (befs_inode_addr);
138 }
139
140 static inline int
befs_iaddr_is_empty(befs_inode_addr * iaddr)141 befs_iaddr_is_empty(befs_inode_addr * iaddr)
142 {
143 return (!iaddr->allocation_group) && (!iaddr->start) && (!iaddr->len);
144 }
145
146 static inline size_t
befs_brun_size(struct super_block * sb,befs_block_run run)147 befs_brun_size(struct super_block *sb, befs_block_run run)
148 {
149 return BEFS_SB(sb)->block_size * run.len;
150 }
151
152 #endif /* _LINUX_BEFS_H */
153