linux/fs/ext2/ext2.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 1992, 1993, 1994, 1995
 * Remy Card ([email protected])
 * Laboratoire MASI - Institut Blaise Pascal
 * Universite Pierre et Marie Curie (Paris VI)
 *
 *  from
 *
 *  linux/include/linux/minix_fs.h
 *
 *  Copyright (C) 1991, 1992  Linus Torvalds
 */
#include <linux/fs.h>
#include <linux/ext2_fs.h>
#include <linux/blockgroup_lock.h>
#include <linux/percpu_counter.h>
#include <linux/rbtree.h>
#include <linux/mm.h>
#include <linux/highmem.h>

/* XXX Here for now... not interested in restructing headers JUST now */

/* data type for block offset of block group */
ext2_grpblk_t;

/* data type for filesystem-wide blocks number */
ext2_fsblk_t;

#define E2FSBLK

struct ext2_reserve_window {};

struct ext2_reserve_window_node {};

struct ext2_block_alloc_info {};

#define rsv_start
#define rsv_end

struct mb_cache;

/*
 * second extended-fs super-block data in memory
 */
struct ext2_sb_info {};

static inline spinlock_t *
sb_bgl_lock(struct ext2_sb_info *sbi, unsigned int block_group)
{}

/*
 * Define EXT2FS_DEBUG to produce debug messages
 */
#undef EXT2FS_DEBUG

/*
 * Define EXT2_RESERVATION to reserve data blocks for expanding files
 */
#define EXT2_DEFAULT_RESERVE_BLOCKS
/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */
#define EXT2_MAX_RESERVE_BLOCKS
#define EXT2_RESERVE_WINDOW_NOT_ALLOCATED
/*
 * The second extended file system version
 */
#define EXT2FS_DATE
#define EXT2FS_VERSION

/*
 * Debug code
 */
#ifdef EXT2FS_DEBUG
#define ext2_debug
#else
#define ext2_debug(f, a...)
#endif

/*
 * Special inode numbers
 */
#define EXT2_BAD_INO
#define EXT2_ROOT_INO
#define EXT2_BOOT_LOADER_INO
#define EXT2_UNDEL_DIR_INO

/* First non-reserved inode for old ext2 filesystems */
#define EXT2_GOOD_OLD_FIRST_INO

static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb)
{}

/*
 * Macro-instructions used to manage several block sizes
 */
#define EXT2_MIN_BLOCK_SIZE
#define EXT2_MAX_BLOCK_SIZE
#define EXT2_MIN_BLOCK_LOG_SIZE
#define EXT2_MAX_BLOCK_LOG_SIZE
#define EXT2_BLOCK_SIZE(s)
#define EXT2_ADDR_PER_BLOCK(s)
#define EXT2_BLOCK_SIZE_BITS(s)
#define EXT2_ADDR_PER_BLOCK_BITS(s)
#define EXT2_INODE_SIZE(s)
#define EXT2_FIRST_INO(s)

/*
 * Structure of a blocks group descriptor
 */
struct ext2_group_desc
{};

/*
 * Macro-instructions used to manage group descriptors
 */
#define EXT2_BLOCKS_PER_GROUP(s)
#define EXT2_DESC_PER_BLOCK(s)
#define EXT2_INODES_PER_GROUP(s)
#define EXT2_DESC_PER_BLOCK_BITS(s)

/*
 * Constants relative to the data blocks
 */
#define EXT2_NDIR_BLOCKS
#define EXT2_IND_BLOCK
#define EXT2_DIND_BLOCK
#define EXT2_TIND_BLOCK
#define EXT2_N_BLOCKS

/*
 * Inode flags (GETFLAGS/SETFLAGS)
 */
