162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _OMFS_FS_H 362306a36Sopenharmony_ci#define _OMFS_FS_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci/* OMFS On-disk structures */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#define OMFS_MAGIC 0xC2993D87 862306a36Sopenharmony_ci#define OMFS_IMAGIC 0xD2 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#define OMFS_DIR 'D' 1162306a36Sopenharmony_ci#define OMFS_FILE 'F' 1262306a36Sopenharmony_ci#define OMFS_INODE_NORMAL 'e' 1362306a36Sopenharmony_ci#define OMFS_INODE_CONTINUATION 'c' 1462306a36Sopenharmony_ci#define OMFS_INODE_SYSTEM 's' 1562306a36Sopenharmony_ci#define OMFS_NAMELEN 256 1662306a36Sopenharmony_ci#define OMFS_DIR_START 0x1b8 1762306a36Sopenharmony_ci#define OMFS_EXTENT_START 0x1d0 1862306a36Sopenharmony_ci#define OMFS_EXTENT_CONT 0x40 1962306a36Sopenharmony_ci#define OMFS_XOR_COUNT 19 2062306a36Sopenharmony_ci#define OMFS_MAX_BLOCK_SIZE 8192 2162306a36Sopenharmony_ci#define OMFS_MAX_CLUSTER_SIZE 8 2262306a36Sopenharmony_ci#define OMFS_MAX_BLOCKS (1ul << 31) 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_cistruct omfs_super_block { 2562306a36Sopenharmony_ci char s_fill1[256]; 2662306a36Sopenharmony_ci __be64 s_root_block; /* block number of omfs_root_block */ 2762306a36Sopenharmony_ci __be64 s_num_blocks; /* total number of FS blocks */ 2862306a36Sopenharmony_ci __be32 s_magic; /* OMFS_MAGIC */ 2962306a36Sopenharmony_ci __be32 s_blocksize; /* size of a block */ 3062306a36Sopenharmony_ci __be32 s_mirrors; /* # of mirrors of system blocks */ 3162306a36Sopenharmony_ci __be32 s_sys_blocksize; /* size of non-data blocks */ 3262306a36Sopenharmony_ci}; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_cistruct omfs_header { 3562306a36Sopenharmony_ci __be64 h_self; /* FS block where this is located */ 3662306a36Sopenharmony_ci __be32 h_body_size; /* size of useful data after header */ 3762306a36Sopenharmony_ci __be16 h_crc; /* crc-ccitt of body_size bytes */ 3862306a36Sopenharmony_ci char h_fill1[2]; 3962306a36Sopenharmony_ci u8 h_version; /* version, always 1 */ 4062306a36Sopenharmony_ci char h_type; /* OMFS_INODE_X */ 4162306a36Sopenharmony_ci u8 h_magic; /* OMFS_IMAGIC */ 4262306a36Sopenharmony_ci u8 h_check_xor; /* XOR of header bytes before this */ 4362306a36Sopenharmony_ci __be32 h_fill2; 4462306a36Sopenharmony_ci}; 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_cistruct omfs_root_block { 4762306a36Sopenharmony_ci struct omfs_header r_head; /* header */ 4862306a36Sopenharmony_ci __be64 r_fill1; 4962306a36Sopenharmony_ci __be64 r_num_blocks; /* total number of FS blocks */ 5062306a36Sopenharmony_ci __be64 r_root_dir; /* block # of root directory */ 5162306a36Sopenharmony_ci __be64 r_bitmap; /* block # of free space bitmap */ 5262306a36Sopenharmony_ci __be32 r_blocksize; /* size of a block */ 5362306a36Sopenharmony_ci __be32 r_clustersize; /* size allocated for data blocks */ 5462306a36Sopenharmony_ci __be64 r_mirrors; /* # of mirrors of system blocks */ 5562306a36Sopenharmony_ci char r_name[OMFS_NAMELEN]; /* partition label */ 5662306a36Sopenharmony_ci}; 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_cistruct omfs_inode { 5962306a36Sopenharmony_ci struct omfs_header i_head; /* header */ 6062306a36Sopenharmony_ci __be64 i_parent; /* parent containing this inode */ 6162306a36Sopenharmony_ci __be64 i_sibling; /* next inode in hash bucket */ 6262306a36Sopenharmony_ci __be64 i_ctime; /* ctime, in milliseconds */ 6362306a36Sopenharmony_ci char i_fill1[35]; 6462306a36Sopenharmony_ci char i_type; /* OMFS_[DIR,FILE] */ 6562306a36Sopenharmony_ci __be32 i_fill2; 6662306a36Sopenharmony_ci char i_fill3[64]; 6762306a36Sopenharmony_ci char i_name[OMFS_NAMELEN]; /* filename */ 6862306a36Sopenharmony_ci __be64 i_size; /* size of file, in bytes */ 6962306a36Sopenharmony_ci}; 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_cistruct omfs_extent_entry { 7262306a36Sopenharmony_ci __be64 e_cluster; /* start location of a set of blocks */ 7362306a36Sopenharmony_ci __be64 e_blocks; /* number of blocks after e_cluster */ 7462306a36Sopenharmony_ci}; 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_cistruct omfs_extent { 7762306a36Sopenharmony_ci __be64 e_next; /* next extent table location */ 7862306a36Sopenharmony_ci __be32 e_extent_count; /* total # extents in this table */ 7962306a36Sopenharmony_ci __be32 e_fill; 8062306a36Sopenharmony_ci struct omfs_extent_entry e_entry[]; /* start of extent entries */ 8162306a36Sopenharmony_ci}; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci#endif 84