]> git.sur5r.net Git - freertos/blob - FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/include/ff_sys.h
Add the Labs projects provided in the V10.2.1_191129 zip file.
[freertos] / FreeRTOS-Labs / Source / FreeRTOS-Plus-FAT / include / ff_sys.h
1 /*\r
2  * FreeRTOS+FAT build 191128 - Note:  FreeRTOS+FAT is still in the lab!\r
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  * Authors include James Walmsley, Hein Tibosch and Richard Barry\r
5  *\r
6  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
7  * this software and associated documentation files (the "Software"), to deal in\r
8  * the Software without restriction, including without limitation the rights to\r
9  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
10  * the Software, and to permit persons to whom the Software is furnished to do so,\r
11  * subject to the following conditions:\r
12  *\r
13  * The above copyright notice and this permission notice shall be included in all\r
14  * copies or substantial portions of the Software.\r
15  *\r
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22  *\r
23  * https://www.FreeRTOS.org\r
24  *\r
25  */\r
26 \r
27 /*\r
28         ff_sys.h\r
29 \r
30         This module allow to map several separate file-sub-systems into a root directory\r
31 \r
32         For instance, a system with 3 sub sytems:\r
33 \r
34                 /flash :  NAND flash driver\r
35                 /ram   :  RAM-disk driver\r
36                 /      :  SD-card driver\r
37 \r
38         In this example, the SD-card driver handles ALL files and directories which\r
39         do not match /flash/ * or /ram/ *\r
40 \r
41         Now for instance a file call "/flash/etc/network.ini"\r
42         will be stored as "/etc/network.ini" on the NAND drive\r
43 \r
44         This module along with ff_stdio.c make translations between absolute\r
45         and relative paths\r
46 */\r
47 \r
48 #ifndef FF_SYS_H\r
49 #define FF_SYS_H\r
50 \r
51 #ifdef __cplusplus\r
52 extern "C" {\r
53 #endif\r
54 \r
55 typedef struct FILE_SUB_SYSTEM\r
56 {\r
57         char pcPath[16];\r
58         BaseType_t xPathlen;\r
59         FF_IOManager_t *pxManager;\r
60 } FF_SubSystem_t;\r
61 \r
62 typedef struct FF_DIR_HANDLER\r
63 {\r
64         union\r
65         {\r
66                 struct\r
67                 {\r
68                         unsigned\r
69                                 bEndOfDir : 1,\r
70                                 bFirstCalled : 1,\r
71                                 bIsValid : 1,\r
72                                 bAddDotEntries : 2;\r
73                 } bits;\r
74                 unsigned uFlags;\r
75         } u;\r
76         /*\r
77          * path will contain the relative path. It will be used when calling +FAT functions\r
78          * like FF_FindFirst() / FF_FindNext()\r
79          * For instance, for "/flash/etc" path will become "/etc"\r
80          */\r
81         const char *pcPath;\r
82         FF_IOManager_t *pxManager;      /* Will point to handler of this partition. */\r
83         BaseType_t xFSIndex;            /* The index of this entry, where 0 always means: the root system. */\r
84 } FF_DirHandler_t;\r
85 \r
86 /*\r
87  * Initialise (clear) the file system table\r
88  * This will also called by FF_FS_Add()\r
89  */\r
90 void FF_FS_Init( void );\r
91 \r
92 /*\r
93  * Add a file system\r
94  * The path must be absolute, e.g. start with a slash\r
95  * The second argument is the FF_Disk_t structure that is handling the driver\r
96  */\r
97 int FF_FS_Add( const char *pcPath, FF_Disk_t *pxDisk );\r
98 \r
99 /*\r
100  * Remove a file system\r
101  * which ws earlier added by ff_fs_ad()\r
102  */\r
103 void FF_FS_Remove( const char *pcPath );\r
104 \r
105 /*\r
106  * Internally used by ff_stdio:\r
107  * The ff_dir_handler helps to iterate through a mounte directory\r
108  *\r
109  * FF_FS_Find() will find a ff_dir_handler for a given path\r
110  */\r
111 int FF_FS_Find( const char *pcPath, FF_DirHandler_t *pxHandler );\r
112 \r
113 /*\r
114  * For internal use:\r
115  * Get the file system information, based on an index\r
116  */\r
117 int FF_FS_Get( int iIndex, FF_SubSystem_t *pxSystem );\r
118 \r
119 /*\r
120  * Returns the number of registered\r
121  * file systems\r
122  */\r
123 int FF_FS_Count( void );\r
124 \r
125 #ifdef __cplusplus\r
126 } /* extern "C" */\r
127 #endif\r
128 \r
129 #endif /* FF_SYS_H */\r