#define EXT2_SECRM_FL
#define EXT2_UNRM_FL
#define EXT2_COMPR_FL
#define EXT2_SYNC_FL
#define EXT2_IMMUTABLE_FL
#define EXT2_APPEND_FL
#define EXT2_NODUMP_FL
#define EXT2_NOATIME_FL
/* Reserved for compression usage... */
#define EXT2_DIRTY_FL
#define EXT2_COMPRBLK_FL
#define EXT2_NOCOMP_FL
#define EXT2_ECOMPR_FL
/* End compression flags --- maybe not all used */	
#define EXT2_BTREE_FL
#define EXT2_INDEX_FL
#define EXT2_IMAGIC_FL
#define EXT2_JOURNAL_DATA_FL
#define EXT2_NOTAIL_FL
#define EXT2_DIRSYNC_FL
#define EXT2_TOPDIR_FL
#define EXT2_RESERVED_FL

#define EXT2_FL_USER_VISIBLE
#define EXT2_FL_USER_MODIFIABLE

/* Flags that should be inherited by new inodes from their parent. */
#define EXT2_FL_INHERITED

/* Flags that are appropriate for regular files (all but dir-specific ones). */
#define EXT2_REG_FLMASK

/* Flags that are appropriate for non-directories/regular files. */
#define EXT2_OTHER_FLMASK

/* Mask out flags that are inappropriate for the given type of inode. */
static inline __u32 ext2_mask_flags(umode_t mode, __u32 flags)
{}

/*
 * ioctl commands
 */
#define EXT2_IOC_GETVERSION
#define EXT2_IOC_SETVERSION
#define EXT2_IOC_GETRSVSZ
#define EXT2_IOC_SETRSVSZ

/*
 * ioctl commands in 32 bit emulation
 */
#define EXT2_IOC32_GETVERSION
#define EXT2_IOC32_SETVERSION

/*
 * Structure of an inode on the disk
 */
struct ext2_inode {};

#define i_size_high

#define i_reserved1
#define i_frag
#define i_fsize
#define i_uid_low
#define i_gid_low
#define i_uid_high
#define i_gid_high
#define i_reserved2

/*
 * File system states
 */
#define EXT2_VALID_FS
#define EXT2_ERROR_FS
#define EFSCORRUPTED

/*
 * Mount flags
 */
#define EXT2_MOUNT_OLDALLOC
#define EXT2_MOUNT_GRPID
#define EXT2_MOUNT_DEBUG
#define EXT2_MOUNT_ERRORS_CONT
#define EXT2_MOUNT_ERRORS_RO
#define EXT2_MOUNT_ERRORS_PANIC
#define EXT2_MOUNT_MINIX_DF
#define EXT2_MOUNT_NOBH
#define EXT2_MOUNT_NO_UID32
#define EXT2_MOUNT_XATTR_USER
#define EXT2_MOUNT_POSIX_ACL
#define EXT2_MOUNT_XIP
#define EXT2_MOUNT_USRQUOTA
#define EXT2_MOUNT_GRPQUOTA
#define EXT2_MOUNT_RESERVATION
#define EXT2_MOUNT_DAX


#define clear_opt(o, opt)
#define set_opt(o, opt)
#define test_opt(sb, opt)
/*
 * Maximal mount counts between two filesystem checks
 */
#define EXT2_DFL_MAX_MNT_COUNT
#define EXT2_DFL_CHECKINTERVAL

/*
 * Behaviour when detecting errors
 */
#define EXT2_ERRORS_CONTINUE
#define EXT2_ERRORS_RO
#define EXT2_ERRORS_PANIC
#define EXT2_ERRORS_DEFAULT

/*
 * Allocation flags
 */
#define EXT2_ALLOC_NORESERVE

/*
 * Structure of the super block
 */
struct ext2_super_block {};

/*
 * Codes for operating systems
 */
#define EXT2_OS_LINUX
#define EXT2_OS_HURD
#define EXT2_OS_MASIX
#define EXT2_OS_FREEBSD
#define EXT2_OS_LITES

/*
 * Revision levels
 */
#define EXT2_GOOD_OLD_REV
#define EXT2_DYNAMIC_REV

