b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100 1) /* SPDX-License-Identifier: GPL-2.0 */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 2) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 3) * befs.h
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 4) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 5) * Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 6) * Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 7) */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 8)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 9) #ifndef _LINUX_BEFS_H
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 10) #define _LINUX_BEFS_H
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 11)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 12) #include "befs_fs_types.h"
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 13)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 14) /* used in debug.c */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 15) #define BEFS_VERSION "0.9.3"
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 16)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 17)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 18) typedef u64 befs_blocknr_t;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 19) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 20) * BeFS in memory structures
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 21) */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 22)
09ad0eae5ed0f (Fabian Frederick 2015-04-16 12:46:17 -0700 23) struct befs_mount_options {
31aba059bb952 (Eric W. Biederman 2012-02-10 10:51:24 -0800 24) kgid_t gid;
31aba059bb952 (Eric W. Biederman 2012-02-10 10:51:24 -0800 25) kuid_t uid;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 26) int use_gid;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 27) int use_uid;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 28) int debug;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 29) char *iocharset;
09ad0eae5ed0f (Fabian Frederick 2015-04-16 12:46:17 -0700 30) };
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 31)
038428fcf7f05 (Fabian Frederick 2015-04-16 12:46:20 -0700 32) struct befs_sb_info {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 33) u32 magic1;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 34) u32 block_size;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 35) u32 block_shift;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 36) int byte_order;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 37) befs_off_t num_blocks;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 38) befs_off_t used_blocks;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 39) u32 inode_size;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 40) u32 magic2;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 41)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 42) /* Allocation group information */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 43) u32 blocks_per_ag;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 44) u32 ag_shift;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 45) u32 num_ags;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 46)
6ea4558f9b373 (Salah Triki 2016-08-09 14:46:04 +0100 47) /* State of the superblock */
6ea4558f9b373 (Salah Triki 2016-08-09 14:46:04 +0100 48) u32 flags;
6ea4558f9b373 (Salah Triki 2016-08-09 14:46:04 +0100 49)
2ac636b4d0470 (Salah Triki 2016-08-09 14:46:05 +0100 50) /* Journal log entry */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 51) befs_block_run log_blocks;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 52) befs_off_t log_start;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 53) befs_off_t log_end;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 54)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 55) befs_inode_addr root_dir;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 56) befs_inode_addr indices;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 57) u32 magic3;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 58)
09ad0eae5ed0f (Fabian Frederick 2015-04-16 12:46:17 -0700 59) struct befs_mount_options mount_opts;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 60) struct nls_table *nls;
038428fcf7f05 (Fabian Frederick 2015-04-16 12:46:20 -0700 61) };
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 62)
f8ccad2164d40 (Fabian Frederick 2015-04-16 12:46:23 -0700 63) struct befs_inode_info {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 64) u32 i_flags;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 65) u32 i_type;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 66)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 67) befs_inode_addr i_inode_num;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 68) befs_inode_addr i_parent;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 69) befs_inode_addr i_attribute;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 70)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 71) union {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 72) befs_data_stream ds;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 73) char symlink[BEFS_SYMLINK_LEN];
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 74) } i_data;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 75)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 76) struct inode vfs_inode;
f8ccad2164d40 (Fabian Frederick 2015-04-16 12:46:23 -0700 77) };
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 78)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 79) enum befs_err {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 80) BEFS_OK,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 81) BEFS_ERR,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 82) BEFS_BAD_INODE,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 83) BEFS_BT_END,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 84) BEFS_BT_EMPTY,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 85) BEFS_BT_MATCH,
672a8515ee7ce (Luis de Bethencourt 2016-08-08 15:21:20 +0100 86) BEFS_BT_OVERFLOW,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 87) BEFS_BT_NOT_FOUND
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 88) };
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 89)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 90)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 91) /****************************/
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 92) /* debug.c */
dac52fc1826a7 (Fabian Frederick 2014-04-03 14:50:23 -0700 93) __printf(2, 3)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 94) void befs_error(const struct super_block *sb, const char *fmt, ...);
dac52fc1826a7 (Fabian Frederick 2014-04-03 14:50:23 -0700 95) __printf(2, 3)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 96) void befs_warning(const struct super_block *sb, const char *fmt, ...);
dac52fc1826a7 (Fabian Frederick 2014-04-03 14:50:23 -0700 97) __printf(2, 3)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 98) void befs_debug(const struct super_block *sb, const char *fmt, ...);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 99)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 100) void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 101) void befs_dump_inode(const struct super_block *sb, befs_inode *);
a9721f3152bc2 (Al Viro 2005-12-24 14:28:55 -0500 102) void befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super *);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 103) void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 104) /****************************/
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 105)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 106)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 107) /* Gets a pointer to the private portion of the super_block
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 108) * structure from the public part
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 109) */
038428fcf7f05 (Fabian Frederick 2015-04-16 12:46:20 -0700 110) static inline struct befs_sb_info *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 111) BEFS_SB(const struct super_block *super)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 112) {
038428fcf7f05 (Fabian Frederick 2015-04-16 12:46:20 -0700 113) return (struct befs_sb_info *) super->s_fs_info;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 114) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 115)
f8ccad2164d40 (Fabian Frederick 2015-04-16 12:46:23 -0700 116) static inline struct befs_inode_info *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 117) BEFS_I(const struct inode *inode)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 118) {
db6172c411945 (Rasmus Villemoes 2015-03-19 12:28:04 +0100 119) return container_of(inode, struct befs_inode_info, vfs_inode);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 120) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 121)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 122) static inline befs_blocknr_t
22341d8f33084 (Al Viro 2016-05-10 14:24:06 -0400 123) iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 124) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 125) return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 126) iaddr->start);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 127) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 128)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 129) static inline befs_inode_addr
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 130) blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 131) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 132) befs_inode_addr iaddr;
12ecb38d03cff (Luis de Bethencourt 2016-08-14 18:31:38 +0100 133)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 134) iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 135) iaddr.start =
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 136) blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 137) iaddr.len = 1;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 138)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 139) return iaddr;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 140) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 141)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 142) static inline unsigned int
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 143) befs_iaddrs_per_block(struct super_block *sb)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 144) {
12ecb38d03cff (Luis de Bethencourt 2016-08-14 18:31:38 +0100 145) return BEFS_SB(sb)->block_size / sizeof(befs_disk_inode_addr);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 146) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 147)
af10b0084dff5 (Al Viro 2005-12-24 01:13:13 -0500 148) #include "endian.h"
af10b0084dff5 (Al Viro 2005-12-24 01:13:13 -0500 149)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 150) #endif /* _LINUX_BEFS_H */