Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | typedef u64 befs_blocknr_t; |
| 18 | /* |
| 19 | * BeFS in memory structures |
| 20 | */ |
| 21 | |
Fabian Frederick | 09ad0ea | 2015-04-16 12:46:17 -0700 | [diff] [blame] | 22 | struct befs_mount_options { |
Eric W. Biederman | 31aba05 | 2012-02-10 10:51:24 -0800 | [diff] [blame] | 23 | kgid_t gid; |
| 24 | kuid_t uid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | int use_gid; |
| 26 | int use_uid; |
| 27 | int debug; |
| 28 | char *iocharset; |
Fabian Frederick | 09ad0ea | 2015-04-16 12:46:17 -0700 | [diff] [blame] | 29 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Fabian Frederick | 038428f | 2015-04-16 12:46:20 -0700 | [diff] [blame] | 31 | struct befs_sb_info { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Salah Triki | 6ea4558 | 2016-08-09 14:46:04 +0100 | [diff] [blame] | 46 | /* State of the superblock */ |
| 47 | u32 flags; |
| 48 | |
Salah Triki | 2ac636b | 2016-08-09 14:46:05 +0100 | [diff] [blame^] | 49 | /* Journal log entry */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Fabian Frederick | 09ad0ea | 2015-04-16 12:46:17 -0700 | [diff] [blame] | 58 | struct befs_mount_options mount_opts; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | struct nls_table *nls; |
Fabian Frederick | 038428f | 2015-04-16 12:46:20 -0700 | [diff] [blame] | 60 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
Fabian Frederick | f8ccad2 | 2015-04-16 12:46:23 -0700 | [diff] [blame] | 62 | struct befs_inode_info { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | u32 i_flags; |
| 64 | u32 i_type; |
| 65 | |
| 66 | befs_inode_addr i_inode_num; |
| 67 | befs_inode_addr i_parent; |
| 68 | befs_inode_addr i_attribute; |
| 69 | |
| 70 | union { |
| 71 | befs_data_stream ds; |
| 72 | char symlink[BEFS_SYMLINK_LEN]; |
| 73 | } i_data; |
| 74 | |
| 75 | struct inode vfs_inode; |
Fabian Frederick | f8ccad2 | 2015-04-16 12:46:23 -0700 | [diff] [blame] | 76 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
| 78 | enum befs_err { |
| 79 | BEFS_OK, |
| 80 | BEFS_ERR, |
| 81 | BEFS_BAD_INODE, |
| 82 | BEFS_BT_END, |
| 83 | BEFS_BT_EMPTY, |
| 84 | BEFS_BT_MATCH, |
Luis de Bethencourt | 672a851 | 2016-08-08 15:21:20 +0100 | [diff] [blame] | 85 | BEFS_BT_OVERFLOW, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | BEFS_BT_NOT_FOUND |
| 87 | }; |
| 88 | |
| 89 | |
| 90 | /****************************/ |
| 91 | /* debug.c */ |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 92 | __printf(2, 3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | void befs_error(const struct super_block *sb, const char *fmt, ...); |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 94 | __printf(2, 3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | void befs_warning(const struct super_block *sb, const char *fmt, ...); |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 96 | __printf(2, 3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | void befs_debug(const struct super_block *sb, const char *fmt, ...); |
| 98 | |
| 99 | void befs_dump_super_block(const struct super_block *sb, befs_super_block *); |
| 100 | void befs_dump_inode(const struct super_block *sb, befs_inode *); |
Al Viro | a9721f3 | 2005-12-24 14:28:55 -0500 | [diff] [blame] | 101 | void befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *); |
| 103 | /****************************/ |
| 104 | |
| 105 | |
| 106 | /* Gets a pointer to the private portion of the super_block |
| 107 | * structure from the public part |
| 108 | */ |
Fabian Frederick | 038428f | 2015-04-16 12:46:20 -0700 | [diff] [blame] | 109 | static inline struct befs_sb_info * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | BEFS_SB(const struct super_block *super) |
| 111 | { |
Fabian Frederick | 038428f | 2015-04-16 12:46:20 -0700 | [diff] [blame] | 112 | return (struct befs_sb_info *) super->s_fs_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Fabian Frederick | f8ccad2 | 2015-04-16 12:46:23 -0700 | [diff] [blame] | 115 | static inline struct befs_inode_info * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | BEFS_I(const struct inode *inode) |
| 117 | { |
Rasmus Villemoes | db6172c | 2015-03-19 12:28:04 +0100 | [diff] [blame] | 118 | return container_of(inode, struct befs_inode_info, vfs_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | static inline befs_blocknr_t |
Al Viro | 22341d8 | 2016-05-10 14:24:06 -0400 | [diff] [blame] | 122 | iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | { |
Al Viro | a9721f3 | 2005-12-24 14:28:55 -0500 | [diff] [blame] | 143 | return BEFS_SB(sb)->block_size / sizeof (befs_disk_inode_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Al Viro | af10b00 | 2005-12-24 01:13:13 -0500 | [diff] [blame] | 146 | #include "endian.h" |
| 147 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | #endif /* _LINUX_BEFS_H */ |