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