linux/fs/exfat/exfat_fs.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
 */

#ifndef _EXFAT_FS_H
#define _EXFAT_FS_H

#include <linux/fs.h>
#include <linux/ratelimit.h>
#include <linux/nls.h>
#include <linux/blkdev.h>

#define EXFAT_ROOT_INO

#define EXFAT_CLUSTERS_UNTRACKED

/*
 * exfat error flags
 */
enum exfat_error_mode {};

/*
 * exfat nls lossy flag
 */
enum {};

#define EXFAT_HASH_BITS
#define EXFAT_HASH_SIZE

/*
 * Type Definitions
 */
#define ES_2_ENTRIES
#define ES_ALL_ENTRIES

#define ES_IDX_FILE
#define ES_IDX_STREAM
#define ES_IDX_FIRST_FILENAME
#define EXFAT_FILENAME_ENTRY_NUM(name_len)
#define ES_IDX_LAST_FILENAME(name_len)

#define DIR_DELETED

/* type values */
#define TYPE_UNUSED
#define TYPE_DELETED
#define TYPE_INVALID
#define TYPE_CRITICAL_PRI
#define TYPE_BITMAP
#define TYPE_UPCASE
#define TYPE_VOLUME
#define TYPE_DIR
#define TYPE_FILE
#define TYPE_CRITICAL_SEC
#define TYPE_STREAM
#define TYPE_EXTEND
#define TYPE_ACL
#define TYPE_BENIGN_PRI
#define TYPE_GUID
#define TYPE_PADDING
#define TYPE_ACLTAB
#define TYPE_BENIGN_SEC
#define TYPE_VENDOR_EXT
#define TYPE_VENDOR_ALLOC

#define MAX_CHARSET_SIZE
#define MAX_NAME_LENGTH
#define MAX_VFSNAME_BUF_SIZE

#define EXFAT_HINT_NONE
#define EXFAT_MIN_SUBDIR

/*
 * helpers for cluster size to byte conversion.
 */
#define EXFAT_CLU_TO_B(b, sbi)
#define EXFAT_B_TO_CLU(b, sbi)
#define EXFAT_B_TO_CLU_ROUND_UP(b, sbi)
#define EXFAT_CLU_OFFSET(off, sbi)

/*
 * helpers for block size to byte conversion.
 */
#define EXFAT_BLK_TO_B(b, sb)
#define EXFAT_B_TO_BLK(b, sb)
#define EXFAT_B_TO_BLK_ROUND_UP(b, sb)
#define EXFAT_BLK_OFFSET(off, sb)

/*
 * helpers for block size to dentry size conversion.
 */
#define EXFAT_B_TO_DEN(b)
#define EXFAT_DEN_TO_B(b)

/*
 * helpers for cluster size to dentry size conversion.
 */
#define EXFAT_CLU_TO_DEN(clu, sbi)
#define EXFAT_DEN_TO_CLU(dentry, sbi)

/*
 * helpers for fat entry.
 */
#define FAT_ENT_SIZE
#define FAT_ENT_SIZE_BITS
#define FAT_ENT_OFFSET_SECTOR(sb, loc)
#define FAT_ENT_OFFSET_BYTE_IN_SECTOR(sb, loc)

/*
 * helpers for bitmap.
 */
#define CLUSTER_TO_BITMAP_ENT(clu)
#define BITMAP_ENT_TO_CLUSTER(ent)
#define BITS_PER_SECTOR(sb)
#define BITS_PER_SECTOR_MASK(sb)
#define BITMAP_OFFSET_SECTOR_INDEX(sb, ent)
#define BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent)
#define BITMAP_OFFSET_BYTE_IN_SECTOR(sb, ent)
#define IGNORED_BITS_REMAINED(clu, clu_base)

#define ES_ENTRY_NUM(name_len)
/* 19 entries = 1 file entry + 1 stream entry + 17 filename entries */
#define ES_MAX_ENTRY_NUM

/*
 * 19 entries x 32 bytes/entry = 608 bytes.
 * The 608 bytes are in 3 sectors at most (even 512 Byte sector).
 */
#define DIR_CACHE_SIZE

struct exfat_dentry_namebuf {};

/* unicode name structure */
struct exfat_uni_name {};

/* directory structure */
struct exfat_chain {};

/* first empty entry hint information */
struct exfat_hint_femp {};

