]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - fs/befs/befs.h
befs: replace typedef befs_sb_info by structure
[mirror_ubuntu-zesty-kernel.git] / fs / befs / befs.h
CommitLineData
1da177e4
LT
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
17typedef u64 befs_blocknr_t;
18/*
19 * BeFS in memory structures
20 */
21
09ad0eae 22struct befs_mount_options {
31aba059
EB
23 kgid_t gid;
24 kuid_t uid;
1da177e4
LT
25 int use_gid;
26 int use_uid;
27 int debug;
28 char *iocharset;
09ad0eae 29};
1da177e4 30
038428fc 31struct befs_sb_info {
1da177e4
LT
32 u32 magic1;
33 u32 block_size;
34 u32 block_shift;
35 int byte_order;
36 befs_off_t num_blocks;
37 befs_off_t used_blocks;
38 u32 inode_size;
39 u32 magic2;
40
41 /* Allocation group information */
42 u32 blocks_per_ag;
43 u32 ag_shift;
44 u32 num_ags;
45
46 /* jornal log entry */
47 befs_block_run log_blocks;
48 befs_off_t log_start;
49 befs_off_t log_end;
50
51 befs_inode_addr root_dir;
52 befs_inode_addr indices;
53 u32 magic3;
54
09ad0eae 55 struct befs_mount_options mount_opts;
1da177e4 56 struct nls_table *nls;
038428fc 57};
1da177e4
LT
58
59typedef struct befs_inode_info {
60 u32 i_flags;
61 u32 i_type;
62
63 befs_inode_addr i_inode_num;
64 befs_inode_addr i_parent;
65 befs_inode_addr i_attribute;
66
67 union {
68 befs_data_stream ds;
69 char symlink[BEFS_SYMLINK_LEN];
70 } i_data;
71
72 struct inode vfs_inode;
73
74} befs_inode_info;
75
76enum 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/****************************/
89/* debug.c */
dac52fc1 90__printf(2, 3)
1da177e4 91void befs_error(const struct super_block *sb, const char *fmt, ...);
dac52fc1 92__printf(2, 3)
1da177e4 93void befs_warning(const struct super_block *sb, const char *fmt, ...);
dac52fc1 94__printf(2, 3)
1da177e4
LT
95void befs_debug(const struct super_block *sb, const char *fmt, ...);
96
97void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
98void befs_dump_inode(const struct super_block *sb, befs_inode *);
a9721f31 99void befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super *);
1da177e4
LT
100void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
101/****************************/
102
103
104/* Gets a pointer to the private portion of the super_block
105 * structure from the public part
106 */
038428fc 107static inline struct befs_sb_info *
1da177e4
LT
108BEFS_SB(const struct super_block *super)
109{
038428fc 110 return (struct befs_sb_info *) super->s_fs_info;
1da177e4
LT
111}
112
113static inline befs_inode_info *
114BEFS_I(const struct inode *inode)
115{
116 return list_entry(inode, struct befs_inode_info, vfs_inode);
117}
118
119static inline befs_blocknr_t
120iaddr2blockno(struct super_block *sb, befs_inode_addr * iaddr)
121{
122 return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
123 iaddr->start);
124}
125
126static inline befs_inode_addr
127blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
128{
129 befs_inode_addr iaddr;
130 iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
131 iaddr.start =
132 blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
133 iaddr.len = 1;
134
135 return iaddr;
136}
137
138static inline unsigned int
139befs_iaddrs_per_block(struct super_block *sb)
140{
a9721f31 141 return BEFS_SB(sb)->block_size / sizeof (befs_disk_inode_addr);
1da177e4
LT
142}
143
144static inline int
145befs_iaddr_is_empty(befs_inode_addr * iaddr)
146{
147 return (!iaddr->allocation_group) && (!iaddr->start) && (!iaddr->len);
148}
149
150static inline size_t
151befs_brun_size(struct super_block *sb, befs_block_run run)
152{
153 return BEFS_SB(sb)->block_size * run.len;
154}
155
af10b008
AV
156#include "endian.h"
157
1da177e4 158#endif /* _LINUX_BEFS_H */