linux/fs/fat/fat.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _FAT_H
#define _FAT_H

#include <linux/buffer_head.h>
#include <linux/nls.h>
#include <linux/hash.h>
#include <linux/ratelimit.h>
#include <linux/msdos_fs.h>
#include <linux/fs_context.h>
#include <linux/fs_parser.h>

/*
 * vfat shortname flags
 */
#define VFAT_SFN_DISPLAY_LOWER
#define VFAT_SFN_DISPLAY_WIN95
#define VFAT_SFN_DISPLAY_WINNT
#define VFAT_SFN_CREATE_WIN95
#define VFAT_SFN_CREATE_WINNT

#define FAT_ERRORS_CONT
#define FAT_ERRORS_PANIC
#define FAT_ERRORS_RO

#define FAT_NFS_STALE_RW
#define FAT_NFS_NOSTALE_RO

struct fat_mount_options {};

#define FAT_HASH_BITS
#define FAT_HASH_SIZE

/*
 * MS-DOS file system in-core superblock data
 */
struct msdos_sb_info {};

#define FAT_CACHE_VALID

/*
 * MS-DOS file system inode data in memory
 */
struct msdos_inode_info {};

struct fat_slot_info {};

static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
{}

/*
 * Functions that determine the variant of the FAT file system (i.e.,
 * whether this is FAT12, FAT16 or FAT32.
 */
static inline bool is_fat12(const struct msdos_sb_info *sbi)
{}

static inline bool is_fat16(const struct msdos_sb_info *sbi)
{}

static inline bool is_fat32(const struct msdos_sb_info *sbi)
{}

/* Maximum number of clusters */
static inline u32 max_fat(struct super_block *sb)
{}

static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
{}

/*
 * If ->i_mode can't hold S_IWUGO (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 fat_mode_can_hold_ro(struct inode *inode)
{}

/* Convert attribute bits and a mask to the UNIX mode. */
static inline umode_t fat_make_mode(struct msdos_sb_info *sbi,
				   u8 attrs, umode_t mode)
{}

/* Return the FAT attribute byte for this inode */
static inline u8 fat_make_attrs(struct inode *inode)
{}

static inline void fat_save_attrs(struct inode *inode, u8 attrs)
{}

static inline unsigned char fat_checksum(const __u8 *name)
{}

static inline sector_t fat_clus_to_blknr(struct msdos_sb_info *sbi, int clus)
{}

static inline void fat_get_blknr_offset(struct msdos_sb_info *sbi,
				loff_t i_pos, sector_t *blknr, int *offset)
{}

static inline loff_t fat_i_pos_read(struct msdos_sb_info *sbi,
					struct inode *inode)
{}

static inline void fat16_towchar(wchar_t *dst, const __u8 *src, size_t len)
{}

static inline int fat_get_start(const struct msdos_sb_info *sbi,
				const struct msdos_dir_entry *de)
{}

static inline void fat_set_start(struct msdos_dir_entry *de, int cluster)
{}

static inline void fatwchar_to16(__u8 *dst, const wchar_t *src, size_t len)
{}

/* fat/cache.c */
extern void fat_cache_inval_inode(struct inode *inode);
extern int fat_get_cluster(struct inode *inode, int cluster,
			   int *fclus, int *dclus);
extern int fat_get_mapped_cluster(struct inode *inode, sector_t sector,
				  sector_t last_block,
				  unsigned long *mapped_blocks, sector_t *bmap);
extern int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
		    unsigned long *mapped_blocks, int create, bool from_bmap);

/* fat/dir.c */
extern const struct file_operations fat_dir_operations;
extern int fat_search_long(struct inode *inode, const unsigned char *name,
			   int name_len, struct fat_slot_info *sinfo);
extern int fat_dir_empty(struct inode *dir);
extern int fat_subdirs(struct inode *dir);
extern int fat_scan(struct inode *dir, const unsigned char *name,
		    struct fat_slot_info *sinfo);
extern int fat_scan_logstart(struct inode *dir, int i_logstart,
			     struct fat_slot_info *sinfo);
extern int fat_get_dotdot_entry(struct inode *dir, struct buffer_head **bh,
				struct msdos_dir_entry **de);
