2 * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
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.
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.
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.
19 /************************************************************************/
21 /* PROJECT : exFAT & FAT12/16/32 File System */
22 /* FILE : exfat_api.h */
23 /* PURPOSE : Header File for exFAT API Glue Layer */
25 /*----------------------------------------------------------------------*/
28 /*----------------------------------------------------------------------*/
29 /* REVISION HISTORY (Ver 0.9) */
31 /* - 2010.11.15 [Joosun Hahn] : first writing */
33 /************************************************************************/
38 #include "exfat_config.h"
39 #include "exfat_global.h"
43 #endif /* __cplusplus */
45 /*----------------------------------------------------------------------*/
46 /* Constant & Macro Definitions */
47 /*----------------------------------------------------------------------*/
49 #define EXFAT_SUPER_MAGIC (0x2011BAB0L)
50 #define EXFAT_ROOT_INO 1
53 #define FAT12 0x01 // FAT12
54 #define FAT16 0x0E // Win95 FAT16 (LBA)
55 #define FAT32 0x0C // Win95 FAT32 (LBA)
56 #define EXFAT 0x07 // exFAT
58 /* file name lengths */
59 #define MAX_CHARSET_SIZE 3 // max size of multi-byte character
60 #define MAX_PATH_DEPTH 15 // max depth of path name
61 #define MAX_NAME_LENGTH 256 // max len of file name including NULL
62 #define MAX_PATH_LENGTH 260 // max len of path name including NULL
63 #define DOS_NAME_LENGTH 11 // DOS file name length excluding NULL
64 #define DOS_PATH_LENGTH 80 // DOS path name length excluding NULL
67 #define ATTR_NORMAL 0x0000
68 #define ATTR_READONLY 0x0001
69 #define ATTR_HIDDEN 0x0002
70 #define ATTR_SYSTEM 0x0004
71 #define ATTR_VOLUME 0x0008
72 #define ATTR_SUBDIR 0x0010
73 #define ATTR_ARCHIVE 0x0020
74 #define ATTR_SYMLINK 0x0040
75 #define ATTR_EXTEND 0x000F
76 #define ATTR_RWMASK 0x007E
78 /* file creation modes */
79 #define FM_REGULAR 0x00
80 #define FM_SYMLINK 0x40
84 #define FFS_MEDIAERR 1
85 #define FFS_FORMATERR 2
87 #define FFS_NOTMOUNTED 4
88 #define FFS_ALIGNMENTERR 5
89 #define FFS_SEMAPHOREERR 6
90 #define FFS_INVALIDPATH 7
91 #define FFS_INVALIDFID 8
92 #define FFS_NOTFOUND 9
93 #define FFS_FILEEXIST 10
94 #define FFS_PERMISSIONERR 11
95 #define FFS_NOTOPENED 12
96 #define FFS_MAXOPENED 13
99 #define FFS_DIRBUSY 16
100 #define FFS_MEMORYERR 17
101 #define FFS_NAMETOOLONG 18
102 #define FFS_ERROR 19 // generic error code
104 /*----------------------------------------------------------------------*/
105 /* Type Definitions */
106 /*----------------------------------------------------------------------*/
119 UINT32 Offset
; // start sector number of the partition
120 UINT32 Size
; // in sectors
124 UINT32 SecSize
; // sector size in bytes
125 UINT32 DevSize
; // block device size in sectors
136 /* directory structure */
143 /* file id structure */
152 UINT32 hint_last_clu
;
158 INT8 Name
[MAX_NAME_LENGTH
*MAX_CHARSET_SIZE
];
159 INT8 ShortName
[DOS_NAME_LENGTH
+ 2]; // used only for FAT12/16/32, not used for exFAT
163 DATE_TIME_T CreateTimestamp
;
164 DATE_TIME_T ModifyTimestamp
;
165 DATE_TIME_T AccessTimestamp
;
168 /*======================================================================*/
170 /* API FUNCTION DECLARATIONS */
171 /* (CHANGE THIS PART IF REQUIRED) */
173 /*======================================================================*/
175 /*----------------------------------------------------------------------*/
176 /* External Function Declarations */
177 /*----------------------------------------------------------------------*/
179 /* file system initialization & shutdown functions */
181 INT32
FsShutdown(void);
183 /* volume management functions */
184 INT32
FsMountVol(struct super_block
*sb
);
185 INT32
FsUmountVol(struct super_block
*sb
);
186 INT32
FsGetVolInfo(struct super_block
*sb
, VOL_INFO_T
*info
);
187 INT32
FsSyncVol(struct super_block
*sb
, INT32 do_sync
);
189 /* file management functions */
190 INT32
FsLookupFile(struct inode
*inode
, UINT8
*path
, FILE_ID_T
*fid
);
191 INT32
FsCreateFile(struct inode
*inode
, UINT8
*path
, UINT8 mode
, FILE_ID_T
*fid
);
192 INT32
FsReadFile(struct inode
*inode
, FILE_ID_T
*fid
, void *buffer
, UINT64 count
, UINT64
*rcount
);
193 INT32
FsWriteFile(struct inode
*inode
, FILE_ID_T
*fid
, void *buffer
, UINT64 count
, UINT64
*wcount
);
194 INT32
FsTruncateFile(struct inode
*inode
, UINT64 old_size
, UINT64 new_size
);
195 INT32
FsMoveFile(struct inode
*old_parent_inode
, FILE_ID_T
*fid
, struct inode
*new_parent_inode
, struct dentry
*new_dentry
);
196 INT32
FsRemoveFile(struct inode
*inode
, FILE_ID_T
*fid
);
197 INT32
FsSetAttr(struct inode
*inode
, UINT32 attr
);
198 INT32
FsReadStat(struct inode
*inode
, DIR_ENTRY_T
*info
);
199 INT32
FsWriteStat(struct inode
*inode
, DIR_ENTRY_T
*info
);
200 INT32
FsMapCluster(struct inode
*inode
, INT32 clu_offset
, UINT32
*clu
);
202 /* directory management functions */
203 INT32
FsCreateDir(struct inode
*inode
, UINT8
*path
, FILE_ID_T
*fid
);
204 INT32
FsReadDir(struct inode
*inode
, DIR_ENTRY_T
*dir_entry
);
205 INT32
FsRemoveDir(struct inode
*inode
, FILE_ID_T
*fid
);
207 /* debug functions */
208 INT32
FsReleaseCache(struct super_block
*sb
);
210 /* partition management functions */
211 //INT32 FsSetPartition(INT32 dev, INT32 num_vol, PART_INFO_T *vol_spec);
212 //INT32 FsGetPartition(INT32 dev, INT32 *num_vol, PART_INFO_T *vol_spec);
213 //INT32 FsGetDevInfo(INT32 dev, DEV_INFO_T *info);
217 #endif /* __cplusplus */
219 #endif /* _EXFAT_API_H */
221 /* end of exfat_api.h */