162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _OMFS_H
362306a36Sopenharmony_ci#define _OMFS_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/module.h>
662306a36Sopenharmony_ci#include <linux/fs.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include "omfs_fs.h"
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/* In-memory structures */
1162306a36Sopenharmony_cistruct omfs_sb_info {
1262306a36Sopenharmony_ci	u64 s_num_blocks;
1362306a36Sopenharmony_ci	u64 s_bitmap_ino;
1462306a36Sopenharmony_ci	u64 s_root_ino;
1562306a36Sopenharmony_ci	u32 s_blocksize;
1662306a36Sopenharmony_ci	u32 s_mirrors;
1762306a36Sopenharmony_ci	u32 s_sys_blocksize;
1862306a36Sopenharmony_ci	u32 s_clustersize;
1962306a36Sopenharmony_ci	int s_block_shift;
2062306a36Sopenharmony_ci	unsigned long **s_imap;
2162306a36Sopenharmony_ci	int s_imap_size;
2262306a36Sopenharmony_ci	struct mutex s_bitmap_lock;
2362306a36Sopenharmony_ci	kuid_t s_uid;
2462306a36Sopenharmony_ci	kgid_t s_gid;
2562306a36Sopenharmony_ci	int s_dmask;
2662306a36Sopenharmony_ci	int s_fmask;
2762306a36Sopenharmony_ci};
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/* convert a cluster number to a scaled block number */
3062306a36Sopenharmony_cistatic inline sector_t clus_to_blk(struct omfs_sb_info *sbi, sector_t block)
3162306a36Sopenharmony_ci{
3262306a36Sopenharmony_ci	return block << sbi->s_block_shift;
3362306a36Sopenharmony_ci}
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_cistatic inline struct omfs_sb_info *OMFS_SB(struct super_block *sb)
3662306a36Sopenharmony_ci{
3762306a36Sopenharmony_ci	return sb->s_fs_info;
3862306a36Sopenharmony_ci}
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci/* bitmap.c */
4162306a36Sopenharmony_ciextern unsigned long omfs_count_free(struct super_block *sb);
4262306a36Sopenharmony_ciextern int omfs_allocate_block(struct super_block *sb, u64 block);
4362306a36Sopenharmony_ciextern int omfs_allocate_range(struct super_block *sb, int min_request,
4462306a36Sopenharmony_ci			int max_request, u64 *return_block, int *return_size);
4562306a36Sopenharmony_ciextern int omfs_clear_range(struct super_block *sb, u64 block, int count);
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci/* dir.c */
4862306a36Sopenharmony_ciextern const struct file_operations omfs_dir_operations;
4962306a36Sopenharmony_ciextern const struct inode_operations omfs_dir_inops;
5062306a36Sopenharmony_ciextern int omfs_make_empty(struct inode *inode, struct super_block *sb);
5162306a36Sopenharmony_ciextern int omfs_is_bad(struct omfs_sb_info *sbi, struct omfs_header *header,
5262306a36Sopenharmony_ci			u64 fsblock);
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci/* file.c */
5562306a36Sopenharmony_ciextern const struct file_operations omfs_file_operations;
5662306a36Sopenharmony_ciextern const struct inode_operations omfs_file_inops;
5762306a36Sopenharmony_ciextern const struct address_space_operations omfs_aops;
5862306a36Sopenharmony_ciextern void omfs_make_empty_table(struct buffer_head *bh, int offset);
5962306a36Sopenharmony_ciextern int omfs_shrink_inode(struct inode *inode);
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci/* inode.c */
6262306a36Sopenharmony_ciextern struct buffer_head *omfs_bread(struct super_block *sb, sector_t block);
6362306a36Sopenharmony_ciextern struct inode *omfs_iget(struct super_block *sb, ino_t inode);
6462306a36Sopenharmony_ciextern struct inode *omfs_new_inode(struct inode *dir, umode_t mode);
6562306a36Sopenharmony_ciextern int omfs_reserve_block(struct super_block *sb, sector_t block);
6662306a36Sopenharmony_ciextern int omfs_find_empty_block(struct super_block *sb, int mode, ino_t *ino);
6762306a36Sopenharmony_ciextern int omfs_sync_inode(struct inode *inode);
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci#endif
70