extern int fat_alloc_new_dir(struct inode *dir, struct timespec64 *ts);
extern int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
			   struct fat_slot_info *sinfo);
extern int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo);

/* fat/fatent.c */
struct fat_entry {};

static inline void fatent_init(struct fat_entry *fatent)
{}

static inline void fatent_set_entry(struct fat_entry *fatent, int entry)
{}

static inline void fatent_brelse(struct fat_entry *fatent)
{}

static inline bool fat_valid_entry(struct msdos_sb_info *sbi, int entry)
{}

extern void fat_ent_access_init(struct super_block *sb);
extern int fat_ent_read(struct inode *inode, struct fat_entry *fatent,
			int entry);
extern int fat_ent_write(struct inode *inode, struct fat_entry *fatent,
			 int new, int wait);
extern int fat_alloc_clusters(struct inode *inode, int *cluster,
			      int nr_cluster);
extern int fat_free_clusters(struct inode *inode, int cluster);
extern int fat_count_free_clusters(struct super_block *sb);
extern int fat_trim_fs(struct inode *inode, struct fstrim_range *range);

/* fat/file.c */
extern long fat_generic_ioctl(struct file *filp, unsigned int cmd,
			      unsigned long arg);
extern const struct file_operations fat_file_operations;
extern const struct inode_operations fat_file_inode_operations;
extern int fat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
		       struct iattr *attr);
extern void fat_truncate_blocks(struct inode *inode, loff_t offset);
extern int fat_getattr(struct mnt_idmap *idmap,
		       const struct path *path, struct kstat *stat,
		       u32 request_mask, unsigned int flags);
extern int fat_file_fsync(struct file *file, loff_t start, loff_t end,
			  int datasync);

/* fat/inode.c */
extern int fat_block_truncate_page(struct inode *inode, loff_t from);
extern void fat_attach(struct inode *inode, loff_t i_pos);
extern void fat_detach(struct inode *inode);
extern struct inode *fat_iget(struct super_block *sb, loff_t i_pos);
extern struct inode *fat_build_inode(struct super_block *sb,
			struct msdos_dir_entry *de, loff_t i_pos);
extern int fat_sync_inode(struct inode *inode);
extern int fat_fill_super(struct super_block *sb, struct fs_context *fc,
			  void (*setup)(struct super_block *));
extern int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de);

extern int fat_flush_inodes(struct super_block *sb, struct inode *i1,
			    struct inode *i2);

extern const struct fs_parameter_spec fat_param_spec[];
int fat_init_fs_context(struct fs_context *fc, bool is_vfat);
void fat_free_fc(struct fs_context *fc);

int fat_parse_param(struct fs_context *fc, struct fs_parameter *param,
		    bool is_vfat);
int fat_reconfigure(struct fs_context *fc);

static inline unsigned long fat_dir_hash(int logstart)
{}
extern int fat_add_cluster(struct inode *inode);

/* fat/misc.c */
extern __printf(3, 4) __cold
void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...);
#define fat_fs_error(sb, fmt, args...)
#define fat_fs_error_ratelimit(sb, fmt, args...)

#define FAT_PRINTK_PREFIX
#define fat_msg(sb, level, fmt, args...)
__printf(3, 4) __cold
void _fat_msg(struct super_block *sb, const char *level, const char *fmt, ...);
#define fat_msg_ratelimit(sb, level, fmt, args...)
extern int fat_clusters_flush(struct super_block *sb);
extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster);
extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts,
			      __le16 __time, __le16 __date, u8 time_cs);
extern void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts,
			      __le16 *time, __le16 *date, u8 *time_cs);
extern struct timespec64 fat_truncate_atime(const struct msdos_sb_info *sbi,
					    const struct timespec64 *ts);
extern struct timespec64 fat_truncate_mtime(const struct msdos_sb_info *sbi,
					    const struct timespec64 *ts);
extern int fat_truncate_time(struct inode *inode, struct timespec64 *now,
			     int flags);
extern int fat_update_time(struct inode *inode, int flags);
extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs);

int fat_cache_init(void);
void fat_cache_destroy(void);

/* fat/nfs.c */
extern const struct export_operations fat_export_ops;
extern const struct export_operations fat_export_ops_nostale;

/* helper for printk */
llu;

#endif /* !_FAT_H */