From f8a595d594e9374709ab2c14805f1af07dafea45 Mon Sep 17 00:00:00 2001 From: Liu Qishuai Date: Sun, 29 Sep 2013 12:39:53 +0800 Subject: [PATCH] remove __cplusplus stuff --- exfat_api.h | 217 ++++++------ exfat_bitmap.h | 28 +- exfat_blkdev.h | 59 ++-- exfat_cache.h | 76 ++-- exfat_config.h | 8 - exfat_core.h | 926 ++++++++++++++++++++++++------------------------- exfat_data.h | 20 +- exfat_nls.h | 14 +- exfat_oal.h | 56 ++- 9 files changed, 666 insertions(+), 738 deletions(-) diff --git a/exfat_api.h b/exfat_api.h index 66b9d89..306fe81 100644 --- a/exfat_api.h +++ b/exfat_api.h @@ -38,10 +38,6 @@ #include #include "exfat_config.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - /*----------------------------------------------------------------------*/ /* Constant & Macro Definitions */ /*----------------------------------------------------------------------*/ @@ -101,114 +97,111 @@ extern "C" { #define FFS_NAMETOOLONG 18 #define FFS_ERROR 19 - /*----------------------------------------------------------------------*/ - /* Type Definitions */ - /*----------------------------------------------------------------------*/ - - typedef struct { - u16 Year; - u16 Month; - u16 Day; - u16 Hour; - u16 Minute; - u16 Second; - u16 MilliSecond; - } DATE_TIME_T; - - typedef struct { - u32 Offset; /* start sector number of the partition */ - u32 Size; /* in sectors */ - } PART_INFO_T; - - typedef struct { - u32 SecSize; /* sector size in bytes */ - u32 DevSize; /* block device size in sectors */ - } DEV_INFO_T; - - typedef struct { - u32 FatType; - u32 ClusterSize; - u32 NumClusters; - u32 FreeClusters; - u32 UsedClusters; - } VOL_INFO_T; - - /* directory structure */ - typedef struct { - u32 dir; - s32 size; - u8 flags; - } CHAIN_T; - - /* file id structure */ - typedef struct { - CHAIN_T dir; - s32 entry; - u32 type; - u32 attr; - u32 start_clu; - u64 size; - u8 flags; - s64 rwoffset; - s32 hint_last_off; - u32 hint_last_clu; - } FILE_ID_T; - - typedef struct { - char Name[MAX_NAME_LENGTH * MAX_CHARSET_SIZE]; - char ShortName[DOS_NAME_LENGTH + 2]; /* used only for FAT12/16/32, not used for exFAT */ - u32 Attr; - u64 Size; - u32 NumSubdirs; - DATE_TIME_T CreateTimestamp; - DATE_TIME_T ModifyTimestamp; - DATE_TIME_T AccessTimestamp; - } DIR_ENTRY_T; - - /*======================================================================*/ - /* */ - /* API FUNCTION DECLARATIONS */ - /* (CHANGE THIS PART IF REQUIRED) */ - /* */ - /*======================================================================*/ - - /*----------------------------------------------------------------------*/ - /* External Function Declarations */ - /*----------------------------------------------------------------------*/ - - /* file system initialization & shutdown functions */ - s32 FsInit(void); - s32 FsShutdown(void); - - /* volume management functions */ - s32 FsMountVol(struct super_block *sb); - s32 FsUmountVol(struct super_block *sb); - s32 FsGetVolInfo(struct super_block *sb, VOL_INFO_T *info); - s32 FsSyncVol(struct super_block *sb, s32 do_sync); - - /* file management functions */ - s32 FsLookupFile(struct inode *inode, char *path, FILE_ID_T *fid); - s32 FsCreateFile(struct inode *inode, char *path, u8 mode, FILE_ID_T *fid); - s32 FsReadFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *rcount); - s32 FsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *wcount); - s32 FsTruncateFile(struct inode *inode, u64 old_size, u64 new_size); - s32 FsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry); - s32 FsRemoveFile(struct inode *inode, FILE_ID_T *fid); - s32 FsSetAttr(struct inode *inode, u32 attr); - s32 FsReadStat(struct inode *inode, DIR_ENTRY_T *info); - s32 FsWriteStat(struct inode *inode, DIR_ENTRY_T *info); - s32 FsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu); - - /* directory management functions */ - s32 FsCreateDir(struct inode *inode, char *path, FILE_ID_T *fid); - s32 FsReadDir(struct inode *inode, DIR_ENTRY_T *dir_entry); - s32 FsRemoveDir(struct inode *inode, FILE_ID_T *fid); - - /* debug functions */ - s32 FsReleaseCache(struct super_block *sb); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +/*----------------------------------------------------------------------*/ +/* Type Definitions */ +/*----------------------------------------------------------------------*/ + +typedef struct { + u16 Year; + u16 Month; + u16 Day; + u16 Hour; + u16 Minute; + u16 Second; + u16 MilliSecond; +} DATE_TIME_T; + +typedef struct { + u32 Offset; /* start sector number of the partition */ + u32 Size; /* in sectors */ +} PART_INFO_T; + +typedef struct { + u32 SecSize; /* sector size in bytes */ + u32 DevSize; /* block device size in sectors */ +} DEV_INFO_T; + +typedef struct { + u32 FatType; + u32 ClusterSize; + u32 NumClusters; + u32 FreeClusters; + u32 UsedClusters; +} VOL_INFO_T; + +/* directory structure */ +typedef struct { + u32 dir; + s32 size; + u8 flags; +} CHAIN_T; + +/* file id structure */ +typedef struct { + CHAIN_T dir; + s32 entry; + u32 type; + u32 attr; + u32 start_clu; + u64 size; + u8 flags; + s64 rwoffset; + s32 hint_last_off; + u32 hint_last_clu; +} FILE_ID_T; + +typedef struct { + char Name[MAX_NAME_LENGTH * MAX_CHARSET_SIZE]; + char ShortName[DOS_NAME_LENGTH + 2]; /* used only for FAT12/16/32, not used for exFAT */ + u32 Attr; + u64 Size; + u32 NumSubdirs; + DATE_TIME_T CreateTimestamp; + DATE_TIME_T ModifyTimestamp; + DATE_TIME_T AccessTimestamp; +} DIR_ENTRY_T; + +/*======================================================================*/ +/* */ +/* API FUNCTION DECLARATIONS */ +/* (CHANGE THIS PART IF REQUIRED) */ +/* */ +/*======================================================================*/ + +/*----------------------------------------------------------------------*/ +/* External Function Declarations */ +/*----------------------------------------------------------------------*/ + +/* file system initialization & shutdown functions */ +s32 FsInit(void); +s32 FsShutdown(void); + +/* volume management functions */ +s32 FsMountVol(struct super_block *sb); +s32 FsUmountVol(struct super_block *sb); +s32 FsGetVolInfo(struct super_block *sb, VOL_INFO_T *info); +s32 FsSyncVol(struct super_block *sb, s32 do_sync); + +/* file management functions */ +s32 FsLookupFile(struct inode *inode, char *path, FILE_ID_T *fid); +s32 FsCreateFile(struct inode *inode, char *path, u8 mode, FILE_ID_T *fid); +s32 FsReadFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *rcount); +s32 FsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *wcount); +s32 FsTruncateFile(struct inode *inode, u64 old_size, u64 new_size); +s32 FsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry); +s32 FsRemoveFile(struct inode *inode, FILE_ID_T *fid); +s32 FsSetAttr(struct inode *inode, u32 attr); +s32 FsReadStat(struct inode *inode, DIR_ENTRY_T *info); +s32 FsWriteStat(struct inode *inode, DIR_ENTRY_T *info); +s32 FsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu); + +/* directory management functions */ +s32 FsCreateDir(struct inode *inode, char *path, FILE_ID_T *fid); +s32 FsReadDir(struct inode *inode, DIR_ENTRY_T *dir_entry); +s32 FsRemoveDir(struct inode *inode, FILE_ID_T *fid); + +/* debug functions */ +s32 FsReleaseCache(struct super_block *sb); #endif /* _EXFAT_API_H */ diff --git a/exfat_bitmap.h b/exfat_bitmap.h index 4f61aef..a04d310 100644 --- a/exfat_bitmap.h +++ b/exfat_bitmap.h @@ -37,29 +37,19 @@ #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - - - /*======================================================================*/ - /* */ - /* LIBRARY FUNCTION DECLARATIONS -- OTHER UTILITY FUNCTIONS */ - /* (DO NOT CHANGE THIS PART !!) */ - /* */ - /*======================================================================*/ +/*======================================================================*/ +/* */ +/* LIBRARY FUNCTION DECLARATIONS -- OTHER UTILITY FUNCTIONS */ +/* (DO NOT CHANGE THIS PART !!) */ +/* */ +/*======================================================================*/ - /*----------------------------------------------------------------------*/ - /* Bitmap Manipulation Functions */ - /*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* Bitmap Manipulation Functions */ +/*----------------------------------------------------------------------*/ s32 exfat_bitmap_test(u8 *bitmap, s32 i); void exfat_bitmap_set(u8 *bitmap, s32 i); void exfat_bitmap_clear(u8 *bitmpa, s32 i); -#ifdef __cplusplus -} -#endif /* __cplusplus */ - #endif /* _EXFAT_BITMAP_H */ diff --git a/exfat_blkdev.h b/exfat_blkdev.h index 665ae6a..f10dfd4 100644 --- a/exfat_blkdev.h +++ b/exfat_blkdev.h @@ -38,44 +38,37 @@ #include #include "exfat_config.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - /*----------------------------------------------------------------------*/ - /* Constant & Macro Definitions (Non-Configurable) */ - /*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* Constant & Macro Definitions (Non-Configurable) */ +/*----------------------------------------------------------------------*/ - /*----------------------------------------------------------------------*/ - /* Type Definitions */ - /*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* Type Definitions */ +/*----------------------------------------------------------------------*/ - typedef struct __BD_INFO_T { - s32 sector_size; /* in bytes */ - s32 sector_size_bits; - s32 sector_size_mask; - s32 num_sectors; /* total number of sectors in this block device */ - bool opened; /* opened or not */ - } BD_INFO_T; +typedef struct __BD_INFO_T { + s32 sector_size; /* in bytes */ + s32 sector_size_bits; + s32 sector_size_mask; + s32 num_sectors; /* total number of sectors in this block device */ + bool opened; /* opened or not */ +} BD_INFO_T; - /*----------------------------------------------------------------------*/ - /* External Variable Declarations */ - /*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* External Variable Declarations */ +/*----------------------------------------------------------------------*/ - /*----------------------------------------------------------------------*/ - /* External Function Declarations */ - /*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* External Function Declarations */ +/*----------------------------------------------------------------------*/ - s32 bdev_init(void); - s32 bdev_shutdown(void); - s32 bdev_open(struct super_block *sb); - s32 bdev_close(struct super_block *sb); - s32 bdev_read(struct super_block *sb, u32 secno, struct buffer_head **bh, u32 num_secs, s32 read); - s32 bdev_write(struct super_block *sb, u32 secno, struct buffer_head *bh, u32 num_secs, s32 sync); - s32 bdev_sync(struct super_block *sb); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +s32 bdev_init(void); +s32 bdev_shutdown(void); +s32 bdev_open(struct super_block *sb); +s32 bdev_close(struct super_block *sb); +s32 bdev_read(struct super_block *sb, u32 secno, struct buffer_head **bh, u32 num_secs, s32 read); +s32 bdev_write(struct super_block *sb, u32 secno, struct buffer_head *bh, u32 num_secs, s32 sync); +s32 bdev_sync(struct super_block *sb); #endif /* _EXFAT_BLKDEV_H */ diff --git a/exfat_cache.h b/exfat_cache.h index 55e368c..8d4b577 100644 --- a/exfat_cache.h +++ b/exfat_cache.h @@ -40,55 +40,47 @@ #include #include "exfat_config.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - /*----------------------------------------------------------------------*/ - /* Constant & Macro Definitions */ - /*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* Constant & Macro Definitions */ +/*----------------------------------------------------------------------*/ #define LOCKBIT 0x01 #define DIRTYBIT 0x02 - /*----------------------------------------------------------------------*/ - /* Type Definitions */ - /*----------------------------------------------------------------------*/ - - typedef struct __BUF_CACHE_T { - struct __BUF_CACHE_T *next; - struct __BUF_CACHE_T *prev; - struct __BUF_CACHE_T *hash_next; - struct __BUF_CACHE_T *hash_prev; - s32 drv; - u32 sec; - u32 flag; - struct buffer_head *buf_bh; - } BUF_CACHE_T; +/*----------------------------------------------------------------------*/ +/* Type Definitions */ +/*----------------------------------------------------------------------*/ - /*----------------------------------------------------------------------*/ - /* External Function Declarations */ - /*----------------------------------------------------------------------*/ +typedef struct __BUF_CACHE_T { + struct __BUF_CACHE_T *next; + struct __BUF_CACHE_T *prev; + struct __BUF_CACHE_T *hash_next; + struct __BUF_CACHE_T *hash_prev; + s32 drv; + u32 sec; + u32 flag; + struct buffer_head *buf_bh; +} BUF_CACHE_T; - s32 buf_init(struct super_block *sb); - s32 buf_shutdown(struct super_block *sb); - s32 FAT_read(struct super_block *sb, u32 loc, u32 *content); - s32 FAT_write(struct super_block *sb, u32 loc, u32 content); - u8 *FAT_getblk(struct super_block *sb, u32 sec); - void FAT_modify(struct super_block *sb, u32 sec); - void FAT_release_all(struct super_block *sb); - void FAT_sync(struct super_block *sb); - u8 *buf_getblk(struct super_block *sb, u32 sec); - void buf_modify(struct super_block *sb, u32 sec); - void buf_lock(struct super_block *sb, u32 sec); - void buf_unlock(struct super_block *sb, u32 sec); - void buf_release(struct super_block *sb, u32 sec); - void buf_release_all(struct super_block *sb); - void buf_sync(struct super_block *sb); +/*----------------------------------------------------------------------*/ +/* External Function Declarations */ +/*----------------------------------------------------------------------*/ -#ifdef __cplusplus -} -#endif /* __cplusplus */ +s32 buf_init(struct super_block *sb); +s32 buf_shutdown(struct super_block *sb); +s32 FAT_read(struct super_block *sb, u32 loc, u32 *content); +s32 FAT_write(struct super_block *sb, u32 loc, u32 content); +u8 *FAT_getblk(struct super_block *sb, u32 sec); +void FAT_modify(struct super_block *sb, u32 sec); +void FAT_release_all(struct super_block *sb); +void FAT_sync(struct super_block *sb); +u8 *buf_getblk(struct super_block *sb, u32 sec); +void buf_modify(struct super_block *sb, u32 sec); +void buf_lock(struct super_block *sb, u32 sec); +void buf_unlock(struct super_block *sb, u32 sec); +void buf_release(struct super_block *sb, u32 sec); +void buf_release_all(struct super_block *sb); +void buf_sync(struct super_block *sb); #endif /* _EXFAT_CACHE_H */ diff --git a/exfat_config.h b/exfat_config.h index ba3e604..63f9e39 100644 --- a/exfat_config.h +++ b/exfat_config.h @@ -35,10 +35,6 @@ #ifndef _EXFAT_CONFIG_H #define _EXFAT_CONFIG_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - /*======================================================================*/ /* */ /* FFS CONFIGURATIONS */ @@ -110,10 +106,6 @@ extern "C" { #define CONFIG_EXFAT_DEFAULT_IOCHARSET "utf8" #endif -#ifdef __cplusplus -} -#endif /* __cplusplus */ - #endif /* _EXFAT_CONFIG_H */ /* end of exfat_config.h */ diff --git a/exfat_core.h b/exfat_core.h index 60d21dd..6962b43 100644 --- a/exfat_core.h +++ b/exfat_core.h @@ -45,10 +45,6 @@ #include "exfat_api.h" #include "exfat_cache.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #ifdef CONFIG_EXFAT_KERNEL_DEBUG /* For Debugging Purpose */ /* IOCTL code 'f' used by @@ -209,479 +205,475 @@ extern "C" { #define DPRINTK(...) #endif - static inline u16 get_col_index(u16 i) - { - return i >> LOW_INDEX_BIT; - } - static inline u16 get_row_index(u16 i) - { - return i & ~HIGH_INDEX_MASK; - } - /*----------------------------------------------------------------------*/ - /* Type Definitions */ - /*----------------------------------------------------------------------*/ +static inline u16 get_col_index(u16 i) +{ + return i >> LOW_INDEX_BIT; +} +static inline u16 get_row_index(u16 i) +{ + return i & ~HIGH_INDEX_MASK; +} +/*----------------------------------------------------------------------*/ +/* Type Definitions */ +/*----------------------------------------------------------------------*/ - /* MS_DOS FAT partition boot record (512 bytes) */ - typedef struct { - u8 jmp_boot[3]; - u8 oem_name[8]; - u8 bpb[109]; - u8 boot_code[390]; - u8 signature[2]; - } PBR_SECTOR_T; - - /* MS-DOS FAT12/16 BIOS parameter block (51 bytes) */ - typedef struct { - u8 sector_size[2]; - u8 sectors_per_clu; - u8 num_reserved[2]; - u8 num_fats; - u8 num_root_entries[2]; - u8 num_sectors[2]; - u8 media_type; - u8 num_fat_sectors[2]; - u8 sectors_in_track[2]; - u8 num_heads[2]; - u8 num_hid_sectors[4]; - u8 num_huge_sectors[4]; - - u8 phy_drv_no; - u8 reserved; - u8 ext_signature; - u8 vol_serial[4]; - u8 vol_label[11]; - u8 vol_type[8]; - } BPB16_T; - - /* MS-DOS FAT32 BIOS parameter block (79 bytes) */ - typedef struct { - u8 sector_size[2]; - u8 sectors_per_clu; - u8 num_reserved[2]; - u8 num_fats; - u8 num_root_entries[2]; - u8 num_sectors[2]; - u8 media_type; - u8 num_fat_sectors[2]; - u8 sectors_in_track[2]; - u8 num_heads[2]; - u8 num_hid_sectors[4]; - u8 num_huge_sectors[4]; - u8 num_fat32_sectors[4]; - u8 ext_flags[2]; - u8 fs_version[2]; - u8 root_cluster[4]; - u8 fsinfo_sector[2]; - u8 backup_sector[2]; - u8 reserved[12]; - - u8 phy_drv_no; - u8 ext_reserved; - u8 ext_signature; - u8 vol_serial[4]; - u8 vol_label[11]; - u8 vol_type[8]; - } BPB32_T; - - /* MS-DOS EXFAT BIOS parameter block (109 bytes) */ - typedef struct { - u8 reserved1[53]; - u8 vol_offset[8]; - u8 vol_length[8]; - u8 fat_offset[4]; - u8 fat_length[4]; - u8 clu_offset[4]; - u8 clu_count[4]; - u8 root_cluster[4]; - u8 vol_serial[4]; - u8 fs_version[2]; - u8 vol_flags[2]; - u8 sector_size_bits; - u8 sectors_per_clu_bits; - u8 num_fats; - u8 phy_drv_no; - u8 perc_in_use; - u8 reserved2[7]; - } BPBEX_T; - - /* MS-DOS FAT file system information sector (512 bytes) */ - typedef struct { - u8 signature1[4]; - u8 reserved1[480]; - u8 signature2[4]; - u8 free_cluster[4]; - u8 next_cluster[4]; - u8 reserved2[14]; - u8 signature3[2]; - } FSI_SECTOR_T; - - /* MS-DOS FAT directory entry (32 bytes) */ - typedef struct { - u8 dummy[32]; - } DENTRY_T; - - typedef struct { - u8 name[DOS_NAME_LENGTH]; - u8 attr; - u8 lcase; - u8 create_time_ms; - u8 create_time[2]; - u8 create_date[2]; - u8 access_date[2]; - u8 start_clu_hi[2]; - u8 modify_time[2]; - u8 modify_date[2]; - u8 start_clu_lo[2]; - u8 size[4]; - } DOS_DENTRY_T; - - /* MS-DOS FAT extended directory entry (32 bytes) */ - typedef struct { - u8 order; - u8 unicode_0_4[10]; - u8 attr; - u8 sysid; - u8 checksum; - u8 unicode_5_10[12]; - u8 start_clu[2]; - u8 unicode_11_12[4]; - } EXT_DENTRY_T; - - /* MS-DOS EXFAT file directory entry (32 bytes) */ - typedef struct { - u8 type; - u8 num_ext; - u8 checksum[2]; - u8 attr[2]; - u8 reserved1[2]; - u8 create_time[2]; - u8 create_date[2]; - u8 modify_time[2]; - u8 modify_date[2]; - u8 access_time[2]; - u8 access_date[2]; - u8 create_time_ms; - u8 modify_time_ms; - u8 access_time_ms; - u8 reserved2[9]; - } FILE_DENTRY_T; - - /* MS-DOS EXFAT stream extension directory entry (32 bytes) */ - typedef struct { - u8 type; - u8 flags; - u8 reserved1; - u8 name_len; - u8 name_hash[2]; - u8 reserved2[2]; - u8 valid_size[8]; - u8 reserved3[4]; - u8 start_clu[4]; - u8 size[8]; - } STRM_DENTRY_T; - - /* MS-DOS EXFAT file name directory entry (32 bytes) */ - typedef struct { - u8 type; - u8 flags; - u8 unicode_0_14[30]; - } NAME_DENTRY_T; - - /* MS-DOS EXFAT allocation bitmap directory entry (32 bytes) */ - typedef struct { - u8 type; - u8 flags; - u8 reserved[18]; - u8 start_clu[4]; - u8 size[8]; - } BMAP_DENTRY_T; - - /* MS-DOS EXFAT up-case table directory entry (32 bytes) */ - typedef struct { - u8 type; - u8 reserved1[3]; - u8 checksum[4]; - u8 reserved2[12]; - u8 start_clu[4]; - u8 size[8]; - } CASE_DENTRY_T; - - /* MS-DOS EXFAT volume label directory entry (32 bytes) */ - typedef struct { - u8 type; - u8 label_len; - u8 unicode_0_10[22]; - u8 reserved[8]; - } VOLM_DENTRY_T; - - /* unused entry hint information */ - typedef struct { - u32 dir; - s32 entry; - CHAIN_T clu; - } UENTRY_T; - - /* file system volume information structure */ - typedef struct __FS_STRUCT_T { - u32 mounted; - struct super_block *sb; - struct semaphore v_sem; - } FS_STRUCT_T; - - typedef struct { - s32 (*alloc_cluster)(struct super_block *sb, s32 num_alloc, CHAIN_T *p_chain); - void (*free_cluster)(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse); - s32 (*count_used_clusters)(struct super_block *sb); - - s32 (*init_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, - u32 start_clu, u64 size); - s32 (*init_ext_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 num_entries, - UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname); - s32 (*find_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type); - void (*delete_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 offset, s32 num_entries); - void (*get_uni_name_from_ext_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u16 *uniname); - s32 (*count_ext_entries)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, DENTRY_T *p_entry); - s32 (*calc_num_entries)(UNI_NAME_T *p_uniname); - - u32 (*get_entry_type)(DENTRY_T *p_entry); - void (*set_entry_type)(DENTRY_T *p_entry, u32 type); - u32 (*get_entry_attr)(DENTRY_T *p_entry); - void (*set_entry_attr)(DENTRY_T *p_entry, u32 attr); - u8 (*get_entry_flag)(DENTRY_T *p_entry); - void (*set_entry_flag)(DENTRY_T *p_entry, u8 flag); - u32 (*get_entry_clu0)(DENTRY_T *p_entry); - void (*set_entry_clu0)(DENTRY_T *p_entry, u32 clu0); - u64 (*get_entry_size)(DENTRY_T *p_entry); - void (*set_entry_size)(DENTRY_T *p_entry, u64 size); - void (*get_entry_time)(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); - void (*set_entry_time)(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); - } FS_FUNC_T; - - typedef struct __FS_INFO_T { - u32 drv; /* drive ID */ - u32 vol_type; /* volume FAT type */ - u32 vol_id; /* volume serial number */ - - u32 num_sectors; /* num of sectors in volume */ - u32 num_clusters; /* num of clusters in volume */ - u32 cluster_size; /* cluster size in bytes */ - u32 cluster_size_bits; - u32 sectors_per_clu; /* cluster size in sectors */ - u32 sectors_per_clu_bits; - - u32 PBR_sector; /* PBR sector */ - u32 FAT1_start_sector; /* FAT1 start sector */ - u32 FAT2_start_sector; /* FAT2 start sector */ - u32 root_start_sector; /* root dir start sector */ - u32 data_start_sector; /* data area start sector */ - u32 num_FAT_sectors; /* num of FAT sectors */ - - u32 root_dir; /* root dir cluster */ - u32 dentries_in_root; /* num of dentries in root dir */ - u32 dentries_per_clu; /* num of dentries per cluster */ - - u32 vol_flag; /* volume dirty flag */ - struct buffer_head *pbr_bh; /* PBR sector */ - - u32 map_clu; /* allocation bitmap start cluster */ - u32 map_sectors; /* num of allocation bitmap sectors */ - struct buffer_head **vol_amap; /* allocation bitmap */ - - u16 **vol_utbl; /* upcase table */ - - u32 clu_srch_ptr; /* cluster search pointer */ - u32 used_clusters; /* number of used clusters */ - UENTRY_T hint_uentry; /* unused entry hint information */ - - u32 dev_ejected; /* block device operation error flag */ - - FS_FUNC_T *fs_func; - - /* FAT cache */ - BUF_CACHE_T FAT_cache_array[FAT_CACHE_SIZE]; - BUF_CACHE_T FAT_cache_lru_list; - BUF_CACHE_T FAT_cache_hash_list[FAT_CACHE_HASH_SIZE]; - - /* buf cache */ - BUF_CACHE_T buf_cache_array[BUF_CACHE_SIZE]; - BUF_CACHE_T buf_cache_lru_list; - BUF_CACHE_T buf_cache_hash_list[BUF_CACHE_HASH_SIZE]; - } FS_INFO_T; +/* MS_DOS FAT partition boot record (512 bytes) */ +typedef struct { + u8 jmp_boot[3]; + u8 oem_name[8]; + u8 bpb[109]; + u8 boot_code[390]; + u8 signature[2]; +} PBR_SECTOR_T; + +/* MS-DOS FAT12/16 BIOS parameter block (51 bytes) */ +typedef struct { + u8 sector_size[2]; + u8 sectors_per_clu; + u8 num_reserved[2]; + u8 num_fats; + u8 num_root_entries[2]; + u8 num_sectors[2]; + u8 media_type; + u8 num_fat_sectors[2]; + u8 sectors_in_track[2]; + u8 num_heads[2]; + u8 num_hid_sectors[4]; + u8 num_huge_sectors[4]; + + u8 phy_drv_no; + u8 reserved; + u8 ext_signature; + u8 vol_serial[4]; + u8 vol_label[11]; + u8 vol_type[8]; +} BPB16_T; + +/* MS-DOS FAT32 BIOS parameter block (79 bytes) */ +typedef struct { + u8 sector_size[2]; + u8 sectors_per_clu; + u8 num_reserved[2]; + u8 num_fats; + u8 num_root_entries[2]; + u8 num_sectors[2]; + u8 media_type; + u8 num_fat_sectors[2]; + u8 sectors_in_track[2]; + u8 num_heads[2]; + u8 num_hid_sectors[4]; + u8 num_huge_sectors[4]; + u8 num_fat32_sectors[4]; + u8 ext_flags[2]; + u8 fs_version[2]; + u8 root_cluster[4]; + u8 fsinfo_sector[2]; + u8 backup_sector[2]; + u8 reserved[12]; + + u8 phy_drv_no; + u8 ext_reserved; + u8 ext_signature; + u8 vol_serial[4]; + u8 vol_label[11]; + u8 vol_type[8]; +} BPB32_T; + +/* MS-DOS EXFAT BIOS parameter block (109 bytes) */ +typedef struct { + u8 reserved1[53]; + u8 vol_offset[8]; + u8 vol_length[8]; + u8 fat_offset[4]; + u8 fat_length[4]; + u8 clu_offset[4]; + u8 clu_count[4]; + u8 root_cluster[4]; + u8 vol_serial[4]; + u8 fs_version[2]; + u8 vol_flags[2]; + u8 sector_size_bits; + u8 sectors_per_clu_bits; + u8 num_fats; + u8 phy_drv_no; + u8 perc_in_use; + u8 reserved2[7]; +} BPBEX_T; + +/* MS-DOS FAT file system information sector (512 bytes) */ +typedef struct { + u8 signature1[4]; + u8 reserved1[480]; + u8 signature2[4]; + u8 free_cluster[4]; + u8 next_cluster[4]; + u8 reserved2[14]; + u8 signature3[2]; +} FSI_SECTOR_T; + +/* MS-DOS FAT directory entry (32 bytes) */ +typedef struct { + u8 dummy[32]; +} DENTRY_T; + +typedef struct { + u8 name[DOS_NAME_LENGTH]; + u8 attr; + u8 lcase; + u8 create_time_ms; + u8 create_time[2]; + u8 create_date[2]; + u8 access_date[2]; + u8 start_clu_hi[2]; + u8 modify_time[2]; + u8 modify_date[2]; + u8 start_clu_lo[2]; + u8 size[4]; +} DOS_DENTRY_T; + +/* MS-DOS FAT extended directory entry (32 bytes) */ +typedef struct { + u8 order; + u8 unicode_0_4[10]; + u8 attr; + u8 sysid; + u8 checksum; + u8 unicode_5_10[12]; + u8 start_clu[2]; + u8 unicode_11_12[4]; +} EXT_DENTRY_T; + +/* MS-DOS EXFAT file directory entry (32 bytes) */ +typedef struct { + u8 type; + u8 num_ext; + u8 checksum[2]; + u8 attr[2]; + u8 reserved1[2]; + u8 create_time[2]; + u8 create_date[2]; + u8 modify_time[2]; + u8 modify_date[2]; + u8 access_time[2]; + u8 access_date[2]; + u8 create_time_ms; + u8 modify_time_ms; + u8 access_time_ms; + u8 reserved2[9]; +} FILE_DENTRY_T; + +/* MS-DOS EXFAT stream extension directory entry (32 bytes) */ +typedef struct { + u8 type; + u8 flags; + u8 reserved1; + u8 name_len; + u8 name_hash[2]; + u8 reserved2[2]; + u8 valid_size[8]; + u8 reserved3[4]; + u8 start_clu[4]; + u8 size[8]; +} STRM_DENTRY_T; + +/* MS-DOS EXFAT file name directory entry (32 bytes) */ +typedef struct { + u8 type; + u8 flags; + u8 unicode_0_14[30]; +} NAME_DENTRY_T; + +/* MS-DOS EXFAT allocation bitmap directory entry (32 bytes) */ +typedef struct { + u8 type; + u8 flags; + u8 reserved[18]; + u8 start_clu[4]; + u8 size[8]; +} BMAP_DENTRY_T; + +/* MS-DOS EXFAT up-case table directory entry (32 bytes) */ +typedef struct { + u8 type; + u8 reserved1[3]; + u8 checksum[4]; + u8 reserved2[12]; + u8 start_clu[4]; + u8 size[8]; +} CASE_DENTRY_T; + +/* MS-DOS EXFAT volume label directory entry (32 bytes) */ +typedef struct { + u8 type; + u8 label_len; + u8 unicode_0_10[22]; + u8 reserved[8]; +} VOLM_DENTRY_T; + +/* unused entry hint information */ +typedef struct { + u32 dir; + s32 entry; + CHAIN_T clu; +} UENTRY_T; + +/* file system volume information structure */ +typedef struct __FS_STRUCT_T { + u32 mounted; + struct super_block *sb; + struct semaphore v_sem; +} FS_STRUCT_T; + +typedef struct { + s32 (*alloc_cluster)(struct super_block *sb, s32 num_alloc, CHAIN_T *p_chain); + void (*free_cluster)(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse); + s32 (*count_used_clusters)(struct super_block *sb); + + s32 (*init_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, + u32 start_clu, u64 size); + s32 (*init_ext_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 num_entries, + UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname); + s32 (*find_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type); + void (*delete_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 offset, s32 num_entries); + void (*get_uni_name_from_ext_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u16 *uniname); + s32 (*count_ext_entries)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, DENTRY_T *p_entry); + s32 (*calc_num_entries)(UNI_NAME_T *p_uniname); + + u32 (*get_entry_type)(DENTRY_T *p_entry); + void (*set_entry_type)(DENTRY_T *p_entry, u32 type); + u32 (*get_entry_attr)(DENTRY_T *p_entry); + void (*set_entry_attr)(DENTRY_T *p_entry, u32 attr); + u8 (*get_entry_flag)(DENTRY_T *p_entry); + void (*set_entry_flag)(DENTRY_T *p_entry, u8 flag); + u32 (*get_entry_clu0)(DENTRY_T *p_entry); + void (*set_entry_clu0)(DENTRY_T *p_entry, u32 clu0); + u64 (*get_entry_size)(DENTRY_T *p_entry); + void (*set_entry_size)(DENTRY_T *p_entry, u64 size); + void (*get_entry_time)(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); + void (*set_entry_time)(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); +} FS_FUNC_T; + +typedef struct __FS_INFO_T { + u32 drv; /* drive ID */ + u32 vol_type; /* volume FAT type */ + u32 vol_id; /* volume serial number */ + + u32 num_sectors; /* num of sectors in volume */ + u32 num_clusters; /* num of clusters in volume */ + u32 cluster_size; /* cluster size in bytes */ + u32 cluster_size_bits; + u32 sectors_per_clu; /* cluster size in sectors */ + u32 sectors_per_clu_bits; + + u32 PBR_sector; /* PBR sector */ + u32 FAT1_start_sector; /* FAT1 start sector */ + u32 FAT2_start_sector; /* FAT2 start sector */ + u32 root_start_sector; /* root dir start sector */ + u32 data_start_sector; /* data area start sector */ + u32 num_FAT_sectors; /* num of FAT sectors */ + + u32 root_dir; /* root dir cluster */ + u32 dentries_in_root; /* num of dentries in root dir */ + u32 dentries_per_clu; /* num of dentries per cluster */ + + u32 vol_flag; /* volume dirty flag */ + struct buffer_head *pbr_bh; /* PBR sector */ + + u32 map_clu; /* allocation bitmap start cluster */ + u32 map_sectors; /* num of allocation bitmap sectors */ + struct buffer_head **vol_amap; /* allocation bitmap */ + + u16 **vol_utbl; /* upcase table */ + + u32 clu_srch_ptr; /* cluster search pointer */ + u32 used_clusters; /* number of used clusters */ + UENTRY_T hint_uentry; /* unused entry hint information */ + + u32 dev_ejected; /* block device operation error flag */ + + FS_FUNC_T *fs_func; + + /* FAT cache */ + BUF_CACHE_T FAT_cache_array[FAT_CACHE_SIZE]; + BUF_CACHE_T FAT_cache_lru_list; + BUF_CACHE_T FAT_cache_hash_list[FAT_CACHE_HASH_SIZE]; + + /* buf cache */ + BUF_CACHE_T buf_cache_array[BUF_CACHE_SIZE]; + BUF_CACHE_T buf_cache_lru_list; + BUF_CACHE_T buf_cache_hash_list[BUF_CACHE_HASH_SIZE]; +} FS_INFO_T; #define ES_2_ENTRIES 2 #define ES_3_ENTRIES 3 #define ES_ALL_ENTRIES 0 - typedef struct { - u32 sector; /* sector number that contains file_entry */ - s32 offset; /* byte offset in the sector */ - s32 alloc_flag; /* flag in stream entry. 01 for cluster chain, 03 for contig. clusteres. */ - u32 num_entries; +typedef struct { + u32 sector; /* sector number that contains file_entry */ + s32 offset; /* byte offset in the sector */ + s32 alloc_flag; /* flag in stream entry. 01 for cluster chain, 03 for contig. clusteres. */ + u32 num_entries; - /* __buf should be the last member */ - void *__buf; - } ENTRY_SET_CACHE_T; + /* __buf should be the last member */ + void *__buf; +} ENTRY_SET_CACHE_T; - /*----------------------------------------------------------------------*/ - /* External Function Declarations */ - /*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* External Function Declarations */ +/*----------------------------------------------------------------------*/ - /* file system initialization & shutdown functions */ - s32 ffsInit(void); - s32 ffsShutdown(void); - - /* volume management functions */ - s32 ffsMountVol(struct super_block *sb, s32 drv); - s32 ffsUmountVol(struct super_block *sb); - s32 ffsCheckVol(struct super_block *sb); - s32 ffsGetVolInfo(struct super_block *sb, VOL_INFO_T *info); - s32 ffsSyncVol(struct super_block *sb, s32 do_sync); - - /* file management functions */ - s32 ffsLookupFile(struct inode *inode, char *path, FILE_ID_T *fid); - s32 ffsCreateFile(struct inode *inode, char *path, u8 mode, FILE_ID_T *fid); - s32 ffsReadFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *rcount); - s32 ffsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *wcount); - s32 ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size); - s32 ffsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry); - s32 ffsRemoveFile(struct inode *inode, FILE_ID_T *fid); - s32 ffsSetAttr(struct inode *inode, u32 attr); - s32 ffsGetStat(struct inode *inode, DIR_ENTRY_T *info); - s32 ffsSetStat(struct inode *inode, DIR_ENTRY_T *info); - s32 ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu); - - /* directory management functions */ - s32 ffsCreateDir(struct inode *inode, char *path, FILE_ID_T *fid); - s32 ffsReadDir(struct inode *inode, DIR_ENTRY_T *dir_ent); - s32 ffsRemoveDir(struct inode *inode, FILE_ID_T *fid); +/* file system initialization & shutdown functions */ +s32 ffsInit(void); +s32 ffsShutdown(void); + +/* volume management functions */ +s32 ffsMountVol(struct super_block *sb, s32 drv); +s32 ffsUmountVol(struct super_block *sb); +s32 ffsCheckVol(struct super_block *sb); +s32 ffsGetVolInfo(struct super_block *sb, VOL_INFO_T *info); +s32 ffsSyncVol(struct super_block *sb, s32 do_sync); + +/* file management functions */ +s32 ffsLookupFile(struct inode *inode, char *path, FILE_ID_T *fid); +s32 ffsCreateFile(struct inode *inode, char *path, u8 mode, FILE_ID_T *fid); +s32 ffsReadFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *rcount); +s32 ffsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *wcount); +s32 ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size); +s32 ffsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry); +s32 ffsRemoveFile(struct inode *inode, FILE_ID_T *fid); +s32 ffsSetAttr(struct inode *inode, u32 attr); +s32 ffsGetStat(struct inode *inode, DIR_ENTRY_T *info); +s32 ffsSetStat(struct inode *inode, DIR_ENTRY_T *info); +s32 ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu); + +/* directory management functions */ +s32 ffsCreateDir(struct inode *inode, char *path, FILE_ID_T *fid); +s32 ffsReadDir(struct inode *inode, DIR_ENTRY_T *dir_ent); +s32 ffsRemoveDir(struct inode *inode, FILE_ID_T *fid); - /*----------------------------------------------------------------------*/ - /* External Function Declarations (NOT TO UPPER LAYER) */ - /*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* External Function Declarations (NOT TO UPPER LAYER) */ +/*----------------------------------------------------------------------*/ - /* fs management functions */ - s32 fs_init(void); - s32 fs_shutdown(void); - void fs_set_vol_flags(struct super_block *sb, u32 new_flag); - void fs_sync(struct super_block *sb, s32 do_sync); - void fs_error(struct super_block *sb); - - /* cluster management functions */ - s32 clear_cluster(struct super_block *sb, u32 clu); - s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, CHAIN_T *p_chain); - s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, CHAIN_T *p_chain); - void fat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse); - void exfat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse); - u32 find_last_cluster(struct super_block *sb, CHAIN_T *p_chain); - s32 count_num_clusters(struct super_block *sb, CHAIN_T *dir); - s32 fat_count_used_clusters(struct super_block *sb); - s32 exfat_count_used_clusters(struct super_block *sb); - void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len); - - /* allocation bitmap management functions */ - s32 load_alloc_bitmap(struct super_block *sb); - void free_alloc_bitmap(struct super_block *sb); - s32 set_alloc_bitmap(struct super_block *sb, u32 clu); - s32 clr_alloc_bitmap(struct super_block *sb, u32 clu); - u32 test_alloc_bitmap(struct super_block *sb, u32 clu); - void sync_alloc_bitmap(struct super_block *sb); - - /* upcase table management functions */ - s32 load_upcase_table(struct super_block *sb); - void free_upcase_table(struct super_block *sb); - - /* dir entry management functions */ - u32 fat_get_entry_type(DENTRY_T *p_entry); - u32 exfat_get_entry_type(DENTRY_T *p_entry); - void fat_set_entry_type(DENTRY_T *p_entry, u32 type); - void exfat_set_entry_type(DENTRY_T *p_entry, u32 type); - u32 fat_get_entry_attr(DENTRY_T *p_entry); - u32 exfat_get_entry_attr(DENTRY_T *p_entry); - void fat_set_entry_attr(DENTRY_T *p_entry, u32 attr); - void exfat_set_entry_attr(DENTRY_T *p_entry, u32 attr); - u8 fat_get_entry_flag(DENTRY_T *p_entry); - u8 exfat_get_entry_flag(DENTRY_T *p_entry); - void fat_set_entry_flag(DENTRY_T *p_entry, u8 flag); - void exfat_set_entry_flag(DENTRY_T *p_entry, u8 flag); - u32 fat_get_entry_clu0(DENTRY_T *p_entry); - u32 exfat_get_entry_clu0(DENTRY_T *p_entry); - void fat_set_entry_clu0(DENTRY_T *p_entry, u32 start_clu); - void exfat_set_entry_clu0(DENTRY_T *p_entry, u32 start_clu); - u64 fat_get_entry_size(DENTRY_T *p_entry); - u64 exfat_get_entry_size(DENTRY_T *p_entry); - void fat_set_entry_size(DENTRY_T *p_entry, u64 size); - void exfat_set_entry_size(DENTRY_T *p_entry, u64 size); - void fat_get_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); - void exfat_get_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); - void fat_set_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); - void exfat_set_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); - s32 fat_init_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, u32 start_clu, u64 size); - s32 exfat_init_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, u32 start_clu, u64 size); - s32 fat_init_ext_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 num_entries, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname); - s32 exfat_init_ext_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 num_entries, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname); - void init_dos_entry(DOS_DENTRY_T *ep, u32 type, u32 start_clu); - void init_ext_entry(EXT_DENTRY_T *ep, s32 order, u8 chksum, u16 *uniname); - void init_file_entry(FILE_DENTRY_T *ep, u32 type); - void init_strm_entry(STRM_DENTRY_T *ep, u8 flags, u32 start_clu, u64 size); - void init_name_entry(NAME_DENTRY_T *ep, u16 *uniname); - void fat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 order, s32 num_entries); - void exfat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 order, s32 num_entries); - - s32 find_location(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 *sector, s32 *offset); - DENTRY_T *get_entry_with_sector(struct super_block *sb, u32 sector, s32 offset); - DENTRY_T *get_entry_in_dir(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 *sector); - ENTRY_SET_CACHE_T *get_entry_set_in_dir(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, DENTRY_T **file_ep); - void release_entry_set(ENTRY_SET_CACHE_T *es); - s32 write_whole_entry_set(struct super_block *sb, ENTRY_SET_CACHE_T *es); - s32 write_partial_entries_in_entry_set(struct super_block *sb, ENTRY_SET_CACHE_T *es, DENTRY_T *ep, u32 count); - s32 search_deleted_or_unused_entry(struct super_block *sb, CHAIN_T *p_dir, s32 num_entries); - s32 find_empty_entry(struct inode *inode, CHAIN_T *p_dir, s32 num_entries); - s32 fat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type); - s32 exfat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type); - s32 fat_count_ext_entries(struct super_block *sb, CHAIN_T *p_dir, s32 entry, DENTRY_T *p_entry); - s32 exfat_count_ext_entries(struct super_block *sb, CHAIN_T *p_dir, s32 entry, DENTRY_T *p_entry); - s32 count_dos_name_entries(struct super_block *sb, CHAIN_T *p_dir, u32 type); - void update_dir_checksum(struct super_block *sb, CHAIN_T *p_dir, s32 entry); - void update_dir_checksum_with_entry_set(struct super_block *sb, ENTRY_SET_CACHE_T *es); - bool is_dir_empty(struct super_block *sb, CHAIN_T *p_dir); - - /* name conversion functions */ - s32 get_num_entries_and_dos_name(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 *entries, DOS_NAME_T *p_dosname); - void get_uni_name_from_dos_entry(struct super_block *sb, DOS_DENTRY_T *ep, UNI_NAME_T *p_uniname, u8 mode); - void fat_get_uni_name_from_ext_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u16 *uniname); - void exfat_get_uni_name_from_ext_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u16 *uniname); - s32 extract_uni_name_from_ext_entry(EXT_DENTRY_T *ep, u16 *uniname, s32 order); - s32 extract_uni_name_from_name_entry(NAME_DENTRY_T *ep, u16 *uniname, s32 order); - s32 fat_generate_dos_name(struct super_block *sb, CHAIN_T *p_dir, DOS_NAME_T *p_dosname); - void fat_attach_count_to_dos_name(u8 *dosname, s32 count); - s32 fat_calc_num_entries(UNI_NAME_T *p_uniname); - s32 exfat_calc_num_entries(UNI_NAME_T *p_uniname); - u8 calc_checksum_1byte(void *data, s32 len, u8 chksum); - u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type); - u32 calc_checksum_4byte(void *data, s32 len, u32 chksum, s32 type); - - /* name resolution functions */ - s32 resolve_path(struct inode *inode, char *path, CHAIN_T *p_dir, UNI_NAME_T *p_uniname); - s32 resolve_name(u8 *name, u8 **arg); - - /* file operation functions */ - s32 fat16_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr); - s32 fat32_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr); - s32 exfat_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr); - s32 create_dir(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, FILE_ID_T *fid); - s32 create_file(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, u8 mode, FILE_ID_T *fid); - void remove_file(struct inode *inode, CHAIN_T *p_dir, s32 entry); - s32 rename_file(struct inode *inode, CHAIN_T *p_dir, s32 old_entry, UNI_NAME_T *p_uniname, FILE_ID_T *fid); - s32 move_file(struct inode *inode, CHAIN_T *p_olddir, s32 oldentry, CHAIN_T *p_newdir, UNI_NAME_T *p_uniname, FILE_ID_T *fid); - - /* sector read/write functions */ - s32 sector_read(struct super_block *sb, u32 sec, struct buffer_head **bh, s32 read); - s32 sector_write(struct super_block *sb, u32 sec, struct buffer_head *bh, s32 sync); - s32 multi_sector_read(struct super_block *sb, u32 sec, struct buffer_head **bh, s32 num_secs, s32 read); - s32 multi_sector_write(struct super_block *sb, u32 sec, struct buffer_head *bh, s32 num_secs, s32 sync); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ +/* fs management functions */ +s32 fs_init(void); +s32 fs_shutdown(void); +void fs_set_vol_flags(struct super_block *sb, u32 new_flag); +void fs_sync(struct super_block *sb, s32 do_sync); +void fs_error(struct super_block *sb); + +/* cluster management functions */ +s32 clear_cluster(struct super_block *sb, u32 clu); +s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, CHAIN_T *p_chain); +s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, CHAIN_T *p_chain); +void fat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse); +void exfat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse); +u32 find_last_cluster(struct super_block *sb, CHAIN_T *p_chain); +s32 count_num_clusters(struct super_block *sb, CHAIN_T *dir); +s32 fat_count_used_clusters(struct super_block *sb); +s32 exfat_count_used_clusters(struct super_block *sb); +void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len); + +/* allocation bitmap management functions */ +s32 load_alloc_bitmap(struct super_block *sb); +void free_alloc_bitmap(struct super_block *sb); +s32 set_alloc_bitmap(struct super_block *sb, u32 clu); +s32 clr_alloc_bitmap(struct super_block *sb, u32 clu); +u32 test_alloc_bitmap(struct super_block *sb, u32 clu); +void sync_alloc_bitmap(struct super_block *sb); + +/* upcase table management functions */ +s32 load_upcase_table(struct super_block *sb); +void free_upcase_table(struct super_block *sb); + +/* dir entry management functions */ +u32 fat_get_entry_type(DENTRY_T *p_entry); +u32 exfat_get_entry_type(DENTRY_T *p_entry); +void fat_set_entry_type(DENTRY_T *p_entry, u32 type); +void exfat_set_entry_type(DENTRY_T *p_entry, u32 type); +u32 fat_get_entry_attr(DENTRY_T *p_entry); +u32 exfat_get_entry_attr(DENTRY_T *p_entry); +void fat_set_entry_attr(DENTRY_T *p_entry, u32 attr); +void exfat_set_entry_attr(DENTRY_T *p_entry, u32 attr); +u8 fat_get_entry_flag(DENTRY_T *p_entry); +u8 exfat_get_entry_flag(DENTRY_T *p_entry); +void fat_set_entry_flag(DENTRY_T *p_entry, u8 flag); +void exfat_set_entry_flag(DENTRY_T *p_entry, u8 flag); +u32 fat_get_entry_clu0(DENTRY_T *p_entry); +u32 exfat_get_entry_clu0(DENTRY_T *p_entry); +void fat_set_entry_clu0(DENTRY_T *p_entry, u32 start_clu); +void exfat_set_entry_clu0(DENTRY_T *p_entry, u32 start_clu); +u64 fat_get_entry_size(DENTRY_T *p_entry); +u64 exfat_get_entry_size(DENTRY_T *p_entry); +void fat_set_entry_size(DENTRY_T *p_entry, u64 size); +void exfat_set_entry_size(DENTRY_T *p_entry, u64 size); +void fat_get_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); +void exfat_get_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); +void fat_set_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); +void exfat_set_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode); +s32 fat_init_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, u32 start_clu, u64 size); +s32 exfat_init_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, u32 start_clu, u64 size); +s32 fat_init_ext_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 num_entries, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname); +s32 exfat_init_ext_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 num_entries, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname); +void init_dos_entry(DOS_DENTRY_T *ep, u32 type, u32 start_clu); +void init_ext_entry(EXT_DENTRY_T *ep, s32 order, u8 chksum, u16 *uniname); +void init_file_entry(FILE_DENTRY_T *ep, u32 type); +void init_strm_entry(STRM_DENTRY_T *ep, u8 flags, u32 start_clu, u64 size); +void init_name_entry(NAME_DENTRY_T *ep, u16 *uniname); +void fat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 order, s32 num_entries); +void exfat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 order, s32 num_entries); + +s32 find_location(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 *sector, s32 *offset); +DENTRY_T *get_entry_with_sector(struct super_block *sb, u32 sector, s32 offset); +DENTRY_T *get_entry_in_dir(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 *sector); +ENTRY_SET_CACHE_T *get_entry_set_in_dir(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, DENTRY_T **file_ep); +void release_entry_set(ENTRY_SET_CACHE_T *es); +s32 write_whole_entry_set(struct super_block *sb, ENTRY_SET_CACHE_T *es); +s32 write_partial_entries_in_entry_set(struct super_block *sb, ENTRY_SET_CACHE_T *es, DENTRY_T *ep, u32 count); +s32 search_deleted_or_unused_entry(struct super_block *sb, CHAIN_T *p_dir, s32 num_entries); +s32 find_empty_entry(struct inode *inode, CHAIN_T *p_dir, s32 num_entries); +s32 fat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type); +s32 exfat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type); +s32 fat_count_ext_entries(struct super_block *sb, CHAIN_T *p_dir, s32 entry, DENTRY_T *p_entry); +s32 exfat_count_ext_entries(struct super_block *sb, CHAIN_T *p_dir, s32 entry, DENTRY_T *p_entry); +s32 count_dos_name_entries(struct super_block *sb, CHAIN_T *p_dir, u32 type); +void update_dir_checksum(struct super_block *sb, CHAIN_T *p_dir, s32 entry); +void update_dir_checksum_with_entry_set(struct super_block *sb, ENTRY_SET_CACHE_T *es); +bool is_dir_empty(struct super_block *sb, CHAIN_T *p_dir); + +/* name conversion functions */ +s32 get_num_entries_and_dos_name(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 *entries, DOS_NAME_T *p_dosname); +void get_uni_name_from_dos_entry(struct super_block *sb, DOS_DENTRY_T *ep, UNI_NAME_T *p_uniname, u8 mode); +void fat_get_uni_name_from_ext_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u16 *uniname); +void exfat_get_uni_name_from_ext_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u16 *uniname); +s32 extract_uni_name_from_ext_entry(EXT_DENTRY_T *ep, u16 *uniname, s32 order); +s32 extract_uni_name_from_name_entry(NAME_DENTRY_T *ep, u16 *uniname, s32 order); +s32 fat_generate_dos_name(struct super_block *sb, CHAIN_T *p_dir, DOS_NAME_T *p_dosname); +void fat_attach_count_to_dos_name(u8 *dosname, s32 count); +s32 fat_calc_num_entries(UNI_NAME_T *p_uniname); +s32 exfat_calc_num_entries(UNI_NAME_T *p_uniname); +u8 calc_checksum_1byte(void *data, s32 len, u8 chksum); +u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type); +u32 calc_checksum_4byte(void *data, s32 len, u32 chksum, s32 type); + +/* name resolution functions */ +s32 resolve_path(struct inode *inode, char *path, CHAIN_T *p_dir, UNI_NAME_T *p_uniname); +s32 resolve_name(u8 *name, u8 **arg); + +/* file operation functions */ +s32 fat16_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr); +s32 fat32_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr); +s32 exfat_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr); +s32 create_dir(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, FILE_ID_T *fid); +s32 create_file(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, u8 mode, FILE_ID_T *fid); +void remove_file(struct inode *inode, CHAIN_T *p_dir, s32 entry); +s32 rename_file(struct inode *inode, CHAIN_T *p_dir, s32 old_entry, UNI_NAME_T *p_uniname, FILE_ID_T *fid); +s32 move_file(struct inode *inode, CHAIN_T *p_olddir, s32 oldentry, CHAIN_T *p_newdir, UNI_NAME_T *p_uniname, FILE_ID_T *fid); + +/* sector read/write functions */ +s32 sector_read(struct super_block *sb, u32 sec, struct buffer_head **bh, s32 read); +s32 sector_write(struct super_block *sb, u32 sec, struct buffer_head *bh, s32 sync); +s32 multi_sector_read(struct super_block *sb, u32 sec, struct buffer_head **bh, s32 num_secs, s32 read); +s32 multi_sector_write(struct super_block *sb, u32 sec, struct buffer_head *bh, s32 num_secs, s32 sync); #endif /* _EXFAT_H */ diff --git a/exfat_data.h b/exfat_data.h index 5e53802..2316e43 100644 --- a/exfat_data.h +++ b/exfat_data.h @@ -37,16 +37,12 @@ #include "exfat_config.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - /*======================================================================*/ - /* */ - /* FFS CONFIGURATIONS */ - /* (CHANGE THIS PART IF REQUIRED) */ - /* */ - /*======================================================================*/ +/*======================================================================*/ +/* */ +/* FFS CONFIGURATIONS */ +/* (CHANGE THIS PART IF REQUIRED) */ +/* */ +/*======================================================================*/ /* max number of block devices */ #define MAX_DEVICE 2 @@ -68,10 +64,6 @@ extern "C" { #define BUF_CACHE_SIZE 256 #define BUF_CACHE_HASH_SIZE 64 -#ifdef __cplusplus -} -#endif /* __cplusplus */ - #endif /* _EXFAT_DATA_H */ /* end of exfat_data.h */ diff --git a/exfat_nls.h b/exfat_nls.h index a7ac347..1ed8d10 100644 --- a/exfat_nls.h +++ b/exfat_nls.h @@ -40,13 +40,9 @@ #include "exfat_config.h" #include "exfat_api.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - /*----------------------------------------------------------------------*/ - /* Constant & Macro Definitions */ - /*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* Constant & Macro Definitions */ +/*----------------------------------------------------------------------*/ #define NUM_UPCASE 2918 @@ -91,10 +87,6 @@ void nls_dosname_to_uniname(struct super_block *sb, UNI_NAME_T *p_uniname, DOS void nls_uniname_to_cstring(struct super_block *sb, u8 *p_cstring, UNI_NAME_T *p_uniname); void nls_cstring_to_uniname(struct super_block *sb, UNI_NAME_T *p_uniname, u8 *p_cstring, s32 *p_lossy); -#ifdef __cplusplus -} -#endif /* __cplusplus */ - #endif /* _EXFAT_NLS_H */ /* end of exfat_nls.h */ diff --git a/exfat_oal.h b/exfat_oal.h index e1766cd..b9ad234 100644 --- a/exfat_oal.h +++ b/exfat_oal.h @@ -40,44 +40,36 @@ #include "exfat_config.h" #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - /*----------------------------------------------------------------------*/ - /* Constant & Macro Definitions (Configurable) */ - /*----------------------------------------------------------------------*/ - - /*----------------------------------------------------------------------*/ - /* Constant & Macro Definitions (Non-Configurable) */ - /*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* Constant & Macro Definitions (Configurable) */ +/*----------------------------------------------------------------------*/ - /*----------------------------------------------------------------------*/ - /* Type Definitions */ - /*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* Constant & Macro Definitions (Non-Configurable) */ +/*----------------------------------------------------------------------*/ - typedef struct { - u16 sec; /* 0 ~ 59 */ - u16 min; /* 0 ~ 59 */ - u16 hour; /* 0 ~ 23 */ - u16 day; /* 1 ~ 31 */ - u16 mon; /* 1 ~ 12 */ - u16 year; /* 0 ~ 127 (since 1980) */ - } TIMESTAMP_T; +/*----------------------------------------------------------------------*/ +/* Type Definitions */ +/*----------------------------------------------------------------------*/ - /*----------------------------------------------------------------------*/ - /* External Function Declarations */ - /*----------------------------------------------------------------------*/ +typedef struct { + u16 sec; /* 0 ~ 59 */ + u16 min; /* 0 ~ 59 */ + u16 hour; /* 0 ~ 23 */ + u16 day; /* 1 ~ 31 */ + u16 mon; /* 1 ~ 12 */ + u16 year; /* 0 ~ 127 (since 1980) */ +} TIMESTAMP_T; - s32 sm_init(struct semaphore *sm); - s32 sm_P(struct semaphore *sm); - void sm_V(struct semaphore *sm); +/*----------------------------------------------------------------------*/ +/* External Function Declarations */ +/*----------------------------------------------------------------------*/ - TIMESTAMP_T *tm_current(TIMESTAMP_T *tm); +s32 sm_init(struct semaphore *sm); +s32 sm_P(struct semaphore *sm); +void sm_V(struct semaphore *sm); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +TIMESTAMP_T *tm_current(TIMESTAMP_T *tm); #endif /* _EXFAT_OAL_H */