]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/Reliance-Edge/include/redposix.h
Update version numbers in preparation for new release.
[freertos] / FreeRTOS-Plus / Source / Reliance-Edge / include / redposix.h
1 /*             ----> DO NOT REMOVE THE FOLLOWING NOTICE <----\r
2 \r
3                    Copyright (c) 2014-2015 Datalight, Inc.\r
4                        All Rights Reserved Worldwide.\r
5 \r
6     This program is free software; you can redistribute it and/or modify\r
7     it under the terms of the GNU General Public License as published by\r
8     the Free Software Foundation; use version 2 of the License.\r
9 \r
10     This program is distributed in the hope that it will be useful,\r
11     but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty\r
12     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13     GNU General Public License for more details.\r
14 \r
15     You should have received a copy of the GNU General Public License along\r
16     with this program; if not, write to the Free Software Foundation, Inc.,\r
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 */\r
19 /*  Businesses and individuals that for commercial or other reasons cannot\r
20     comply with the terms of the GPLv2 license may obtain a commercial license\r
21     before incorporating Reliance Edge into proprietary software for\r
22     distribution in any form.  Visit http://www.datalight.com/reliance-edge for\r
23     more information.\r
24 */\r
25 /** @file\r
26     @brief Interface for the Reliance Edge POSIX-like API.\r
27 \r
28     The POSIX-like file system API is the primary file system API for\r
29     Reliance Edge, which supports the full functionality of the file system.\r
30     This API aims to be compatible with POSIX where reasonable, but it is\r
31     simplified considerably to meet the needs of resource-constrained embedded\r
32     systems.  The API has also been extended to provide access to the unique\r
33     features of Reliance Edge, and to cover areas (like mountins and formatting)\r
34     which do not have APIs in the POSIX specification.\r
35 */\r
36 #ifndef REDPOSIX_H\r
37 #define REDPOSIX_H\r
38 \r
39 /*  This header is intended for application use; some applications are written\r
40     in C++.\r
41 */\r
42 #ifdef __cplusplus\r
43 extern "C" {\r
44 #endif\r
45 \r
46 #include <redconf.h>\r
47 \r
48 #if REDCONF_API_POSIX == 1\r
49 \r
50 #include <redtypes.h>\r
51 #include "redapimacs.h"\r
52 #include "rederrno.h"\r
53 #include "redstat.h"\r
54 \r
55 /** Open for reading only. */\r
56 #define RED_O_RDONLY    0x00000001U\r
57 \r
58 /** Open for writing only. */\r
59 #define RED_O_WRONLY    0x00000002U\r
60 \r
61 /** Open for reading and writing. */\r
62 #define RED_O_RDWR      0x00000004U\r
63 \r
64 /** File offset for all writes is end-of-file. */\r
65 #define RED_O_APPEND    0x00000008U\r
66 \r
67 /** Create the file. */\r
68 #define RED_O_CREAT     0x00000010U\r
69 \r
70 /** Error if path already exists. */\r
71 #define RED_O_EXCL      0x00000020U\r
72 \r
73 /** Truncate file to size zero. */\r
74 #define RED_O_TRUNC     0x00000040U\r
75 \r
76 \r
77 /** @brief Last file system error (errno).\r
78 \r
79     Under normal circumstances, each task using the file system has an\r
80     independent `red_errno` value.  Applications do not need to worry about\r
81     one task obliterating an error value that another task needed to read.  The\r
82     value is initially zero.  When one of the POSIX-like APIs return an\r
83     indication of error, `red_errno` is set to an error value.\r
84 \r
85     In some circumstances, `red_errno` will be a global errno location which\r
86     is shared by multiple tasks.  If the calling task is not registered as a\r
87     file system user and all of the task slots are full, there can be no\r
88     task-specific errno, so the global errno is used.  Likewise, if the file\r
89     system driver is uninitialized, there are no registered file system users\r
90     and `red_errno` always refers to the global errno.  Under these\r
91     circumstances, multiple tasks manipulating `red_errno` could be\r
92     problematic.  When the task count is set to one, `red_errno` always refers\r
93     to the global errno.\r
94 \r
95     Note that `red_errno` is usable as an lvalue; i.e., in addition to reading\r
96     the error value, the error value can be set:\r
97 \r
98     ~~~{.c}\r
99     red_errno = 0;\r
100     ~~~\r
101 */\r
102 #define red_errno (*red_errnoptr())\r
103 \r
104 \r
105 /** @brief Positions from which to seek within a file.\r
106 */\r
107 typedef enum\r
108 {\r
109     /*  0/1/2 are the traditional values for SET/CUR/END, respectively.  Prior\r
110         to the release of Unix System V in 1983, the SEEK_* symbols did not\r
111         exist and C programs hard-coded the 0/1/2 values with those meanings.\r
112     */\r
113     RED_SEEK_SET = 0,   /**< Set file offset to given offset. */\r
114     RED_SEEK_CUR = 1,   /**< Set file offset to current offset plus signed offset. */\r
115     RED_SEEK_END = 2    /**< Set file offset to EOF plus signed offset. */\r
116 } REDWHENCE;\r
117 \r
118 \r
119 #if REDCONF_API_POSIX_READDIR == 1\r
120 /** @brief Opaque directory handle.\r
121 */\r
122 typedef struct sREDHANDLE REDDIR;\r
123 \r
124 \r
125 /** @brief Directory entry information.\r
126 */\r
127 typedef struct\r
128 {\r
129     uint32_t    d_ino;  /**< File serial number (inode number). */\r
130     char        d_name[REDCONF_NAME_MAX+1U];    /**< Name of entry. */\r
131     REDSTAT     d_stat; /**< File information (POSIX extension). */\r
132 } REDDIRENT;\r
133 #endif\r
134 \r
135 \r
136 int32_t red_init(void);\r
137 int32_t red_uninit(void);\r
138 int32_t red_mount(const char *pszVolume);\r
139 int32_t red_umount(const char *pszVolume);\r
140 #if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_FORMAT == 1)\r
141 int32_t red_format(const char *pszVolume);\r
142 #endif\r
143 #if REDCONF_READ_ONLY == 0\r
144 int32_t red_transact(const char *pszVolume);\r
145 #endif\r
146 #if REDCONF_READ_ONLY == 0\r
147 int32_t red_settransmask(const char *pszVolume, uint32_t ulEventMask);\r
148 #endif\r
149 int32_t red_gettransmask(const char *pszVolume, uint32_t *pulEventMask);\r
150 int32_t red_statvfs(const char *pszVolume, REDSTATFS *pStatvfs);\r
151 int32_t red_open(const char *pszPath, uint32_t ulOpenMode);\r
152 #if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_UNLINK == 1)\r
153 int32_t red_unlink(const char *pszPath);\r
154 #endif\r
155 #if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_MKDIR == 1)\r
156 int32_t red_mkdir(const char *pszPath);\r
157 #endif\r
158 #if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_RMDIR == 1)\r
159 int32_t red_rmdir(const char *pszPath);\r
160 #endif\r
161 #if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_RENAME == 1)\r
162 int32_t red_rename(const char *pszOldPath, const char *pszNewPath);\r
163 #endif\r
164 #if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_LINK == 1)\r
165 int32_t red_link(const char *pszPath, const char *pszHardLink);\r
166 #endif\r
167 int32_t red_close(int32_t iFildes);\r
168 int32_t red_read(int32_t iFildes, void *pBuffer, uint32_t ulLength);\r
169 #if REDCONF_READ_ONLY == 0\r
170 int32_t red_write(int32_t iFildes, const void *pBuffer, uint32_t ulLength);\r
171 #endif\r
172 #if REDCONF_READ_ONLY == 0\r
173 int32_t red_fsync(int32_t iFildes);\r
174 #endif\r
175 int64_t red_lseek(int32_t iFildes, int64_t llOffset, REDWHENCE whence);\r
176 #if (REDCONF_READ_ONLY == 0) && (REDCONF_API_POSIX_FTRUNCATE == 1)\r
177 int32_t red_ftruncate(int32_t iFildes, uint64_t ullSize);\r
178 #endif\r
179 int32_t red_fstat(int32_t iFildes, REDSTAT *pStat);\r
180 #if REDCONF_API_POSIX_READDIR == 1\r
181 REDDIR *red_opendir(const char *pszPath);\r
182 REDDIRENT *red_readdir(REDDIR *pDirStream);\r
183 void red_rewinddir(REDDIR *pDirStream);\r
184 int32_t red_closedir(REDDIR *pDirStream);\r
185 #endif\r
186 REDSTATUS *red_errnoptr(void);\r
187 \r
188 #endif /* REDCONF_API_POSIX */\r
189 \r
190 \r
191 #ifdef __cplusplus\r
192 }\r
193 #endif\r
194 \r
195 #endif\r
196 \r