#define EXT2_CURRENT_REV
#define EXT2_MAX_SUPP_REV

#define EXT2_GOOD_OLD_INODE_SIZE

/*
 * Feature set definitions
 */

#define EXT2_HAS_COMPAT_FEATURE(sb,mask)
#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask)
#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask)
#define EXT2_SET_COMPAT_FEATURE(sb,mask)
#define EXT2_SET_RO_COMPAT_FEATURE(sb,mask)
#define EXT2_SET_INCOMPAT_FEATURE(sb,mask)
#define EXT2_CLEAR_COMPAT_FEATURE(sb,mask)
#define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask)
#define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask)

#define EXT2_FEATURE_COMPAT_DIR_PREALLOC
#define EXT2_FEATURE_COMPAT_IMAGIC_INODES
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL
#define EXT2_FEATURE_COMPAT_EXT_ATTR
#define EXT2_FEATURE_COMPAT_RESIZE_INO
#define EXT2_FEATURE_COMPAT_DIR_INDEX
#define EXT2_FEATURE_COMPAT_ANY

#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE
#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR
#define EXT2_FEATURE_RO_COMPAT_ANY

#define EXT2_FEATURE_INCOMPAT_COMPRESSION
#define EXT2_FEATURE_INCOMPAT_FILETYPE
#define EXT3_FEATURE_INCOMPAT_RECOVER
#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV
#define EXT2_FEATURE_INCOMPAT_META_BG
#define EXT2_FEATURE_INCOMPAT_ANY

#define EXT2_FEATURE_COMPAT_SUPP
#define EXT2_FEATURE_INCOMPAT_SUPP
#define EXT2_FEATURE_RO_COMPAT_SUPP
#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED
#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED

/*
 * Default values for user and/or group using reserved blocks
 */
#define EXT2_DEF_RESUID
#define EXT2_DEF_RESGID

/*
 * Default mount options
 */
#define EXT2_DEFM_DEBUG
#define EXT2_DEFM_BSDGROUPS
#define EXT2_DEFM_XATTR_USER
#define EXT2_DEFM_ACL
#define EXT2_DEFM_UID16
    /* Not used by ext2, but reserved for use by ext3 */
#define EXT3_DEFM_JMODE 
#define EXT3_DEFM_JMODE_DATA
#define EXT3_DEFM_JMODE_ORDERED
#define EXT3_DEFM_JMODE_WBACK

/*
 * Structure of a directory entry
 */

struct ext2_dir_entry {};

/*
 * The new version of the directory entry.  Since EXT2 structures are
 * stored in intel byte order, and the name_len field could never be
 * bigger than 255 chars, it's safe to reclaim the extra byte for the
 * file_type field.
 */
struct ext2_dir_entry_2 {};

/*
 * EXT2_DIR_PAD defines the directory entries boundaries
 *
 * NOTE: It must be a multiple of 4
 */
#define EXT2_DIR_PAD
#define EXT2_DIR_ROUND
#define EXT2_DIR_REC_LEN(name_len)
#define EXT2_MAX_REC_LEN

static inline void verify_offsets(void)
{}

/*
 * ext2 mount options
 */
struct ext2_mount_options {};

/*
 * second extended file system inode data in memory
 */
struct ext2_inode_info {};

/*
 * Inode dynamic state flags
 */
#define EXT2_STATE_NEW


/*
 * Function prototypes
 */

/*
 * Ok, these declarations are also in <linux/kernel.h> but none of the
 * ext2 source programs needs to include it so they are duplicated here.
 */

static inline struct ext2_inode_info *EXT2_I(struct inode *inode)
{}

/* balloc.c */
extern int ext2_bg_has_super(struct super_block *sb, int group);
extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
extern ext2_fsblk_t ext2_new_blocks(struct inode *, ext2_fsblk_t,
				unsigned long *, int *, unsigned int);
extern int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk,
				 unsigned int count);
