xref: /kernel/linux/linux-6.6/fs/bfs/bfs.h (revision 62306a36)
162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *	fs/bfs/bfs.h
462306a36Sopenharmony_ci *	Copyright (C) 1999-2018 Tigran Aivazian <aivazian.tigran@gmail.com>
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#ifndef _FS_BFS_BFS_H
762306a36Sopenharmony_ci#define _FS_BFS_BFS_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/bfs_fs.h>
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci/* In theory BFS supports up to 512 inodes, numbered from 2 (for /) up to 513 inclusive.
1262306a36Sopenharmony_ci   In actual fact, attempting to create the 512th inode (i.e. inode No. 513 or file No. 511)
1362306a36Sopenharmony_ci   will fail with ENOSPC in bfs_add_entry(): the root directory cannot contain so many entries, counting '..'.
1462306a36Sopenharmony_ci   So, mkfs.bfs(8) should really limit its -N option to 511 and not 512. For now, we just print a warning
1562306a36Sopenharmony_ci   if a filesystem is mounted with such "impossible to fill up" number of inodes */
1662306a36Sopenharmony_ci#define BFS_MAX_LASTI	513
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/*
1962306a36Sopenharmony_ci * BFS file system in-core superblock info
2062306a36Sopenharmony_ci */
2162306a36Sopenharmony_cistruct bfs_sb_info {
2262306a36Sopenharmony_ci	unsigned long si_blocks;
2362306a36Sopenharmony_ci	unsigned long si_freeb;
2462306a36Sopenharmony_ci	unsigned long si_freei;
2562306a36Sopenharmony_ci	unsigned long si_lf_eblk;
2662306a36Sopenharmony_ci	unsigned long si_lasti;
2762306a36Sopenharmony_ci	DECLARE_BITMAP(si_imap, BFS_MAX_LASTI+1);
2862306a36Sopenharmony_ci	struct mutex bfs_lock;
2962306a36Sopenharmony_ci};
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci/*
3262306a36Sopenharmony_ci * BFS file system in-core inode info
3362306a36Sopenharmony_ci */
3462306a36Sopenharmony_cistruct bfs_inode_info {
3562306a36Sopenharmony_ci	unsigned long i_dsk_ino; /* inode number from the disk, can be 0 */
3662306a36Sopenharmony_ci	unsigned long i_sblock;
3762306a36Sopenharmony_ci	unsigned long i_eblock;
3862306a36Sopenharmony_ci	struct inode vfs_inode;
3962306a36Sopenharmony_ci};
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_cistatic inline struct bfs_sb_info *BFS_SB(struct super_block *sb)
4262306a36Sopenharmony_ci{
4362306a36Sopenharmony_ci	return sb->s_fs_info;
4462306a36Sopenharmony_ci}
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_cistatic inline struct bfs_inode_info *BFS_I(struct inode *inode)
4762306a36Sopenharmony_ci{
4862306a36Sopenharmony_ci	return container_of(inode, struct bfs_inode_info, vfs_inode);
4962306a36Sopenharmony_ci}
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#define printf(format, args...) \
5362306a36Sopenharmony_ci	printk(KERN_ERR "BFS-fs: %s(): " format, __func__, ## args)
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci/* inode.c */
5662306a36Sopenharmony_ciextern struct inode *bfs_iget(struct super_block *sb, unsigned long ino);
5762306a36Sopenharmony_ciextern void bfs_dump_imap(const char *, struct super_block *);
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci/* file.c */
6062306a36Sopenharmony_ciextern const struct inode_operations bfs_file_inops;
6162306a36Sopenharmony_ciextern const struct file_operations bfs_file_operations;
6262306a36Sopenharmony_ciextern const struct address_space_operations bfs_aops;
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci/* dir.c */
6562306a36Sopenharmony_ciextern const struct inode_operations bfs_dir_inops;
6662306a36Sopenharmony_ciextern const struct file_operations bfs_dir_operations;
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci#endif /* _FS_BFS_BFS_H */
69