18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _OMFS_FS_H
38c2ecf20Sopenharmony_ci#define _OMFS_FS_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/* OMFS On-disk structures */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#define OMFS_MAGIC 0xC2993D87
88c2ecf20Sopenharmony_ci#define OMFS_IMAGIC 0xD2
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define OMFS_DIR 'D'
118c2ecf20Sopenharmony_ci#define OMFS_FILE 'F'
128c2ecf20Sopenharmony_ci#define OMFS_INODE_NORMAL 'e'
138c2ecf20Sopenharmony_ci#define OMFS_INODE_CONTINUATION 'c'
148c2ecf20Sopenharmony_ci#define OMFS_INODE_SYSTEM 's'
158c2ecf20Sopenharmony_ci#define OMFS_NAMELEN 256
168c2ecf20Sopenharmony_ci#define OMFS_DIR_START 0x1b8
178c2ecf20Sopenharmony_ci#define OMFS_EXTENT_START 0x1d0
188c2ecf20Sopenharmony_ci#define OMFS_EXTENT_CONT 0x40
198c2ecf20Sopenharmony_ci#define OMFS_XOR_COUNT 19
208c2ecf20Sopenharmony_ci#define OMFS_MAX_BLOCK_SIZE 8192
218c2ecf20Sopenharmony_ci#define OMFS_MAX_CLUSTER_SIZE 8
228c2ecf20Sopenharmony_ci#define OMFS_MAX_BLOCKS (1ul << 31)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistruct omfs_super_block {
258c2ecf20Sopenharmony_ci	char s_fill1[256];
268c2ecf20Sopenharmony_ci	__be64 s_root_block;		/* block number of omfs_root_block */
278c2ecf20Sopenharmony_ci	__be64 s_num_blocks;		/* total number of FS blocks */
288c2ecf20Sopenharmony_ci	__be32 s_magic;			/* OMFS_MAGIC */
298c2ecf20Sopenharmony_ci	__be32 s_blocksize;		/* size of a block */
308c2ecf20Sopenharmony_ci	__be32 s_mirrors;		/* # of mirrors of system blocks */
318c2ecf20Sopenharmony_ci	__be32 s_sys_blocksize;		/* size of non-data blocks */
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistruct omfs_header {
358c2ecf20Sopenharmony_ci	__be64 h_self;			/* FS block where this is located */
368c2ecf20Sopenharmony_ci	__be32 h_body_size;		/* size of useful data after header */
378c2ecf20Sopenharmony_ci	__be16 h_crc;			/* crc-ccitt of body_size bytes */
388c2ecf20Sopenharmony_ci	char h_fill1[2];
398c2ecf20Sopenharmony_ci	u8 h_version;			/* version, always 1 */
408c2ecf20Sopenharmony_ci	char h_type;			/* OMFS_INODE_X */
418c2ecf20Sopenharmony_ci	u8 h_magic;			/* OMFS_IMAGIC */
428c2ecf20Sopenharmony_ci	u8 h_check_xor;			/* XOR of header bytes before this */
438c2ecf20Sopenharmony_ci	__be32 h_fill2;
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_cistruct omfs_root_block {
478c2ecf20Sopenharmony_ci	struct omfs_header r_head;	/* header */
488c2ecf20Sopenharmony_ci	__be64 r_fill1;
498c2ecf20Sopenharmony_ci	__be64 r_num_blocks;		/* total number of FS blocks */
508c2ecf20Sopenharmony_ci	__be64 r_root_dir;		/* block # of root directory */
518c2ecf20Sopenharmony_ci	__be64 r_bitmap;		/* block # of free space bitmap */
528c2ecf20Sopenharmony_ci	__be32 r_blocksize;		/* size of a block */
538c2ecf20Sopenharmony_ci	__be32 r_clustersize;		/* size allocated for data blocks */
548c2ecf20Sopenharmony_ci	__be64 r_mirrors;		/* # of mirrors of system blocks */
558c2ecf20Sopenharmony_ci	char r_name[OMFS_NAMELEN];	/* partition label */
568c2ecf20Sopenharmony_ci};
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cistruct omfs_inode {
598c2ecf20Sopenharmony_ci	struct omfs_header i_head;	/* header */
608c2ecf20Sopenharmony_ci	__be64 i_parent;		/* parent containing this inode */
618c2ecf20Sopenharmony_ci	__be64 i_sibling;		/* next inode in hash bucket */
628c2ecf20Sopenharmony_ci	__be64 i_ctime;			/* ctime, in milliseconds */
638c2ecf20Sopenharmony_ci	char i_fill1[35];
648c2ecf20Sopenharmony_ci	char i_type;			/* OMFS_[DIR,FILE] */
658c2ecf20Sopenharmony_ci	__be32 i_fill2;
668c2ecf20Sopenharmony_ci	char i_fill3[64];
678c2ecf20Sopenharmony_ci	char i_name[OMFS_NAMELEN];	/* filename */
688c2ecf20Sopenharmony_ci	__be64 i_size;			/* size of file, in bytes */
698c2ecf20Sopenharmony_ci};
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistruct omfs_extent_entry {
728c2ecf20Sopenharmony_ci	__be64 e_cluster;		/* start location of a set of blocks */
738c2ecf20Sopenharmony_ci	__be64 e_blocks;		/* number of blocks after e_cluster */
748c2ecf20Sopenharmony_ci};
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cistruct omfs_extent {
778c2ecf20Sopenharmony_ci	__be64 e_next;			/* next extent table location */
788c2ecf20Sopenharmony_ci	__be32 e_extent_count;		/* total # extents in this table */
798c2ecf20Sopenharmony_ci	__be32 e_fill;
808c2ecf20Sopenharmony_ci	struct omfs_extent_entry e_entry;	/* start of extent entries */
818c2ecf20Sopenharmony_ci};
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#endif
84