-
Notifications
You must be signed in to change notification settings - Fork 326
/
exfat_api.h
206 lines (180 loc) · 7.75 KB
/
exfat_api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/************************************************************************/
/* */
/* PROJECT : exFAT & FAT12/16/32 File System */
/* FILE : exfat_api.h */
/* PURPOSE : Header File for exFAT API Glue Layer */
/* */
/*----------------------------------------------------------------------*/
/* NOTES */
/* */
/*----------------------------------------------------------------------*/
/* REVISION HISTORY (Ver 0.9) */
/* */
/* - 2010.11.15 [Joosun Hahn] : first writing */
/* */
/************************************************************************/
#ifndef _EXFAT_API_H
#define _EXFAT_API_H
#include <linux/fs.h>
#include "exfat_config.h"
/*----------------------------------------------------------------------*/
/* Constant & Macro Definitions */
/*----------------------------------------------------------------------*/
#define EXFAT_SUPER_MAGIC (0x2011BAB0L)
#define EXFAT_ROOT_INO 1
/* FAT types */
#define FAT12 0x01 /* FAT12 */
#define FAT16 0x0E /* Win95 FAT16 (LBA) */
#define FAT32 0x0C /* Win95 FAT32 (LBA) */
#define EXFAT 0x07 /* exFAT */
/* file name lengths */
#define MAX_CHARSET_SIZE 3 /* max size of multi-byte character */
#define MAX_PATH_DEPTH 15 /* max depth of path name */
#define MAX_NAME_LENGTH 256 /* max len of file name including NULL */
#define MAX_PATH_LENGTH 260 /* max len of path name including NULL */
#define DOS_NAME_LENGTH 11 /* DOS file name length excluding NULL */
#define DOS_PATH_LENGTH 80 /* DOS path name length excluding NULL */
/* file attributes */
#define ATTR_NORMAL 0x0000
#define ATTR_READONLY 0x0001
#define ATTR_HIDDEN 0x0002
#define ATTR_SYSTEM 0x0004
#define ATTR_VOLUME 0x0008
#define ATTR_SUBDIR 0x0010
#define ATTR_ARCHIVE 0x0020
#define ATTR_SYMLINK 0x0040
#define ATTR_EXTEND 0x000F
#define ATTR_RWMASK 0x007E
/* file creation modes */
#define FM_REGULAR 0x00
#define FM_SYMLINK 0x40
/* return values */
#define FFS_SUCCESS 0
#define FFS_MEDIAERR 1
#define FFS_FORMATERR 2
#define FFS_MOUNTED 3
#define FFS_NOTMOUNTED 4
#define FFS_ALIGNMENTERR 5
#define FFS_SEMAPHOREERR 6
#define FFS_INVALIDPATH 7
#define FFS_INVALIDFID 8
#define FFS_NOTFOUND 9
#define FFS_FILEEXIST 10
#define FFS_PERMISSIONERR 11
#define FFS_NOTOPENED 12
#define FFS_MAXOPENED 13
#define FFS_FULL 14
#define FFS_EOF 15
#define FFS_DIRBUSY 16
#define FFS_MEMORYERR 17
#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 */
int FsInit(void);
int FsShutdown(void);
/* volume management functions */
int FsMountVol(struct super_block *sb);
int FsUmountVol(struct super_block *sb);
int FsGetVolInfo(struct super_block *sb, VOL_INFO_T *info);
int FsSyncVol(struct super_block *sb, int do_sync);
/* file management functions */
int FsLookupFile(struct inode *inode, char *path, FILE_ID_T *fid);
int FsCreateFile(struct inode *inode, char *path, u8 mode, FILE_ID_T *fid);
int FsReadFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *rcount);
int FsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *wcount);
int FsTruncateFile(struct inode *inode, u64 old_size, u64 new_size);
int FsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry);
int FsRemoveFile(struct inode *inode, FILE_ID_T *fid);
int FsSetAttr(struct inode *inode, u32 attr);
int FsReadStat(struct inode *inode, DIR_ENTRY_T *info);
int FsWriteStat(struct inode *inode, DIR_ENTRY_T *info);
int FsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu);
/* directory management functions */
int FsCreateDir(struct inode *inode, char *path, FILE_ID_T *fid);
int FsReadDir(struct inode *inode, DIR_ENTRY_T *dir_entry);
int FsRemoveDir(struct inode *inode, FILE_ID_T *fid);
/* debug functions */
s32 FsReleaseCache(struct super_block *sb);
#endif /* _EXFAT_API_H */