xref: /OK3568_Linux_fs/kernel/fs/omfs/omfs.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _OMFS_H
3*4882a593Smuzhiyun #define _OMFS_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/module.h>
6*4882a593Smuzhiyun #include <linux/fs.h>
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #include "omfs_fs.h"
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun /* In-memory structures */
11*4882a593Smuzhiyun struct omfs_sb_info {
12*4882a593Smuzhiyun 	u64 s_num_blocks;
13*4882a593Smuzhiyun 	u64 s_bitmap_ino;
14*4882a593Smuzhiyun 	u64 s_root_ino;
15*4882a593Smuzhiyun 	u32 s_blocksize;
16*4882a593Smuzhiyun 	u32 s_mirrors;
17*4882a593Smuzhiyun 	u32 s_sys_blocksize;
18*4882a593Smuzhiyun 	u32 s_clustersize;
19*4882a593Smuzhiyun 	int s_block_shift;
20*4882a593Smuzhiyun 	unsigned long **s_imap;
21*4882a593Smuzhiyun 	int s_imap_size;
22*4882a593Smuzhiyun 	struct mutex s_bitmap_lock;
23*4882a593Smuzhiyun 	kuid_t s_uid;
24*4882a593Smuzhiyun 	kgid_t s_gid;
25*4882a593Smuzhiyun 	int s_dmask;
26*4882a593Smuzhiyun 	int s_fmask;
27*4882a593Smuzhiyun };
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun /* convert a cluster number to a scaled block number */
clus_to_blk(struct omfs_sb_info * sbi,sector_t block)30*4882a593Smuzhiyun static inline sector_t clus_to_blk(struct omfs_sb_info *sbi, sector_t block)
31*4882a593Smuzhiyun {
32*4882a593Smuzhiyun 	return block << sbi->s_block_shift;
33*4882a593Smuzhiyun }
34*4882a593Smuzhiyun 
OMFS_SB(struct super_block * sb)35*4882a593Smuzhiyun static inline struct omfs_sb_info *OMFS_SB(struct super_block *sb)
36*4882a593Smuzhiyun {
37*4882a593Smuzhiyun 	return sb->s_fs_info;
38*4882a593Smuzhiyun }
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun /* bitmap.c */
41*4882a593Smuzhiyun extern unsigned long omfs_count_free(struct super_block *sb);
42*4882a593Smuzhiyun extern int omfs_allocate_block(struct super_block *sb, u64 block);
43*4882a593Smuzhiyun extern int omfs_allocate_range(struct super_block *sb, int min_request,
44*4882a593Smuzhiyun 			int max_request, u64 *return_block, int *return_size);
45*4882a593Smuzhiyun extern int omfs_clear_range(struct super_block *sb, u64 block, int count);
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun /* dir.c */
48*4882a593Smuzhiyun extern const struct file_operations omfs_dir_operations;
49*4882a593Smuzhiyun extern const struct inode_operations omfs_dir_inops;
50*4882a593Smuzhiyun extern int omfs_make_empty(struct inode *inode, struct super_block *sb);
51*4882a593Smuzhiyun extern int omfs_is_bad(struct omfs_sb_info *sbi, struct omfs_header *header,
52*4882a593Smuzhiyun 			u64 fsblock);
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun /* file.c */
55*4882a593Smuzhiyun extern const struct file_operations omfs_file_operations;
56*4882a593Smuzhiyun extern const struct inode_operations omfs_file_inops;
57*4882a593Smuzhiyun extern const struct address_space_operations omfs_aops;
58*4882a593Smuzhiyun extern void omfs_make_empty_table(struct buffer_head *bh, int offset);
59*4882a593Smuzhiyun extern int omfs_shrink_inode(struct inode *inode);
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun /* inode.c */
62*4882a593Smuzhiyun extern struct buffer_head *omfs_bread(struct super_block *sb, sector_t block);
63*4882a593Smuzhiyun extern struct inode *omfs_iget(struct super_block *sb, ino_t inode);
64*4882a593Smuzhiyun extern struct inode *omfs_new_inode(struct inode *dir, umode_t mode);
65*4882a593Smuzhiyun extern int omfs_reserve_block(struct super_block *sb, sector_t block);
66*4882a593Smuzhiyun extern int omfs_find_empty_block(struct super_block *sb, int mode, ino_t *ino);
67*4882a593Smuzhiyun extern int omfs_sync_inode(struct inode *inode);
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun #endif
70