/* hint structure */
struct exfat_hint {};

struct exfat_entry_set_cache {};

#define IS_DYNAMIC_ES(es)

struct exfat_dir_entry {};

/*
 * exfat mount in-memory data
 */
struct exfat_mount_options {};

/*
 * EXFAT file system superblock in-memory data
 */
struct exfat_sb_info {};

#define EXFAT_CACHE_VALID

/*
 * EXFAT file system inode in-memory data
 */
struct exfat_inode_info {};

static inline struct exfat_sb_info *EXFAT_SB(struct super_block *sb)
{}

static inline struct exfat_inode_info *EXFAT_I(struct inode *inode)
{}

/*
 * If ->i_mode can't hold 0222 (i.e. ATTR_RO), we use ->i_attrs to
 * save ATTR_RO instead of ->i_mode.
 *
 * If it's directory and !sbi->options.rodir, ATTR_RO isn't read-only
 * bit, it's just used as flag for app.
 */
static inline int exfat_mode_can_hold_ro(struct inode *inode)
{}

/* Convert attribute bits and a mask to the UNIX mode. */
static inline mode_t exfat_make_mode(struct exfat_sb_info *sbi,
		unsigned short attr, mode_t mode)
{}

/* Return the FAT attribute byte for this inode */
static inline unsigned short exfat_make_attr(struct inode *inode)
{}

static inline void exfat_save_attr(struct inode *inode, unsigned short attr)
{}

static inline bool exfat_is_last_sector_in_cluster(struct exfat_sb_info *sbi,
		sector_t sec)
{}

static inline sector_t exfat_cluster_to_sector(struct exfat_sb_info *sbi,
		unsigned int clus)
{}

static inline unsigned int exfat_sector_to_cluster(struct exfat_sb_info *sbi,
		sector_t sec)
{}

static inline bool is_valid_cluster(struct exfat_sb_info *sbi,
		unsigned int clus)
{}

/* super.c */
int exfat_set_volume_dirty(struct super_block *sb);
int exfat_clear_volume_dirty(struct super_block *sb);

/* fatent.c */
#define exfat_get_next_cluster(sb, pclu)

int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
		struct exfat_chain *p_chain, bool sync_bmap);
int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain);
int exfat_ent_get(struct super_block *sb, unsigned int loc,
		unsigned int *content);
int exfat_ent_set(struct super_block *sb, unsigned int loc,
		unsigned int content);
int exfat_chain_cont_cluster(struct super_block *sb, unsigned int chain,
		unsigned int len);
int exfat_zeroed_cluster(struct inode *dir, unsigned int clu);
int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_chain,
		unsigned int *ret_clu);
int exfat_count_num_clusters(struct super_block *sb,
		struct exfat_chain *p_chain, unsigned int *ret_count);

/* balloc.c */
int exfat_load_bitmap(struct super_block *sb);
void exfat_free_bitmap(struct exfat_sb_info *sbi);
int exfat_set_bitmap(struct inode *inode, unsigned int clu, bool sync);
void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync);
unsigned int exfat_find_free_bitmap(struct super_block *sb, unsigned int clu);
int exfat_count_used_clusters(struct super_block *sb, unsigned int *ret_count);
int exfat_trim_fs(struct inode *inode, struct fstrim_range *range);

/* file.c */
extern const struct file_operations exfat_file_operations;
int __exfat_truncate(struct inode *inode);
void exfat_truncate(struct inode *inode);
int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
		  struct iattr *attr);
int exfat_getattr(struct mnt_idmap *idmap, const struct path *path,
		  struct kstat *stat, unsigned int request_mask,
		  unsigned int query_flags);
int exfat_file_fsync(struct file *file, loff_t start, loff_t end, int datasync);
long exfat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
long exfat_compat_ioctl(struct file *filp, unsigned int cmd,
				unsigned long arg);

/* namei.c */
extern const struct dentry_operations exfat_dentry_ops;
extern const struct dentry_operations exfat_utf8_dentry_ops;

/* cache.c */
int exfat_cache_init(void);
void exfat_cache_shutdown(void);
void exfat_cache_inval_inode(struct inode *inode);
int exfat_get_cluster(struct inode *inode, unsigned int cluster,
		unsigned int *fclus, unsigned int *dclus,
		unsigned int *last_dclus, int allow_eof);

