18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _OMFS_H 38c2ecf20Sopenharmony_ci#define _OMFS_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/module.h> 68c2ecf20Sopenharmony_ci#include <linux/fs.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include "omfs_fs.h" 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* In-memory structures */ 118c2ecf20Sopenharmony_cistruct omfs_sb_info { 128c2ecf20Sopenharmony_ci u64 s_num_blocks; 138c2ecf20Sopenharmony_ci u64 s_bitmap_ino; 148c2ecf20Sopenharmony_ci u64 s_root_ino; 158c2ecf20Sopenharmony_ci u32 s_blocksize; 168c2ecf20Sopenharmony_ci u32 s_mirrors; 178c2ecf20Sopenharmony_ci u32 s_sys_blocksize; 188c2ecf20Sopenharmony_ci u32 s_clustersize; 198c2ecf20Sopenharmony_ci int s_block_shift; 208c2ecf20Sopenharmony_ci unsigned long **s_imap; 218c2ecf20Sopenharmony_ci int s_imap_size; 228c2ecf20Sopenharmony_ci struct mutex s_bitmap_lock; 238c2ecf20Sopenharmony_ci kuid_t s_uid; 248c2ecf20Sopenharmony_ci kgid_t s_gid; 258c2ecf20Sopenharmony_ci int s_dmask; 268c2ecf20Sopenharmony_ci int s_fmask; 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* convert a cluster number to a scaled block number */ 308c2ecf20Sopenharmony_cistatic inline sector_t clus_to_blk(struct omfs_sb_info *sbi, sector_t block) 318c2ecf20Sopenharmony_ci{ 328c2ecf20Sopenharmony_ci return block << sbi->s_block_shift; 338c2ecf20Sopenharmony_ci} 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistatic inline struct omfs_sb_info *OMFS_SB(struct super_block *sb) 368c2ecf20Sopenharmony_ci{ 378c2ecf20Sopenharmony_ci return sb->s_fs_info; 388c2ecf20Sopenharmony_ci} 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* bitmap.c */ 418c2ecf20Sopenharmony_ciextern unsigned long omfs_count_free(struct super_block *sb); 428c2ecf20Sopenharmony_ciextern int omfs_allocate_block(struct super_block *sb, u64 block); 438c2ecf20Sopenharmony_ciextern int omfs_allocate_range(struct super_block *sb, int min_request, 448c2ecf20Sopenharmony_ci int max_request, u64 *return_block, int *return_size); 458c2ecf20Sopenharmony_ciextern int omfs_clear_range(struct super_block *sb, u64 block, int count); 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* dir.c */ 488c2ecf20Sopenharmony_ciextern const struct file_operations omfs_dir_operations; 498c2ecf20Sopenharmony_ciextern const struct inode_operations omfs_dir_inops; 508c2ecf20Sopenharmony_ciextern int omfs_make_empty(struct inode *inode, struct super_block *sb); 518c2ecf20Sopenharmony_ciextern int omfs_is_bad(struct omfs_sb_info *sbi, struct omfs_header *header, 528c2ecf20Sopenharmony_ci u64 fsblock); 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* file.c */ 558c2ecf20Sopenharmony_ciextern const struct file_operations omfs_file_operations; 568c2ecf20Sopenharmony_ciextern const struct inode_operations omfs_file_inops; 578c2ecf20Sopenharmony_ciextern const struct address_space_operations omfs_aops; 588c2ecf20Sopenharmony_ciextern void omfs_make_empty_table(struct buffer_head *bh, int offset); 598c2ecf20Sopenharmony_ciextern int omfs_shrink_inode(struct inode *inode); 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* inode.c */ 628c2ecf20Sopenharmony_ciextern struct buffer_head *omfs_bread(struct super_block *sb, sector_t block); 638c2ecf20Sopenharmony_ciextern struct inode *omfs_iget(struct super_block *sb, ino_t inode); 648c2ecf20Sopenharmony_ciextern struct inode *omfs_new_inode(struct inode *dir, umode_t mode); 658c2ecf20Sopenharmony_ciextern int omfs_reserve_block(struct super_block *sb, sector_t block); 668c2ecf20Sopenharmony_ciextern int omfs_find_empty_block(struct super_block *sb, int mode, ino_t *ino); 678c2ecf20Sopenharmony_ciextern int omfs_sync_inode(struct inode *inode); 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#endif 70