blob: 35d19e8731e35b8aabfe9cdaaf32d11b9b17b326 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Fabian Frederick09ad0ea2015-04-16 12:46:17 -070022struct befs_mount_options {
Eric W. Biederman31aba052012-02-10 10:51:24 -080023 kgid_t gid;
24 kuid_t uid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 int use_gid;
26 int use_uid;
27 int debug;
28 char *iocharset;
Fabian Frederick09ad0ea2015-04-16 12:46:17 -070029};
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Fabian Frederick038428f2015-04-16 12:46:20 -070031struct befs_sb_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 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
Fabian Frederick09ad0ea2015-04-16 12:46:17 -070055 struct befs_mount_options mount_opts;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 struct nls_table *nls;
Fabian Frederick038428f2015-04-16 12:46:20 -070057};
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Fabian Frederickf8ccad22015-04-16 12:46:23 -070059struct befs_inode_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 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;
Fabian Frederickf8ccad22015-04-16 12:46:23 -070073};
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
75enum befs_err {
76 BEFS_OK,
77 BEFS_ERR,
78 BEFS_BAD_INODE,
79 BEFS_BT_END,
80 BEFS_BT_EMPTY,
81 BEFS_BT_MATCH,
82 BEFS_BT_PARMATCH,
83 BEFS_BT_NOT_FOUND
84};
85
86
87/****************************/
88/* debug.c */
Fabian Frederickdac52fc2014-04-03 14:50:23 -070089__printf(2, 3)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090void befs_error(const struct super_block *sb, const char *fmt, ...);
Fabian Frederickdac52fc2014-04-03 14:50:23 -070091__printf(2, 3)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092void befs_warning(const struct super_block *sb, const char *fmt, ...);
Fabian Frederickdac52fc2014-04-03 14:50:23 -070093__printf(2, 3)
Linus Torvalds1da177e2005-04-16 15:20:36 -070094void befs_debug(const struct super_block *sb, const char *fmt, ...);
95
96void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
97void befs_dump_inode(const struct super_block *sb, befs_inode *);
Al Viroa9721f32005-12-24 14:28:55 -050098void befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
100/****************************/
101
102
103/* Gets a pointer to the private portion of the super_block
104 * structure from the public part
105 */
Fabian Frederick038428f2015-04-16 12:46:20 -0700106static inline struct befs_sb_info *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107BEFS_SB(const struct super_block *super)
108{
Fabian Frederick038428f2015-04-16 12:46:20 -0700109 return (struct befs_sb_info *) super->s_fs_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110}
111
Fabian Frederickf8ccad22015-04-16 12:46:23 -0700112static inline struct befs_inode_info *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113BEFS_I(const struct inode *inode)
114{
Rasmus Villemoesdb6172c2015-03-19 12:28:04 +0100115 return container_of(inode, struct befs_inode_info, vfs_inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116}
117
118static inline befs_blocknr_t
119iaddr2blockno(struct super_block *sb, befs_inode_addr * iaddr)
120{
121 return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
122 iaddr->start);
123}
124
125static inline befs_inode_addr
126blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
127{
128 befs_inode_addr iaddr;
129 iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
130 iaddr.start =
131 blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
132 iaddr.len = 1;
133
134 return iaddr;
135}
136
137static inline unsigned int
138befs_iaddrs_per_block(struct super_block *sb)
139{
Al Viroa9721f32005-12-24 14:28:55 -0500140 return BEFS_SB(sb)->block_size / sizeof (befs_disk_inode_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141}
142
143static inline int
144befs_iaddr_is_empty(befs_inode_addr * iaddr)
145{
146 return (!iaddr->allocation_group) && (!iaddr->start) && (!iaddr->len);
147}
148
149static inline size_t
150befs_brun_size(struct super_block *sb, befs_block_run run)
151{
152 return BEFS_SB(sb)->block_size * run.len;
153}
154
Al Viroaf10b002005-12-24 01:13:13 -0500155#include "endian.h"
156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#endif /* _LINUX_BEFS_H */