CD exfat support for Tomato. https://github.com/dorimanx/exfat-nofuse.
[tomato.git] / release / src-rt / linux / linux-2.6 / fs / exfat / exfat_api.h
blobd89b8fed596fb90546a84e801a2b863b01ea331b
1 /*
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 /************************************************************************/
20 /* */
21 /* PROJECT : exFAT & FAT12/16/32 File System */
22 /* FILE : exfat_api.h */
23 /* PURPOSE : Header File for exFAT API Glue Layer */
24 /* */
25 /*----------------------------------------------------------------------*/
26 /* NOTES */
27 /* */
28 /*----------------------------------------------------------------------*/
29 /* REVISION HISTORY (Ver 0.9) */
30 /* */
31 /* - 2010.11.15 [Joosun Hahn] : first writing */
32 /* */
33 /************************************************************************/
35 #ifndef _EXFAT_API_H
36 #define _EXFAT_API_H
38 #include "exfat_config.h"
39 #include "exfat_global.h"
41 #ifdef __cplusplus
42 extern "C" {
43 #endif /* __cplusplus */
45 /*----------------------------------------------------------------------*/
46 /* Constant & Macro Definitions */
47 /*----------------------------------------------------------------------*/
49 #define EXFAT_SUPER_MAGIC (0x2011BAB0L)
50 #define EXFAT_ROOT_INO 1
52 /* FAT types */
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
66 /* file attributes */
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
82 /* return values */
83 #define FFS_SUCCESS 0
84 #define FFS_MEDIAERR 1
85 #define FFS_FORMATERR 2
86 #define FFS_MOUNTED 3
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
97 #define FFS_FULL 14
98 #define FFS_EOF 15
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 /*----------------------------------------------------------------------*/
108 typedef struct {
109 UINT16 Year;
110 UINT16 Month;
111 UINT16 Day;
112 UINT16 Hour;
113 UINT16 Minute;
114 UINT16 Second;
115 UINT16 MilliSecond;
116 } DATE_TIME_T;
118 typedef struct {
119 UINT32 Offset; // start sector number of the partition
120 UINT32 Size; // in sectors
121 } PART_INFO_T;
123 typedef struct {
124 UINT32 SecSize; // sector size in bytes
125 UINT32 DevSize; // block device size in sectors
126 } DEV_INFO_T;
128 typedef struct {
129 UINT32 FatType;
130 UINT32 ClusterSize;
131 UINT32 NumClusters;
132 UINT32 FreeClusters;
133 UINT32 UsedClusters;
134 } VOL_INFO_T;
136 /* directory structure */
137 typedef struct {
138 UINT32 dir;
139 INT32 size;
140 UINT8 flags;
141 } CHAIN_T;
143 /* file id structure */
144 typedef struct {
145 CHAIN_T dir;
146 UINT8 flags;
147 INT32 entry;
148 UINT32 type;
149 UINT32 attr;
150 UINT32 start_clu;
151 INT32 hint_last_off;
152 UINT32 hint_last_clu;
153 INT64 rwoffset;
154 UINT64 size;
155 } FILE_ID_T;
157 typedef struct {
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
160 UINT32 Attr;
161 UINT64 Size;
162 UINT32 NumSubdirs;
163 DATE_TIME_T CreateTimestamp;
164 DATE_TIME_T ModifyTimestamp;
165 DATE_TIME_T AccessTimestamp;
166 } DIR_ENTRY_T;
168 /*======================================================================*/
169 /* */
170 /* API FUNCTION DECLARATIONS */
171 /* (CHANGE THIS PART IF REQUIRED) */
172 /* */
173 /*======================================================================*/
175 /*----------------------------------------------------------------------*/
176 /* External Function Declarations */
177 /*----------------------------------------------------------------------*/
179 /* file system initialization & shutdown functions */
180 INT32 FsInit(void);
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);
215 #ifdef __cplusplus
217 #endif /* __cplusplus */
219 #endif /* _EXFAT_API_H */
221 /* end of exfat_api.h */