File System Component  Version 5.0
MDK-Professional Middleware for Devices with Flash File System
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
rl_fs.h
Go to the documentation of this file.
1 /*------------------------------------------------------------------------------
2  * MDK Middleware - Component ::File System
3  * Copyright (c) 2004-2013 ARM Germany GmbH. All rights reserved.
4  *------------------------------------------------------------------------------
5  * Name: rl_fs.h
6  * Purpose: File System API
7  * Rev.: V5.04
8  *----------------------------------------------------------------------------*/
9 
10 #ifndef __RL_FS_H
11 #define __RL_FS_H
12 
13 #include <stdint.h>
14 #include <stdbool.h>
15 
16 // ==== Enumeration, structures, defines ====
17 
19 #define FS_FAT_ATTR_READ_ONLY 0x01
20 #define FS_FAT_ATTR_HIDDEN 0x02
21 #define FS_FAT_ATTR_SYSTEM 0x04
22 #define FS_FAT_ATTR_VOLUME_ID 0x08
23 #define FS_FAT_ATTR_DIRECTORY 0x10
24 #define FS_FAT_ATTR_ARCHIVE 0x20
25 
26 
27 #define FS_MEDIA_INSERTED 0x01
28 #define FS_MEDIA_PROTECTED 0x02
29 #define FS_MEDIA_INITIALIZED 0x04
30 #define FS_MEDIA_NOCHKMEDIA 0x80
31 
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
38 typedef enum {
39  fsOK = 0,
53 } fsStatus;
54 
56 typedef enum _fsType {
57  fsTypeNone = 0,
63 } fsType;
64 
66 typedef enum _fsDevCtrlCode {
72 
74 typedef struct _fsMediaInfo {
75  uint32_t block_cnt;
76  uint16_t read_blen;
77  uint16_t write_blen;
78 } fsMediaInfo;
79 
81 typedef struct _fsIOC_Cache {
82  uint8_t *buffer;
83  uint32_t size;
84 } fsIOC_Cache;
85 
87 typedef struct _fsCID_Register {
88  uint32_t PSN;
89  uint16_t OID;
90  uint8_t MID;
91  uint8_t PRV;
92  uint16_t MDT;
93  uint8_t PNM[6];
95 
97 typedef struct _fsTime {
98  uint8_t hr;
99  uint8_t min;
100  uint8_t sec;
101  uint8_t day;
102  uint8_t mon;
103  uint16_t year;
104 } fsTime;
105 
107 typedef struct _fsFileInfo {
108  char name[256];
109  uint32_t size;
110  uint16_t fileID;
111  uint8_t attrib;
113 } fsFileInfo;
114 
116 typedef struct _fsDriveInfo {
118  uint64_t capacity;
119 } fsDriveInfo;
120 
121 
122 // ==== System Routines ====
123 
131 extern fsStatus finit (const char *drive);
132 
139 extern fsStatus funinit (const char *drive);
140 
150 extern fsStatus fmount (const char *drive);
151 
158 extern fsStatus funmount (const char *drive);
159 
160 
161 // ==== File Maintenance Routines ====
162 
171 extern fsStatus fdelete (const char *path);
172 
186 extern fsStatus ffind (const char *pattern, fsFileInfo *info);
187 
198 extern fsStatus frename (const char *path, const char *newname);
199 
218 extern fsStatus fattrib (const char *path, const char *attr);
219 
220 
221 // ==== Utility Routines ====
222 
228 extern int64_t ffree (const char *drive);
229 
238 extern fsStatus fformat (const char *drive, const char *options);
239 
246 extern int32_t fanalyse (const char *drive);
247 
257 extern fsStatus fcheck (const char *drive);
258 
268 extern fsStatus fdefrag (const char *drive);
269 
277 extern fsStatus fmedia (const char *drive);
278 
286 extern fsStatus finfo (const char *drive, fsDriveInfo *info);
287 
301 extern fsStatus fvol (const char *drive, char *label, uint32_t *serial);
302 
303 
304 // ==== File Time Support Routines ====
305 
312 extern fsStatus fs_get_time (fsTime *time);
313 
314 
315 // ==== I/O Control Interface Routines ====
316 
322 extern int32_t fs_ioc_get_id (const char *drive);
323 
330 extern fsStatus fs_ioc_lock (int32_t drv_id);
331 
338 extern fsStatus fs_ioc_unlock (int32_t drv_id);
339 
348 extern fsStatus fs_ioc_get_cache (int32_t drv_id, fsIOC_Cache *cache_info);
349 
361 extern fsStatus fs_ioc_read_sector (int32_t drv_id, uint32_t sect, uint8_t *buf, uint32_t cnt);
362 
374 extern fsStatus fs_ioc_write_sector (int32_t drv_id, uint32_t sect, const uint8_t *buf, uint32_t cnt);
375 
385 extern fsStatus fs_ioc_read_info (int32_t drv_id, fsMediaInfo *info);
386 
392 extern fsStatus fs_ioc_device_ctrl (int32_t drv_id, fsDevCtrlCode code, void *p);
393 
394 #ifdef __cplusplus
395 }
396 #endif
397 
398 #endif /* __RL_FS_H */