Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * befs.h
0004  *
0005  * Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
0006  * Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
0007  */
0008 
0009 #ifndef _LINUX_BEFS_H
0010 #define _LINUX_BEFS_H
0011 
0012 #include "befs_fs_types.h"
0013 
0014 /* used in debug.c */
0015 #define BEFS_VERSION "0.9.3"
0016 
0017 
0018 typedef u64 befs_blocknr_t;
0019 /*
0020  * BeFS in memory structures
0021  */
0022 
0023 struct befs_mount_options {
0024     kgid_t gid;
0025     kuid_t uid;
0026     int use_gid;
0027     int use_uid;
0028     int debug;
0029     char *iocharset;
0030 };
0031 
0032 struct befs_sb_info {
0033     u32 magic1;
0034     u32 block_size;
0035     u32 block_shift;
0036     int byte_order;
0037     befs_off_t num_blocks;
0038     befs_off_t used_blocks;
0039     u32 inode_size;
0040     u32 magic2;
0041 
0042     /* Allocation group information */
0043     u32 blocks_per_ag;
0044     u32 ag_shift;
0045     u32 num_ags;
0046 
0047     /* State of the superblock */
0048     u32 flags;
0049 
0050     /* Journal log entry */
0051     befs_block_run log_blocks;
0052     befs_off_t log_start;
0053     befs_off_t log_end;
0054 
0055     befs_inode_addr root_dir;
0056     befs_inode_addr indices;
0057     u32 magic3;
0058 
0059     struct befs_mount_options mount_opts;
0060     struct nls_table *nls;
0061 };
0062 
0063 struct befs_inode_info {
0064     u32 i_flags;
0065     u32 i_type;
0066 
0067     befs_inode_addr i_inode_num;
0068     befs_inode_addr i_parent;
0069     befs_inode_addr i_attribute;
0070 
0071     union {
0072         befs_data_stream ds;
0073         char symlink[BEFS_SYMLINK_LEN];
0074     } i_data;
0075 
0076     struct inode vfs_inode;
0077 };
0078 
0079 enum befs_err {
0080     BEFS_OK,
0081     BEFS_ERR,
0082     BEFS_BAD_INODE,
0083     BEFS_BT_END,
0084     BEFS_BT_EMPTY,
0085     BEFS_BT_MATCH,
0086     BEFS_BT_OVERFLOW,
0087     BEFS_BT_NOT_FOUND
0088 };
0089 
0090 
0091 /****************************/
0092 /* debug.c */
0093 __printf(2, 3)
0094 void befs_error(const struct super_block *sb, const char *fmt, ...);
0095 __printf(2, 3)
0096 void befs_warning(const struct super_block *sb, const char *fmt, ...);
0097 __printf(2, 3)
0098 void befs_debug(const struct super_block *sb, const char *fmt, ...);
0099 
0100 void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
0101 void befs_dump_inode(const struct super_block *sb, befs_inode *);
0102 void befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super *);
0103 void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
0104 /****************************/
0105 
0106 
0107 /* Gets a pointer to the private portion of the super_block
0108  * structure from the public part
0109  */
0110 static inline struct befs_sb_info *
0111 BEFS_SB(const struct super_block *super)
0112 {
0113     return (struct befs_sb_info *) super->s_fs_info;
0114 }
0115 
0116 static inline struct befs_inode_info *
0117 BEFS_I(const struct inode *inode)
0118 {
0119     return container_of(inode, struct befs_inode_info, vfs_inode);
0120 }
0121 
0122 static inline befs_blocknr_t
0123 iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr)
0124 {
0125     return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
0126         iaddr->start);
0127 }
0128 
0129 static inline befs_inode_addr
0130 blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
0131 {
0132     befs_inode_addr iaddr;
0133 
0134     iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
0135     iaddr.start =
0136         blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
0137     iaddr.len = 1;
0138 
0139     return iaddr;
0140 }
0141 
0142 static inline unsigned int
0143 befs_iaddrs_per_block(struct super_block *sb)
0144 {
0145     return BEFS_SB(sb)->block_size / sizeof(befs_disk_inode_addr);
0146 }
0147 
0148 #include "endian.h"
0149 
0150 #endif              /* _LINUX_BEFS_H */