extern void ext2_free_blocks(struct inode *, ext2_fsblk_t, unsigned long);
extern unsigned long ext2_count_free_blocks (struct super_block *);
extern unsigned long ext2_count_dirs (struct super_block *);
extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
						    unsigned int block_group,
						    struct buffer_head ** bh);
extern void ext2_discard_reservation (struct inode *);
extern int ext2_should_retry_alloc(struct super_block *sb, int *retries);
extern void ext2_init_block_alloc_info(struct inode *);
extern void ext2_rsv_window_add(struct super_block *sb, struct ext2_reserve_window_node *rsv);

/* dir.c */
int ext2_add_link(struct dentry *, struct inode *);
int ext2_inode_by_name(struct inode *dir,
			      const struct qstr *child, ino_t *ino);
int ext2_make_empty(struct inode *, struct inode *);
struct ext2_dir_entry_2 *ext2_find_entry(struct inode *, const struct qstr *,
		struct folio **foliop);
int ext2_delete_entry(struct ext2_dir_entry_2 *dir, struct folio *folio);
int ext2_empty_dir(struct inode *);
struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct folio **foliop);
int ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
		struct folio *folio, struct inode *inode, bool update_times);

/* ialloc.c */
extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *);
extern void ext2_free_inode (struct inode *);
extern unsigned long ext2_count_free_inodes (struct super_block *);
extern unsigned long ext2_count_free (struct buffer_head *, unsigned);

/* inode.c */
extern struct inode *ext2_iget (struct super_block *, unsigned long);
extern int ext2_write_inode (struct inode *, struct writeback_control *);
extern void ext2_evict_inode(struct inode *);
void ext2_write_failed(struct address_space *mapping, loff_t to);
extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
extern int ext2_setattr (struct mnt_idmap *, struct dentry *, struct iattr *);
extern int ext2_getattr (struct mnt_idmap *, const struct path *,
			 struct kstat *, u32, unsigned int);
extern void ext2_set_inode_flags(struct inode *inode);
extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
		       u64 start, u64 len);

/* ioctl.c */
extern int ext2_fileattr_get(struct dentry *dentry, struct fileattr *fa);
extern int ext2_fileattr_set(struct mnt_idmap *idmap,
			     struct dentry *dentry, struct fileattr *fa);
extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long);

/* namei.c */
struct dentry *ext2_get_parent(struct dentry *child);

/* super.c */
extern __printf(3, 4)
void ext2_error(struct super_block *, const char *, const char *, ...);
extern __printf(3, 4)
void ext2_msg(struct super_block *, const char *, const char *, ...);
extern void ext2_update_dynamic_rev (struct super_block *sb);
extern void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es,
			    int wait);

/*
 * Inodes and files operations
 */

/* dir.c */
extern const struct file_operations ext2_dir_operations;

/* file.c */
extern int ext2_fsync(struct file *file, loff_t start, loff_t end,
		      int datasync);
extern const struct inode_operations ext2_file_inode_operations;
extern const struct file_operations ext2_file_operations;

/* inode.c */
extern void ext2_set_file_ops(struct inode *inode);
extern const struct address_space_operations ext2_aops;
extern const struct iomap_ops ext2_iomap_ops;

/* namei.c */
extern const struct inode_operations ext2_dir_inode_operations;
extern const struct inode_operations ext2_special_inode_operations;

/* symlink.c */
extern const struct inode_operations ext2_fast_symlink_inode_operations;
extern const struct inode_operations ext2_symlink_inode_operations;

static inline ext2_fsblk_t
ext2_group_first_block_no(struct super_block *sb, unsigned long group_no)
{}

static inline ext2_fsblk_t
ext2_group_last_block_no(struct super_block *sb, unsigned long group_no)
{}

#define ext2_set_bit
#define ext2_clear_bit
#define ext2_test_bit
#define ext2_find_first_zero_bit
#define ext2_find_next_zero_bit