Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * fs/befs/befs_fs_types.h
0004  *
0005  * Copyright (C) 2001 Will Dyson (will@cs.earlham.edu)
0006  *
0007  *
0008  *
0009  * from linux/include/linux/befs_fs.h
0010  *
0011  * Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
0012  *
0013  */
0014 
0015 #ifndef _LINUX_BEFS_FS_TYPES
0016 #define _LINUX_BEFS_FS_TYPES
0017 
0018 #ifdef __KERNEL__
0019 #include <linux/types.h>
0020 #endif /*__KERNEL__*/
0021 
0022 #define PACKED __attribute__ ((__packed__))
0023 
0024 /*
0025  * Max name lengths of BFS
0026  */
0027 
0028 #define BEFS_NAME_LEN 255
0029 
0030 #define BEFS_SYMLINK_LEN 144
0031 #define BEFS_NUM_DIRECT_BLOCKS 12
0032 #define B_OS_NAME_LENGTH 32
0033 
0034 /* The datastream blocks mapped by the double-indirect
0035  * block are always 4 fs blocks long.
0036  * This eliminates the need for linear searches among
0037  * the potentially huge number of indirect blocks
0038  *
0039  * Err. Should that be 4 fs blocks or 4k???
0040  * It matters on large blocksize volumes
0041  */
0042 #define BEFS_DBLINDIR_BRUN_LEN 4
0043 
0044 /*
0045  * Flags of superblock
0046  */
0047 
0048 enum super_flags {
0049     BEFS_BYTESEX_BE,
0050     BEFS_BYTESEX_LE,
0051     BEFS_CLEAN = 0x434c454e,
0052     BEFS_DIRTY = 0x44495254,
0053     BEFS_SUPER_MAGIC1 = 0x42465331, /* BFS1 */
0054     BEFS_SUPER_MAGIC2 = 0xdd121031,
0055     BEFS_SUPER_MAGIC3 = 0x15b6830e,
0056 };
0057 
0058 #define BEFS_BYTEORDER_NATIVE 0x42494745
0059 #define BEFS_BYTEORDER_NATIVE_LE ((__force fs32)cpu_to_le32(BEFS_BYTEORDER_NATIVE))
0060 #define BEFS_BYTEORDER_NATIVE_BE ((__force fs32)cpu_to_be32(BEFS_BYTEORDER_NATIVE))
0061 
0062 #define BEFS_SUPER_MAGIC BEFS_SUPER_MAGIC1
0063 #define BEFS_SUPER_MAGIC1_LE ((__force fs32)cpu_to_le32(BEFS_SUPER_MAGIC1))
0064 #define BEFS_SUPER_MAGIC1_BE ((__force fs32)cpu_to_be32(BEFS_SUPER_MAGIC1))
0065 
0066 /*
0067  * Flags of inode
0068  */
0069 
0070 #define BEFS_INODE_MAGIC1 0x3bbe0ad9
0071 
0072 enum inode_flags {
0073     BEFS_INODE_IN_USE = 0x00000001,
0074     BEFS_ATTR_INODE = 0x00000004,
0075     BEFS_INODE_LOGGED = 0x00000008,
0076     BEFS_INODE_DELETED = 0x00000010,
0077     BEFS_LONG_SYMLINK = 0x00000040,
0078     BEFS_PERMANENT_FLAG = 0x0000ffff,
0079     BEFS_INODE_NO_CREATE = 0x00010000,
0080     BEFS_INODE_WAS_WRITTEN = 0x00020000,
0081     BEFS_NO_TRANSACTION = 0x00040000,
0082 };
0083 /*
0084  * On-Disk datastructures of BeFS
0085  */
0086 
0087 typedef u64 __bitwise fs64;
0088 typedef u32 __bitwise fs32;
0089 typedef u16 __bitwise fs16;
0090 
0091 typedef u64 befs_off_t;
0092 typedef fs64 befs_time_t;
0093 
0094 /* Block runs */
0095 typedef struct {
0096     fs32 allocation_group;
0097     fs16 start;
0098     fs16 len;
0099 } PACKED befs_disk_block_run;
0100 
0101 typedef struct {
0102     u32 allocation_group;
0103     u16 start;
0104     u16 len;
0105 } PACKED befs_block_run;
0106 
0107 typedef befs_disk_block_run befs_disk_inode_addr;
0108 typedef befs_block_run befs_inode_addr;
0109 
0110 /*
0111  * The Superblock Structure
0112  */
0113 typedef struct {
0114     char name[B_OS_NAME_LENGTH];
0115     fs32 magic1;
0116     fs32 fs_byte_order;
0117 
0118     fs32 block_size;
0119     fs32 block_shift;
0120 
0121     fs64 num_blocks;
0122     fs64 used_blocks;
0123 
0124     fs32 inode_size;
0125 
0126     fs32 magic2;
0127     fs32 blocks_per_ag;
0128     fs32 ag_shift;
0129     fs32 num_ags;
0130 
0131     fs32 flags;
0132 
0133     befs_disk_block_run log_blocks;
0134     fs64 log_start;
0135     fs64 log_end;
0136 
0137     fs32 magic3;
0138     befs_disk_inode_addr root_dir;
0139     befs_disk_inode_addr indices;
0140 
0141 } PACKED befs_super_block;
0142 
0143 /*
0144  * Note: the indirect and dbl_indir block_runs may
0145  * be longer than one block!
0146  */
0147 typedef struct {
0148     befs_disk_block_run direct[BEFS_NUM_DIRECT_BLOCKS];
0149     fs64 max_direct_range;
0150     befs_disk_block_run indirect;
0151     fs64 max_indirect_range;
0152     befs_disk_block_run double_indirect;
0153     fs64 max_double_indirect_range;
0154     fs64 size;
0155 } PACKED befs_disk_data_stream;
0156 
0157 typedef struct {
0158     befs_block_run direct[BEFS_NUM_DIRECT_BLOCKS];
0159     befs_off_t max_direct_range;
0160     befs_block_run indirect;
0161     befs_off_t max_indirect_range;
0162     befs_block_run double_indirect;
0163     befs_off_t max_double_indirect_range;
0164     befs_off_t size;
0165 } PACKED befs_data_stream;
0166 
0167 /* Attribute */
0168 typedef struct {
0169     fs32 type;
0170     fs16 name_size;
0171     fs16 data_size;
0172     char name[1];
0173 } PACKED befs_small_data;
0174 
0175 /* Inode structure */
0176 typedef struct {
0177     fs32 magic1;
0178     befs_disk_inode_addr inode_num;
0179     fs32 uid;
0180     fs32 gid;
0181     fs32 mode;
0182     fs32 flags;
0183     befs_time_t create_time;
0184     befs_time_t last_modified_time;
0185     befs_disk_inode_addr parent;
0186     befs_disk_inode_addr attributes;
0187     fs32 type;
0188 
0189     fs32 inode_size;
0190     fs32 etc;       /* not use */
0191 
0192     union {
0193         befs_disk_data_stream datastream;
0194         char symlink[BEFS_SYMLINK_LEN];
0195     } data;
0196 
0197     fs32 pad[4];        /* not use */
0198     befs_small_data small_data[1];
0199 } PACKED befs_inode;
0200 
0201 /*
0202  * B+tree superblock
0203  */
0204 
0205 #define BEFS_BTREE_MAGIC 0x69f6c2e8
0206 
0207 enum btree_types {
0208     BTREE_STRING_TYPE = 0,
0209     BTREE_INT32_TYPE = 1,
0210     BTREE_UINT32_TYPE = 2,
0211     BTREE_INT64_TYPE = 3,
0212     BTREE_UINT64_TYPE = 4,
0213     BTREE_FLOAT_TYPE = 5,
0214     BTREE_DOUBLE_TYPE = 6
0215 };
0216 
0217 typedef struct {
0218     fs32 magic;
0219     fs32 node_size;
0220     fs32 max_depth;
0221     fs32 data_type;
0222     fs64 root_node_ptr;
0223     fs64 free_node_ptr;
0224     fs64 max_size;
0225 } PACKED befs_disk_btree_super;
0226 
0227 typedef struct {
0228     u32 magic;
0229     u32 node_size;
0230     u32 max_depth;
0231     u32 data_type;
0232     befs_off_t root_node_ptr;
0233     befs_off_t free_node_ptr;
0234     befs_off_t max_size;
0235 } PACKED befs_btree_super;
0236 
0237 /*
0238  * Header structure of each btree node
0239  */
0240 typedef struct {
0241     fs64 left;
0242     fs64 right;
0243     fs64 overflow;
0244     fs16 all_key_count;
0245     fs16 all_key_length;
0246 } PACKED befs_btree_nodehead;
0247 
0248 typedef struct {
0249     befs_off_t left;
0250     befs_off_t right;
0251     befs_off_t overflow;
0252     u16 all_key_count;
0253     u16 all_key_length;
0254 } PACKED befs_host_btree_nodehead;
0255 
0256 #endif              /* _LINUX_BEFS_FS_TYPES */