exfat.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*
  2. * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef _EXFAT_H
  19. #define _EXFAT_H
  20. #include "exfat_config.h"
  21. #include "exfat_global.h"
  22. #include "exfat_data.h"
  23. #include "exfat_oal.h"
  24. #include "exfat_blkdev.h"
  25. #include "exfat_cache.h"
  26. #include "exfat_nls.h"
  27. #include "exfat_api.h"
  28. #include "exfat_cache.h"
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #if EXFAT_CONFIG_KERNEL_DEBUG
  33. #define EXFAT_IOC_GET_DEBUGFLAGS _IOR('f', 100, long)
  34. #define EXFAT_IOC_SET_DEBUGFLAGS _IOW('f', 101, long)
  35. #define EXFAT_DEBUGFLAGS_INVALID_UMOUNT 0x01
  36. #define EXFAT_DEBUGFLAGS_ERROR_RW 0x02
  37. #endif
  38. #define MAX_VOLUME 4
  39. #define DENTRY_SIZE 32
  40. #define DENTRY_SIZE_BITS 5
  41. #define PBR_SIGNATURE 0xAA55
  42. #define EXT_SIGNATURE 0xAA550000
  43. #define VOL_LABEL "NO NAME "
  44. #define OEM_NAME "MSWIN4.1"
  45. #define STR_FAT12 "FAT12 "
  46. #define STR_FAT16 "FAT16 "
  47. #define STR_FAT32 "FAT32 "
  48. #define STR_EXFAT "EXFAT "
  49. #define VOL_CLEAN 0x0000
  50. #define VOL_DIRTY 0x0002
  51. #define FAT12_THRESHOLD 4087
  52. #define FAT16_THRESHOLD 65527
  53. #define FAT32_THRESHOLD 268435457
  54. #define EXFAT_THRESHOLD 268435457
  55. #define TYPE_UNUSED 0x0000
  56. #define TYPE_DELETED 0x0001
  57. #define TYPE_INVALID 0x0002
  58. #define TYPE_CRITICAL_PRI 0x0100
  59. #define TYPE_BITMAP 0x0101
  60. #define TYPE_UPCASE 0x0102
  61. #define TYPE_VOLUME 0x0103
  62. #define TYPE_DIR 0x0104
  63. #define TYPE_FILE 0x011F
  64. #define TYPE_SYMLINK 0x015F
  65. #define TYPE_CRITICAL_SEC 0x0200
  66. #define TYPE_STREAM 0x0201
  67. #define TYPE_EXTEND 0x0202
  68. #define TYPE_ACL 0x0203
  69. #define TYPE_BENIGN_PRI 0x0400
  70. #define TYPE_GUID 0x0401
  71. #define TYPE_PADDING 0x0402
  72. #define TYPE_ACLTAB 0x0403
  73. #define TYPE_BENIGN_SEC 0x0800
  74. #define TYPE_ALL 0x0FFF
  75. #define TM_CREATE 0
  76. #define TM_MODIFY 1
  77. #define TM_ACCESS 2
  78. #define CS_DIR_ENTRY 0
  79. #define CS_PBR_SECTOR 1
  80. #define CS_DEFAULT 2
  81. #define DIR_DELETED 0xFFFF0321
  82. #define CLUSTER_16(x) ((UINT16)(x))
  83. #define CLUSTER_32(x) ((UINT32)(x))
  84. #define START_SECTOR(x) \
  85. ( (((x)-2) << p_fs->sectors_per_clu_bits) + p_fs->data_start_sector )
  86. #define IS_LAST_SECTOR_IN_CLUSTER(sec) \
  87. ( (((sec) - p_fs->data_start_sector + 1) & ((1 << p_fs->sectors_per_clu_bits) -1)) == 0)
  88. #define GET_CLUSTER_FROM_SECTOR(sec) \
  89. ((((sec) - p_fs->data_start_sector) >> p_fs->sectors_per_clu_bits) +2)
  90. #define GET16(p_src) \
  91. ( ((UINT16)(p_src)[0]) | (((UINT16)(p_src)[1]) << 8) )
  92. #define GET32(p_src) \
  93. ( ((UINT32)(p_src)[0]) | (((UINT32)(p_src)[1]) << 8) | \
  94. (((UINT32)(p_src)[2]) << 16) | (((UINT32)(p_src)[3]) << 24) )
  95. #define GET64(p_src) \
  96. ( ((UINT64)(p_src)[0]) | (((UINT64)(p_src)[1]) << 8) | \
  97. (((UINT64)(p_src)[2]) << 16) | (((UINT64)(p_src)[3]) << 24) | \
  98. (((UINT64)(p_src)[4]) << 32) | (((UINT64)(p_src)[5]) << 40) | \
  99. (((UINT64)(p_src)[6]) << 48) | (((UINT64)(p_src)[7]) << 56) )
  100. #define SET16(p_dst,src) \
  101. do { \
  102. (p_dst)[0]=(UINT8)(src); \
  103. (p_dst)[1]=(UINT8)(((UINT16)(src)) >> 8); \
  104. } while (0)
  105. #define SET32(p_dst,src) \
  106. do { \
  107. (p_dst)[0]=(UINT8)(src); \
  108. (p_dst)[1]=(UINT8)(((UINT32)(src)) >> 8); \
  109. (p_dst)[2]=(UINT8)(((UINT32)(src)) >> 16); \
  110. (p_dst)[3]=(UINT8)(((UINT32)(src)) >> 24); \
  111. } while (0)
  112. #define SET64(p_dst,src) \
  113. do { \
  114. (p_dst)[0]=(UINT8)(src); \
  115. (p_dst)[1]=(UINT8)(((UINT64)(src)) >> 8); \
  116. (p_dst)[2]=(UINT8)(((UINT64)(src)) >> 16); \
  117. (p_dst)[3]=(UINT8)(((UINT64)(src)) >> 24); \
  118. (p_dst)[4]=(UINT8)(((UINT64)(src)) >> 32); \
  119. (p_dst)[5]=(UINT8)(((UINT64)(src)) >> 40); \
  120. (p_dst)[6]=(UINT8)(((UINT64)(src)) >> 48); \
  121. (p_dst)[7]=(UINT8)(((UINT64)(src)) >> 56); \
  122. } while (0)
  123. #if (FFS_CONFIG_LITTLE_ENDIAN == 1)
  124. #define GET16_A(p_src) (*((UINT16 *)(p_src)))
  125. #define GET32_A(p_src) (*((UINT32 *)(p_src)))
  126. #define GET64_A(p_src) (*((UINT64 *)(p_src)))
  127. #define SET16_A(p_dst,src) *((UINT16 *)(p_dst)) = (UINT16)(src)
  128. #define SET32_A(p_dst,src) *((UINT32 *)(p_dst)) = (UINT32)(src)
  129. #define SET64_A(p_dst,src) *((UINT64 *)(p_dst)) = (UINT64)(src)
  130. #else
  131. #define GET16_A(p_src) GET16(p_src)
  132. #define GET32_A(p_src) GET32(p_src)
  133. #define GET64_A(p_src) GET64(p_src)
  134. #define SET16_A(p_dst,src) SET16(p_dst, src)
  135. #define SET32_A(p_dst,src) SET32(p_dst, src)
  136. #define SET64_A(p_dst,src) SET64(p_dst, src)
  137. #endif
  138. #define HIGH_INDEX_BIT (8)
  139. #define HIGH_INDEX_MASK (0xFF00)
  140. #define LOW_INDEX_BIT (16-HIGH_INDEX_BIT)
  141. #define UTBL_ROW_COUNT (1<<LOW_INDEX_BIT)
  142. #define UTBL_COL_COUNT (1<<HIGH_INDEX_BIT)
  143. static inline UINT16 get_col_index(UINT16 i)
  144. {
  145. return i >> LOW_INDEX_BIT;
  146. }
  147. static inline UINT16 get_row_index(UINT16 i)
  148. {
  149. return i & ~HIGH_INDEX_MASK;
  150. }
  151. typedef struct {
  152. UINT8 jmp_boot[3];
  153. UINT8 oem_name[8];
  154. UINT8 bpb[109];
  155. UINT8 boot_code[390];
  156. UINT8 signature[2];
  157. } PBR_SECTOR_T;
  158. typedef struct {
  159. UINT8 sector_size[2];
  160. UINT8 sectors_per_clu;
  161. UINT8 num_reserved[2];
  162. UINT8 num_fats;
  163. UINT8 num_root_entries[2];
  164. UINT8 num_sectors[2];
  165. UINT8 media_type;
  166. UINT8 num_fat_sectors[2];
  167. UINT8 sectors_in_track[2];
  168. UINT8 num_heads[2];
  169. UINT8 num_hid_sectors[4];
  170. UINT8 num_huge_sectors[4];
  171. UINT8 phy_drv_no;
  172. UINT8 reserved;
  173. UINT8 ext_signature;
  174. UINT8 vol_serial[4];
  175. UINT8 vol_label[11];
  176. UINT8 vol_type[8];
  177. } BPB16_T;
  178. typedef struct {
  179. UINT8 sector_size[2];
  180. UINT8 sectors_per_clu;
  181. UINT8 num_reserved[2];
  182. UINT8 num_fats;
  183. UINT8 num_root_entries[2];
  184. UINT8 num_sectors[2];
  185. UINT8 media_type;
  186. UINT8 num_fat_sectors[2];
  187. UINT8 sectors_in_track[2];
  188. UINT8 num_heads[2];
  189. UINT8 num_hid_sectors[4];
  190. UINT8 num_huge_sectors[4];
  191. UINT8 num_fat32_sectors[4];
  192. UINT8 ext_flags[2];
  193. UINT8 fs_version[2];
  194. UINT8 root_cluster[4];
  195. UINT8 fsinfo_sector[2];
  196. UINT8 backup_sector[2];
  197. UINT8 reserved[12];
  198. UINT8 phy_drv_no;
  199. UINT8 ext_reserved;
  200. UINT8 ext_signature;
  201. UINT8 vol_serial[4];
  202. UINT8 vol_label[11];
  203. UINT8 vol_type[8];
  204. } BPB32_T;
  205. typedef struct {
  206. UINT8 reserved1[53];
  207. UINT8 vol_offset[8];
  208. UINT8 vol_length[8];
  209. UINT8 fat_offset[4];
  210. UINT8 fat_length[4];
  211. UINT8 clu_offset[4];
  212. UINT8 clu_count[4];
  213. UINT8 root_cluster[4];
  214. UINT8 vol_serial[4];
  215. UINT8 fs_version[2];
  216. UINT8 vol_flags[2];
  217. UINT8 sector_size_bits;
  218. UINT8 sectors_per_clu_bits;
  219. UINT8 num_fats;
  220. UINT8 phy_drv_no;
  221. UINT8 perc_in_use;
  222. UINT8 reserved2[7];
  223. } BPBEX_T;
  224. typedef struct {
  225. UINT8 signature1[4];
  226. UINT8 reserved1[480];
  227. UINT8 signature2[4];
  228. UINT8 free_cluster[4];
  229. UINT8 next_cluster[4];
  230. UINT8 reserved2[14];
  231. UINT8 signature3[2];
  232. } FSI_SECTOR_T;
  233. typedef struct {
  234. UINT8 dummy[32];
  235. } DENTRY_T;
  236. typedef struct {
  237. UINT8 name[DOS_NAME_LENGTH];
  238. UINT8 attr;
  239. UINT8 lcase;
  240. UINT8 create_time_ms;
  241. UINT8 create_time[2];
  242. UINT8 create_date[2];
  243. UINT8 access_date[2];
  244. UINT8 start_clu_hi[2];
  245. UINT8 modify_time[2];
  246. UINT8 modify_date[2];
  247. UINT8 start_clu_lo[2];
  248. UINT8 size[4];
  249. } DOS_DENTRY_T;
  250. typedef struct {
  251. UINT8 order;
  252. UINT8 unicode_0_4[10];
  253. UINT8 attr;
  254. UINT8 sysid;
  255. UINT8 checksum;
  256. UINT8 unicode_5_10[12];
  257. UINT8 start_clu[2];
  258. UINT8 unicode_11_12[4];
  259. } EXT_DENTRY_T;
  260. typedef struct {
  261. UINT8 type;
  262. UINT8 num_ext;
  263. UINT8 checksum[2];
  264. UINT8 attr[2];
  265. UINT8 reserved1[2];
  266. UINT8 create_time[2];
  267. UINT8 create_date[2];
  268. UINT8 modify_time[2];
  269. UINT8 modify_date[2];
  270. UINT8 access_time[2];
  271. UINT8 access_date[2];
  272. UINT8 create_time_ms;
  273. UINT8 modify_time_ms;
  274. UINT8 access_time_ms;
  275. UINT8 reserved2[9];
  276. } FILE_DENTRY_T;
  277. typedef struct {
  278. UINT8 type;
  279. UINT8 flags;
  280. UINT8 reserved1;
  281. UINT8 name_len;
  282. UINT8 name_hash[2];
  283. UINT8 reserved2[2];
  284. UINT8 valid_size[8];
  285. UINT8 reserved3[4];
  286. UINT8 start_clu[4];
  287. UINT8 size[8];
  288. } STRM_DENTRY_T;
  289. typedef struct {
  290. UINT8 type;
  291. UINT8 flags;
  292. UINT8 unicode_0_14[30];
  293. } NAME_DENTRY_T;
  294. typedef struct {
  295. UINT8 type;
  296. UINT8 flags;
  297. UINT8 reserved[18];
  298. UINT8 start_clu[4];
  299. UINT8 size[8];
  300. } BMAP_DENTRY_T;
  301. typedef struct {
  302. UINT8 type;
  303. UINT8 reserved1[3];
  304. UINT8 checksum[4];
  305. UINT8 reserved2[12];
  306. UINT8 start_clu[4];
  307. UINT8 size[8];
  308. } CASE_DENTRY_T;
  309. typedef struct {
  310. UINT8 type;
  311. UINT8 label_len;
  312. UINT8 unicode_0_10[22];
  313. UINT8 reserved[8];
  314. } VOLM_DENTRY_T;
  315. typedef struct {
  316. UINT32 dir;
  317. INT32 entry;
  318. CHAIN_T clu;
  319. } UENTRY_T;
  320. typedef struct __FS_STRUCT_T {
  321. UINT32 mounted;
  322. struct super_block *sb;
  323. struct semaphore v_sem;
  324. } FS_STRUCT_T;
  325. typedef struct {
  326. INT32 (*alloc_cluster)(struct super_block *sb, INT32 num_alloc, CHAIN_T *p_chain);
  327. void (*free_cluster)(struct super_block *sb, CHAIN_T *p_chain, INT32 do_relse);
  328. INT32 (*count_used_clusters)(struct super_block *sb);
  329. INT32 (*init_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, UINT32 type,
  330. UINT32 start_clu, UINT64 size);
  331. INT32 (*init_ext_entry)(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, INT32 num_entries,
  332. UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname);
  333. INT32 (*find_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, INT32 num_entries, DOS_NAME_T *p_dosname, UINT32 type);
  334. void (*delete_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, INT32 offset, INT32 num_entries);
  335. void (*get_uni_name_from_ext_entry)(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, UINT16 *uniname);
  336. INT32 (*count_ext_entries)(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, DENTRY_T *p_entry);
  337. INT32 (*calc_num_entries)(UNI_NAME_T *p_uniname);
  338. UINT32 (*get_entry_type)(DENTRY_T *p_entry);
  339. void (*set_entry_type)(DENTRY_T *p_entry, UINT32 type);
  340. UINT32 (*get_entry_attr)(DENTRY_T *p_entry);
  341. void (*set_entry_attr)(DENTRY_T *p_entry, UINT32 attr);
  342. UINT8 (*get_entry_flag)(DENTRY_T *p_entry);
  343. void (*set_entry_flag)(DENTRY_T *p_entry, UINT8 flag);
  344. UINT32 (*get_entry_clu0)(DENTRY_T *p_entry);
  345. void (*set_entry_clu0)(DENTRY_T *p_entry, UINT32 clu0);
  346. UINT64 (*get_entry_size)(DENTRY_T *p_entry);
  347. void (*set_entry_size)(DENTRY_T *p_entry, UINT64 size);
  348. void (*get_entry_time)(DENTRY_T *p_entry, TIMESTAMP_T *tp, UINT8 mode);
  349. void (*set_entry_time)(DENTRY_T *p_entry, TIMESTAMP_T *tp, UINT8 mode);
  350. } FS_FUNC_T;
  351. typedef struct __FS_INFO_T {
  352. UINT32 drv;
  353. UINT32 vol_type;
  354. UINT32 vol_id;
  355. UINT32 num_sectors;
  356. UINT32 num_clusters;
  357. UINT32 cluster_size;
  358. UINT32 cluster_size_bits;
  359. UINT32 sectors_per_clu;
  360. UINT32 sectors_per_clu_bits;
  361. UINT32 PBR_sector;
  362. UINT32 FAT1_start_sector;
  363. UINT32 FAT2_start_sector;
  364. UINT32 root_start_sector;
  365. UINT32 data_start_sector;
  366. UINT32 num_FAT_sectors;
  367. UINT32 root_dir;
  368. UINT32 dentries_in_root;
  369. UINT32 dentries_per_clu;
  370. UINT32 vol_flag;
  371. struct buffer_head *pbr_bh;
  372. UINT32 map_clu;
  373. UINT32 map_sectors;
  374. struct buffer_head **vol_amap;
  375. UINT16 **vol_utbl;
  376. UINT32 clu_srch_ptr;
  377. UINT32 used_clusters;
  378. UENTRY_T hint_uentry;
  379. UINT32 dev_ejected;
  380. FS_FUNC_T *fs_func;
  381. BUF_CACHE_T FAT_cache_array[FAT_CACHE_SIZE];
  382. BUF_CACHE_T FAT_cache_lru_list;
  383. BUF_CACHE_T FAT_cache_hash_list[FAT_CACHE_HASH_SIZE];
  384. BUF_CACHE_T buf_cache_array[BUF_CACHE_SIZE];
  385. BUF_CACHE_T buf_cache_lru_list;
  386. BUF_CACHE_T buf_cache_hash_list[BUF_CACHE_HASH_SIZE];
  387. } FS_INFO_T;
  388. #define ES_2_ENTRIES 2
  389. #define ES_3_ENTRIES 3
  390. #define ES_ALL_ENTRIES 0
  391. typedef struct {
  392. UINT32 sector;
  393. INT32 offset;
  394. INT32 alloc_flag;
  395. UINT32 num_entries;
  396. void *__buf;
  397. } ENTRY_SET_CACHE_T;
  398. INT32 ffsInit(void);
  399. INT32 ffsShutdown(void);
  400. INT32 ffsMountVol(struct super_block *sb, INT32 drv);
  401. INT32 ffsUmountVol(struct super_block *sb);
  402. INT32 ffsCheckVol(struct super_block *sb);
  403. INT32 ffsGetVolInfo(struct super_block *sb, VOL_INFO_T *info);
  404. INT32 ffsSyncVol(struct super_block *sb, INT32 do_sync);
  405. INT32 ffsLookupFile(struct inode *inode, UINT8 *path, FILE_ID_T *fid);
  406. INT32 ffsCreateFile(struct inode *inode, UINT8 *path, UINT8 mode, FILE_ID_T *fid);
  407. INT32 ffsReadFile(struct inode *inode, FILE_ID_T *fid, void *buffer, UINT64 count, UINT64 *rcount);
  408. INT32 ffsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, UINT64 count, UINT64 *wcount);
  409. INT32 ffsTruncateFile(struct inode *inode, UINT64 old_size, UINT64 new_size);
  410. INT32 ffsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry);
  411. INT32 ffsRemoveFile(struct inode *inode, FILE_ID_T *fid);
  412. INT32 ffsSetAttr(struct inode *inode, UINT32 attr);
  413. INT32 ffsGetStat(struct inode *inode, DIR_ENTRY_T *info);
  414. INT32 ffsSetStat(struct inode *inode, DIR_ENTRY_T *info);
  415. INT32 ffsMapCluster(struct inode *inode, INT32 clu_offset, UINT32 *clu);
  416. INT32 ffsCreateDir(struct inode *inode, UINT8 *path, FILE_ID_T *fid);
  417. INT32 ffsReadDir(struct inode *inode, DIR_ENTRY_T *dir_ent);
  418. INT32 ffsRemoveDir(struct inode *inode, FILE_ID_T *fid);
  419. INT32 ffsRemoveEntry(struct inode *inode, FILE_ID_T *fid);
  420. INT32 fs_init(void);
  421. INT32 fs_shutdown(void);
  422. void fs_set_vol_flags(struct super_block *sb, UINT32 new_flag);
  423. void fs_sync(struct super_block *sb, INT32 do_sync);
  424. void fs_error(struct super_block *sb);
  425. INT32 clear_cluster(struct super_block *sb, UINT32 clu);
  426. INT32 fat_alloc_cluster(struct super_block *sb, INT32 num_alloc, CHAIN_T *p_chain);
  427. INT32 exfat_alloc_cluster(struct super_block *sb, INT32 num_alloc, CHAIN_T *p_chain);
  428. void fat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, INT32 do_relse);
  429. void exfat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, INT32 do_relse);
  430. UINT32 find_last_cluster(struct super_block *sb, CHAIN_T *p_chain);
  431. INT32 count_num_clusters(struct super_block *sb, CHAIN_T *dir);
  432. INT32 fat_count_used_clusters(struct super_block *sb);
  433. INT32 exfat_count_used_clusters(struct super_block *sb);
  434. void exfat_chain_cont_cluster(struct super_block *sb, UINT32 chain, INT32 len);
  435. INT32 load_alloc_bitmap(struct super_block *sb);
  436. void free_alloc_bitmap(struct super_block *sb);
  437. INT32 set_alloc_bitmap(struct super_block *sb, UINT32 clu);
  438. INT32 clr_alloc_bitmap(struct super_block *sb, UINT32 clu);
  439. UINT32 test_alloc_bitmap(struct super_block *sb, UINT32 clu);
  440. void sync_alloc_bitmap(struct super_block *sb);
  441. INT32 load_upcase_table(struct super_block *sb);
  442. void free_upcase_table(struct super_block *sb);
  443. UINT32 fat_get_entry_type(DENTRY_T *p_entry);
  444. UINT32 exfat_get_entry_type(DENTRY_T *p_entry);
  445. void fat_set_entry_type(DENTRY_T *p_entry, UINT32 type);
  446. void exfat_set_entry_type(DENTRY_T *p_entry, UINT32 type);
  447. UINT32 fat_get_entry_attr(DENTRY_T *p_entry);
  448. UINT32 exfat_get_entry_attr(DENTRY_T *p_entry);
  449. void fat_set_entry_attr(DENTRY_T *p_entry, UINT32 attr);
  450. void exfat_set_entry_attr(DENTRY_T *p_entry, UINT32 attr);
  451. UINT8 fat_get_entry_flag(DENTRY_T *p_entry);
  452. UINT8 exfat_get_entry_flag(DENTRY_T *p_entry);
  453. void fat_set_entry_flag(DENTRY_T *p_entry, UINT8 flag);
  454. void exfat_set_entry_flag(DENTRY_T *p_entry, UINT8 flag);
  455. UINT32 fat_get_entry_clu0(DENTRY_T *p_entry);
  456. UINT32 exfat_get_entry_clu0(DENTRY_T *p_entry);
  457. void fat_set_entry_clu0(DENTRY_T *p_entry, UINT32 start_clu);
  458. void exfat_set_entry_clu0(DENTRY_T *p_entry, UINT32 start_clu);
  459. UINT64 fat_get_entry_size(DENTRY_T *p_entry);
  460. UINT64 exfat_get_entry_size(DENTRY_T *p_entry);
  461. void fat_set_entry_size(DENTRY_T *p_entry, UINT64 size);
  462. void exfat_set_entry_size(DENTRY_T *p_entry, UINT64 size);
  463. void fat_get_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, UINT8 mode);
  464. void exfat_get_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, UINT8 mode);
  465. void fat_set_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, UINT8 mode);
  466. void exfat_set_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, UINT8 mode);
  467. INT32 fat_init_dir_entry(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, UINT32 type, UINT32 start_clu, UINT64 size);
  468. INT32 exfat_init_dir_entry(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, UINT32 type, UINT32 start_clu, UINT64 size);
  469. INT32 fat_init_ext_dir_entry(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, INT32 num_entries, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname);
  470. INT32 exfat_init_ext_dir_entry(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, INT32 num_entries, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname);
  471. void init_dos_entry(DOS_DENTRY_T *ep, UINT32 type, UINT32 start_clu, UINT8 tz_utc);
  472. void init_ext_entry(EXT_DENTRY_T *ep, INT32 order, UINT8 chksum, UINT16 *uniname);
  473. void init_file_entry(FILE_DENTRY_T *ep, UINT32 type, UINT8 tz_utc);
  474. void init_strm_entry(STRM_DENTRY_T *ep, UINT8 flags, UINT32 start_clu, UINT64 size);
  475. void init_name_entry(NAME_DENTRY_T *ep, UINT16 *uniname);
  476. void fat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, INT32 order, INT32 num_entries);
  477. void exfat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, INT32 order, INT32 num_entries);
  478. INT32 find_location(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, UINT32 *sector, INT32 *offset);
  479. DENTRY_T *get_entry_with_sector(struct super_block *sb, UINT32 sector, INT32 offset);
  480. DENTRY_T *get_entry_in_dir(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, UINT32 *sector);
  481. ENTRY_SET_CACHE_T *get_entry_set_in_dir (struct super_block *sb, CHAIN_T *p_dir, INT32 entry, UINT32 type, DENTRY_T **file_ep);
  482. void release_entry_set (ENTRY_SET_CACHE_T *es);
  483. INT32 write_whole_entry_set (struct super_block *sb, ENTRY_SET_CACHE_T *es);
  484. INT32 write_partial_entries_in_entry_set (struct super_block *sb, ENTRY_SET_CACHE_T *es, DENTRY_T *ep, UINT32 count);
  485. INT32 search_deleted_or_unused_entry(struct super_block *sb, CHAIN_T *p_dir, INT32 num_entries);
  486. INT32 find_empty_entry(struct inode *inode, CHAIN_T *p_dir, INT32 num_entries);
  487. INT32 fat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, INT32 num_entries, DOS_NAME_T *p_dosname, UINT32 type);
  488. INT32 exfat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, INT32 num_entries, DOS_NAME_T *p_dosname, UINT32 type);
  489. INT32 fat_count_ext_entries(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, DENTRY_T *p_entry);
  490. INT32 exfat_count_ext_entries(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, DENTRY_T *p_entry);
  491. INT32 count_dos_name_entries(struct super_block *sb, CHAIN_T *p_dir, UINT32 type);
  492. void update_dir_checksum(struct super_block *sb, CHAIN_T *p_dir, INT32 entry);
  493. void update_dir_checksum_with_entry_set (struct super_block *sb, ENTRY_SET_CACHE_T *es);
  494. BOOL is_dir_empty(struct super_block *sb, CHAIN_T *p_dir);
  495. INT32 get_num_entries_and_dos_name(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, INT32 *entries, DOS_NAME_T *p_dosname);
  496. void get_uni_name_from_dos_entry(struct super_block *sb, DOS_DENTRY_T *ep, UNI_NAME_T *p_uniname, UINT8 mode);
  497. void fat_get_uni_name_from_ext_entry(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, UINT16 *uniname);
  498. void exfat_get_uni_name_from_ext_entry(struct super_block *sb, CHAIN_T *p_dir, INT32 entry, UINT16 *uniname);
  499. INT32 extract_uni_name_from_ext_entry(EXT_DENTRY_T *ep, UINT16 *uniname, INT32 order);
  500. INT32 extract_uni_name_from_name_entry(NAME_DENTRY_T *ep, UINT16 *uniname, INT32 order);
  501. INT32 fat_generate_dos_name(struct super_block *sb, CHAIN_T *p_dir, DOS_NAME_T *p_dosname);
  502. void fat_attach_count_to_dos_name(UINT8 *dosname, INT32 count);
  503. INT32 fat_calc_num_entries(UNI_NAME_T *p_uniname);
  504. INT32 exfat_calc_num_entries(UNI_NAME_T *p_uniname);
  505. UINT8 calc_checksum_1byte(void *data, INT32 len, UINT8 chksum);
  506. UINT16 calc_checksum_2byte(void *data, INT32 len, UINT16 chksum, INT32 type);
  507. UINT32 calc_checksum_4byte(void *data, INT32 len, UINT32 chksum, INT32 type);
  508. INT32 resolve_path(struct inode *inode, UINT8 *path, CHAIN_T *p_dir, UNI_NAME_T *p_uniname);
  509. INT32 resolve_name(UINT8 *name, UINT8 **arg);
  510. INT32 fat16_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr);
  511. INT32 fat32_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr);
  512. INT32 exfat_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr);
  513. INT32 create_dir(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, FILE_ID_T *fid);
  514. INT32 create_file(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, UINT8 mode, FILE_ID_T *fid);
  515. void remove_file(struct inode *inode, CHAIN_T *p_dir, INT32 entry);
  516. INT32 rename_file(struct inode *inode, CHAIN_T *p_dir, INT32 old_entry, UNI_NAME_T *p_uniname, FILE_ID_T *fid);
  517. INT32 move_file(struct inode *inode, CHAIN_T *p_olddir, INT32 oldentry, CHAIN_T *p_newdir, UNI_NAME_T *p_uniname, FILE_ID_T *fid);
  518. INT32 sector_read(struct super_block *sb, UINT32 sec, struct buffer_head **bh, INT32 read);
  519. INT32 sector_write(struct super_block *sb, UINT32 sec, struct buffer_head *bh, INT32 sync);
  520. INT32 multi_sector_read(struct super_block *sb, UINT32 sec, struct buffer_head **bh, INT32 num_secs, INT32 read);
  521. INT32 multi_sector_write(struct super_block *sb, UINT32 sec, struct buffer_head *bh, INT32 num_secs, INT32 sync);
  522. #ifdef __cplusplus
  523. }
  524. #endif
  525. #endif