]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | /* |
3 | * befs.h | |
4 | * | |
5 | * Copyright (C) 2001-2002 Will Dyson <[email protected]> | |
6 | * Copyright (C) 1999 Makoto Kato ([email protected]) | |
7 | */ | |
8 | ||
9 | #ifndef _LINUX_BEFS_H | |
10 | #define _LINUX_BEFS_H | |
11 | ||
12 | #include "befs_fs_types.h" | |
13 | ||
14 | /* used in debug.c */ | |
15 | #define BEFS_VERSION "0.9.3" | |
16 | ||
17 | ||
18 | typedef u64 befs_blocknr_t; | |
19 | /* | |
20 | * BeFS in memory structures | |
21 | */ | |
22 | ||
09ad0eae | 23 | struct befs_mount_options { |
31aba059 EB |
24 | kgid_t gid; |
25 | kuid_t uid; | |
1da177e4 LT |
26 | int use_gid; |
27 | int use_uid; | |
28 | int debug; | |
29 | char *iocharset; | |
09ad0eae | 30 | }; |
1da177e4 | 31 | |
038428fc | 32 | struct befs_sb_info { |
1da177e4 LT |
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 | ||
6ea4558f ST |
47 | /* State of the superblock */ |
48 | u32 flags; | |
49 | ||
2ac636b4 | 50 | /* Journal log entry */ |
1da177e4 LT |
51 | befs_block_run log_blocks; |
52 | befs_off_t log_start; | |
53 | befs_off_t log_end; | |
54 | ||
55 | befs_inode_addr root_dir; | |
56 | befs_inode_addr indices; | |
57 | u32 magic3; | |
58 | ||
09ad0eae | 59 | struct befs_mount_options mount_opts; |
1da177e4 | 60 | struct nls_table *nls; |
038428fc | 61 | }; |
1da177e4 | 62 | |
f8ccad21 | 63 | struct befs_inode_info { |
1da177e4 LT |
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; | |
f8ccad21 | 77 | }; |
1da177e4 LT |
78 | |
79 | enum befs_err { | |
80 | BEFS_OK, | |
81 | BEFS_ERR, | |
82 | BEFS_BAD_INODE, | |
83 | BEFS_BT_END, | |
84 | BEFS_BT_EMPTY, | |
85 | BEFS_BT_MATCH, | |
672a8515 | 86 | BEFS_BT_OVERFLOW, |
1da177e4 LT |
87 | BEFS_BT_NOT_FOUND |
88 | }; | |
89 | ||
90 | ||
91 | /****************************/ | |
92 | /* debug.c */ | |
dac52fc1 | 93 | __printf(2, 3) |
1da177e4 | 94 | void befs_error(const struct super_block *sb, const char *fmt, ...); |
dac52fc1 | 95 | __printf(2, 3) |
1da177e4 | 96 | void befs_warning(const struct super_block *sb, const char *fmt, ...); |
dac52fc1 | 97 | __printf(2, 3) |
1da177e4 LT |
98 | void befs_debug(const struct super_block *sb, const char *fmt, ...); |
99 | ||
100 | void befs_dump_super_block(const struct super_block *sb, befs_super_block *); | |
101 | void befs_dump_inode(const struct super_block *sb, befs_inode *); | |
a9721f31 | 102 | void befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super *); |
1da177e4 LT |
103 | void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *); |
104 | /****************************/ | |
105 | ||
106 | ||
107 | /* Gets a pointer to the private portion of the super_block | |
108 | * structure from the public part | |
109 | */ | |
038428fc | 110 | static inline struct befs_sb_info * |
1da177e4 LT |
111 | BEFS_SB(const struct super_block *super) |
112 | { | |
038428fc | 113 | return (struct befs_sb_info *) super->s_fs_info; |
1da177e4 LT |
114 | } |
115 | ||
f8ccad21 | 116 | static inline struct befs_inode_info * |
1da177e4 LT |
117 | BEFS_I(const struct inode *inode) |
118 | { | |
db6172c4 | 119 | return container_of(inode, struct befs_inode_info, vfs_inode); |
1da177e4 LT |
120 | } |
121 | ||
122 | static inline befs_blocknr_t | |
22341d8f | 123 | iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr) |
1da177e4 LT |
124 | { |
125 | return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) + | |
126 | iaddr->start); | |
127 | } | |
128 | ||
129 | static inline befs_inode_addr | |
130 | blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno) | |
131 | { | |
132 | befs_inode_addr iaddr; | |
12ecb38d | 133 | |
1da177e4 LT |
134 | iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift; |
135 | iaddr.start = | |
136 | blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift); | |
137 | iaddr.len = 1; | |
138 | ||
139 | return iaddr; | |
140 | } | |
141 | ||
142 | static inline unsigned int | |
143 | befs_iaddrs_per_block(struct super_block *sb) | |
144 | { | |
12ecb38d | 145 | return BEFS_SB(sb)->block_size / sizeof(befs_disk_inode_addr); |
1da177e4 LT |
146 | } |
147 | ||
af10b008 AV |
148 | #include "endian.h" |
149 | ||
1da177e4 | 150 | #endif /* _LINUX_BEFS_H */ |