/* dir.c */
extern const struct inode_operations exfat_dir_inode_operations;
extern const struct file_operations exfat_dir_operations;
unsigned int exfat_get_entry_type(struct exfat_dentry *p_entry);
void exfat_init_dir_entry(struct exfat_entry_set_cache *es,
		unsigned int type, unsigned int start_clu,
		unsigned long long size, struct timespec64 *ts);
void exfat_init_ext_entry(struct exfat_entry_set_cache *es, int num_entries,
		struct exfat_uni_name *p_uniname);
void exfat_remove_entries(struct inode *inode, struct exfat_entry_set_cache *es,
		int order);
void exfat_update_dir_chksum(struct exfat_entry_set_cache *es);
int exfat_calc_num_entries(struct exfat_uni_name *p_uniname);
int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei,
		struct exfat_chain *p_dir, struct exfat_uni_name *p_uniname,
		struct exfat_hint *hint_opt);
int exfat_alloc_new_dir(struct inode *inode, struct exfat_chain *clu);
struct exfat_dentry *exfat_get_dentry(struct super_block *sb,
		struct exfat_chain *p_dir, int entry, struct buffer_head **bh);
struct exfat_dentry *exfat_get_dentry_cached(struct exfat_entry_set_cache *es,
		int num);
int exfat_get_dentry_set(struct exfat_entry_set_cache *es,
		struct super_block *sb, struct exfat_chain *p_dir, int entry,
		unsigned int num_entries);
int exfat_get_empty_dentry_set(struct exfat_entry_set_cache *es,
		struct super_block *sb, struct exfat_chain *p_dir, int entry,
		unsigned int num_entries);
int exfat_put_dentry_set(struct exfat_entry_set_cache *es, int sync);
int exfat_count_dir_entries(struct super_block *sb, struct exfat_chain *p_dir);

/* inode.c */
extern const struct inode_operations exfat_file_inode_operations;
void exfat_sync_inode(struct inode *inode);
struct inode *exfat_build_inode(struct super_block *sb,
		struct exfat_dir_entry *info, loff_t i_pos);
void exfat_hash_inode(struct inode *inode, loff_t i_pos);
void exfat_unhash_inode(struct inode *inode);
struct inode *exfat_iget(struct super_block *sb, loff_t i_pos);
int __exfat_write_inode(struct inode *inode, int sync);
int exfat_write_inode(struct inode *inode, struct writeback_control *wbc);
void exfat_evict_inode(struct inode *inode);
int exfat_block_truncate_page(struct inode *inode, loff_t from);

/* exfat/nls.c */
unsigned short exfat_toupper(struct super_block *sb, unsigned short a);
int exfat_uniname_ncmp(struct super_block *sb, unsigned short *a,
		unsigned short *b, unsigned int len);
int exfat_utf16_to_nls(struct super_block *sb,
		struct exfat_uni_name *uniname, unsigned char *p_cstring,
		int len);
int exfat_nls_to_utf16(struct super_block *sb,
		const unsigned char *p_cstring, const int len,
		struct exfat_uni_name *uniname, int *p_lossy);
int exfat_create_upcase_table(struct super_block *sb);
void exfat_free_upcase_table(struct exfat_sb_info *sbi);

/* exfat/misc.c */
void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
		__printf(3, 4) __cold;
#define exfat_fs_error(sb, fmt, args...)
#define exfat_fs_error_ratelimit(sb, fmt, args...)

/* expand to pr_*() with prefix */
#define exfat_err(sb, fmt, ...)
#define exfat_warn(sb, fmt, ...)
#define exfat_info(sb, fmt, ...)
#define exfat_debug(sb, fmt, ...)

void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
		u8 tz, __le16 time, __le16 date, u8 time_cs);
void exfat_truncate_atime(struct timespec64 *ts);
void exfat_truncate_inode_atime(struct inode *inode);
void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
		u8 *tz, __le16 *time, __le16 *date, u8 *time_cs);
u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type);
u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type);
void exfat_update_bh(struct buffer_head *bh, int sync);
int exfat_update_bhs(struct buffer_head **bhs, int nr_bhs, int sync);
void exfat_chain_set(struct exfat_chain *ec, unsigned int dir,
		unsigned int size, unsigned char flags);
void exfat_chain_dup(struct exfat_chain *dup, struct exfat_chain *ec);

#endif /* !_EXFAT_FS_H */