RTEMS: cpukit/include/rtems/confdefs/libio.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
libio.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef _RTEMS_CONFDEFS_LIBIO_H
37#define _RTEMS_CONFDEFS_LIBIO_H
38
39#ifndef __CONFIGURATION_TEMPLATE_h
40#error "Do not include this file directly, use <rtems/confdefs.h> instead"
41#endif
42
43#ifdef CONFIGURE_INIT
44
45#include <rtems/confdefs/bsp.h>
46#include <rtems/libio.h>
47#include <rtems/sysinit.h>
48
49#ifdef CONFIGURE_FILESYSTEM_ALL
50 #define CONFIGURE_FILESYSTEM_DOSFS
51 #define CONFIGURE_FILESYSTEM_FTPFS
52 #define CONFIGURE_FILESYSTEM_IMFS
53 #define CONFIGURE_FILESYSTEM_JFFS2
54 #define CONFIGURE_FILESYSTEM_NFS
55 #define CONFIGURE_FILESYSTEM_RFS
56 #define CONFIGURE_FILESYSTEM_TFTPFS
57#endif
58
59#ifdef CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
60 #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
61 #error "CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM cannot be used together with CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM"
62 #endif
63
64 #define CONFIGURE_IMFS_DISABLE_CHMOD
65 #define CONFIGURE_IMFS_DISABLE_CHOWN
66 #define CONFIGURE_IMFS_DISABLE_LINK
67 #define CONFIGURE_IMFS_DISABLE_READLINK
68 #define CONFIGURE_IMFS_DISABLE_RENAME
69 #define CONFIGURE_IMFS_DISABLE_SYMLINK
70 #define CONFIGURE_IMFS_DISABLE_UNMOUNT
71 #define CONFIGURE_IMFS_DISABLE_UTIME
72#endif
73
74#ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
75 #define CONFIGURE_IMFS_DISABLE_CHMOD
76 #define CONFIGURE_IMFS_DISABLE_CHOWN
77 #define CONFIGURE_IMFS_DISABLE_LINK
78 #define CONFIGURE_IMFS_DISABLE_MKNOD_FILE
79 #define CONFIGURE_IMFS_DISABLE_MOUNT
80 #define CONFIGURE_IMFS_DISABLE_READDIR
81 #define CONFIGURE_IMFS_DISABLE_READLINK
82 #define CONFIGURE_IMFS_DISABLE_RENAME
83 #define CONFIGURE_IMFS_DISABLE_RMNOD
84 #define CONFIGURE_IMFS_DISABLE_SYMLINK
85 #define CONFIGURE_IMFS_DISABLE_UNMOUNT
86 #define CONFIGURE_IMFS_DISABLE_UTIME
87#endif
88
89#ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
90 #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
91 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM"
92 #endif
93
94 #ifdef CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
95 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM"
96 #endif
97
98 #ifdef CONFIGURE_FILESYSTEM_DOSFS
99 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_DOSFS"
100 #endif
101
102 #ifdef CONFIGURE_FILESYSTEM_FTPFS
103 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_FTPFS"
104 #endif
105
106 #ifdef CONFIGURE_FILESYSTEM_IMFS
107 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_IMFS"
108 #endif
109
110 #ifdef CONFIGURE_FILESYSTEM_JFFS2
111 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_JFFS2"
112 #endif
113
114 #ifdef CONFIGURE_FILESYSTEM_NFS
115 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_NFS"
116 #endif
117
118 #ifdef CONFIGURE_FILESYSTEM_RFS
119 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_RFS"
120 #endif
121
122 #ifdef CONFIGURE_FILESYSTEM_TFTPFS
123 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_TFTPFS"
124 #endif
125#endif
126
127#include <rtems/imfs.h>
128
129#ifdef CONFIGURE_FILESYSTEM_DOSFS
130#include <rtems/dosfs.h>
131#endif
132
133#ifdef CONFIGURE_FILESYSTEM_FTPFS
134#include <rtems/ftpfs.h>
135#endif
136
137#ifdef CONFIGURE_FILESYSTEM_JFFS2
138#include <rtems/jffs2.h>
139#endif
140
141#ifdef CONFIGURE_FILESYSTEM_NFS
142#include <librtemsNfs.h>
143#endif
144
145#ifdef CONFIGURE_FILESYSTEM_RFS
146#include <rtems/rtems-rfs.h>
147#endif
148
149#ifdef CONFIGURE_FILESYSTEM_TFTPFS
150#include <rtems/tftp.h>
151#endif
152
153#ifdef __cplusplus
154extern "C" {
155#endif
156
157#ifndef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
158
159#ifndef CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK
160 #define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK \
161 IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK
162#endif
163
164#if CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 16 && \
165 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 32 && \
166 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 64 && \
167 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 128 && \
168 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 256 && \
169 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 512
170 #error "CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK must be a power of two between 16 and 512"
171#endif
172
173const int imfs_memfile_bytes_per_block = CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK;
174
175static IMFS_fs_info_t IMFS_root_fs_info;
176
177static const rtems_filesystem_operations_table IMFS_root_ops = {
178 rtems_filesystem_default_lock,
179 rtems_filesystem_default_unlock,
180 #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
181 IMFS_eval_path_devfs,
182 #else
183 IMFS_eval_path,
184 #endif
185 #ifdef CONFIGURE_IMFS_DISABLE_LINK
186 rtems_filesystem_default_link,
187 #else
188 IMFS_link,
189 #endif
190 rtems_filesystem_default_are_nodes_equal,
191 #ifdef CONFIGURE_IMFS_DISABLE_MKNOD
192 rtems_filesystem_default_mknod,
193 #else
194 IMFS_mknod,
195 #endif
196 #ifdef CONFIGURE_IMFS_DISABLE_RMNOD
197 rtems_filesystem_default_rmnod,
198 #else
199 IMFS_rmnod,
200 #endif
201 #ifdef CONFIGURE_IMFS_DISABLE_CHMOD
202 rtems_filesystem_default_fchmod,
203 #else
204 IMFS_fchmod,
205 #endif
206 #ifdef CONFIGURE_IMFS_DISABLE_CHOWN
207 rtems_filesystem_default_chown,
208 #else
209 IMFS_chown,
210 #endif
211 IMFS_node_clone,
212 IMFS_node_free,
213 #ifdef CONFIGURE_IMFS_DISABLE_MOUNT
214 rtems_filesystem_default_mount,
215 #else
216 IMFS_mount,
217 #endif
218 #ifdef CONFIGURE_IMFS_DISABLE_UNMOUNT
219 rtems_filesystem_default_unmount,
220 #else
221 IMFS_unmount,
222 #endif
223 rtems_filesystem_default_fsunmount,
224 #ifdef CONFIGURE_IMFS_DISABLE_UTIME
225 rtems_filesystem_default_utime,
226 #else
227 IMFS_utime,
228 #endif
229 #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK
230 rtems_filesystem_default_symlink,
231 #else
232 IMFS_symlink,
233 #endif
234 #ifdef CONFIGURE_IMFS_DISABLE_READLINK
235 rtems_filesystem_default_readlink,
236 #else
237 IMFS_readlink,
238 #endif
239 #ifdef CONFIGURE_IMFS_DISABLE_RENAME
240 rtems_filesystem_default_rename,
241 #else
242 IMFS_rename,
243 #endif
244 rtems_filesystem_default_statvfs
245};
246
247static const IMFS_mknod_controls IMFS_root_mknod_controls = {
248 #ifdef CONFIGURE_IMFS_DISABLE_READDIR
249 &IMFS_mknod_control_dir_minimal,
250 #else
251 &IMFS_mknod_control_dir_default,
252 #endif
253 #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_DEVICE
254 &IMFS_mknod_control_enosys,
255 #else
256 &IMFS_mknod_control_device,
257 #endif
258 #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_FILE
259 &IMFS_mknod_control_enosys,
260 #else
261 &IMFS_mknod_control_memfile,
262 #endif
263 #ifdef CONFIGURE_IMFS_ENABLE_MKFIFO
264 &IMFS_mknod_control_fifo
265 #else
266 &IMFS_mknod_control_enosys
267 #endif
268};
269
270static const IMFS_mount_data IMFS_root_mount_data = {
271 &IMFS_root_fs_info,
272 &IMFS_root_ops,
273 &IMFS_root_mknod_controls
274};
275
276const rtems_filesystem_table_t rtems_filesystem_table[] = {
277 { "/", IMFS_initialize_support },
278 #ifdef CONFIGURE_FILESYSTEM_DOSFS
279 { RTEMS_FILESYSTEM_TYPE_DOSFS, rtems_dosfs_initialize },
280 #endif
281 #ifdef CONFIGURE_FILESYSTEM_FTPFS
282 { RTEMS_FILESYSTEM_TYPE_FTPFS, rtems_ftpfs_initialize },
283 #endif
284 #ifdef CONFIGURE_FILESYSTEM_IMFS
285 { RTEMS_FILESYSTEM_TYPE_IMFS, IMFS_initialize },
286 #endif
287 #ifdef CONFIGURE_FILESYSTEM_JFFS2
288 { RTEMS_FILESYSTEM_TYPE_JFFS2, rtems_jffs2_initialize },
289 #endif
290 #ifdef CONFIGURE_FILESYSTEM_NFS
291 { RTEMS_FILESYSTEM_TYPE_NFS, rtems_nfs_initialize },
292 #endif
293 #ifdef CONFIGURE_FILESYSTEM_RFS
294 { RTEMS_FILESYSTEM_TYPE_RFS, rtems_rfs_rtems_initialise },
295 #endif
296 #ifdef CONFIGURE_FILESYSTEM_TFTPFS
297 { RTEMS_FILESYSTEM_TYPE_TFTPFS, rtems_tftpfs_initialize },
298 #endif
299 { NULL, NULL }
300};
301
302const rtems_filesystem_mount_configuration
303rtems_filesystem_root_configuration = {
304 NULL,
305 NULL,
306 "/",
307 RTEMS_FILESYSTEM_READ_WRITE,
308 &IMFS_root_mount_data
309};
310
311RTEMS_SYSINIT_ITEM(
312 rtems_filesystem_initialize,
313 RTEMS_SYSINIT_ROOT_FILESYSTEM,
314 RTEMS_SYSINIT_ORDER_MIDDLE
315);
316
317#endif /* !CONFIGURE_APPLICATION_DISABLE_FILESYSTEM */
318
319#ifndef CONFIGURE_MAXIMUM_FILE_DESCRIPTORS
320 #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 3
321#endif
322
323 rtems_libio_t rtems_libio_iops[ CONFIGURE_MAXIMUM_FILE_DESCRIPTORS ];
324
325const uint32_t rtems_libio_number_iops = RTEMS_ARRAY_SIZE( rtems_libio_iops );
326
327#ifdef __cplusplus
328}
329#endif
330
331#endif /* CONFIGURE_INIT */
332
333#endif /* _RTEMS_CONFDEFS_LIBIO_H */
NULL
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
bsp.h
Evaluate BSP Related Configuration Options.
dosfs.h
Application Interface to FAT Filesystem.
ftpfs.h
File Transfer Protocol file system (FTP client).
rtems_ftpfs_initialize
int rtems_ftpfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
Do not call directly, use mount().
rtems_filesystem_table
const rtems_filesystem_table_t rtems_filesystem_table[]
Static table of file systems.
IMFS_chown
int IMFS_chown(const rtems_filesystem_location_info_t *loc, uid_t owner, gid_t group)
Change the owner of IMFS.
Definition: imfs_chown.c:28
IMFS_rmnod
int IMFS_rmnod(const rtems_filesystem_location_info_t *parentloc, const rtems_filesystem_location_info_t *loc)
IMFS node removal handler.
Definition: imfs_rmnod.c:27
IMFS_link
int IMFS_link(const rtems_filesystem_location_info_t *parentloc, const rtems_filesystem_location_info_t *targetloc, const char *name, size_t namelen)
Create a new IMFS link node.
Definition: imfs_link.c:26
IMFS_rename
int IMFS_rename(const rtems_filesystem_location_info_t *oldparentloc, const rtems_filesystem_location_info_t *oldloc, const rtems_filesystem_location_info_t *newparentloc, const char *name, size_t namelen)
Rename the IMFS.
Definition: imfs_rename.c:50
IMFS_node_free
void IMFS_node_free(const rtems_filesystem_location_info_t *loc)
Free an IMFS node.
Definition: imfs_node.c:88
IMFS_unmount
int IMFS_unmount(rtems_filesystem_mount_table_entry_t *mt_entry)
Unmount an IMFS.
Definition: imfs_unmount.c:27
IMFS_symlink
int IMFS_symlink(const rtems_filesystem_location_info_t *parentloc, const char *name, size_t namelen, const char *target)
Create a new IMFS symbolic link node.
Definition: imfs_symlink.c:28
IMFS_node_clone
int IMFS_node_clone(rtems_filesystem_location_info_t *loc)
Clone an IMFS node.
Definition: imfs_node.c:72
IMFS_utime
int IMFS_utime(const rtems_filesystem_location_info_t *loc, time_t actime, time_t modtime)
Set IMFS file access and modification times.
Definition: imfs_utime.c:26
IMFS_mount
int IMFS_mount(rtems_filesystem_mount_table_entry_t *mt_entry)
Mount an IMFS.
Definition: imfs_mount.c:27
IMFS_mknod
int IMFS_mknod(const rtems_filesystem_location_info_t *parentloc, const char *name, size_t namelen, mode_t mode, dev_t dev)
Create an IMFS node.
Definition: imfs_mknod.c:44
IMFS_eval_path
void IMFS_eval_path(rtems_filesystem_eval_path_context_t *ctx)
IMFS evaluation node support.
Definition: imfs_eval.c:176
IMFS_readlink
ssize_t IMFS_readlink(const rtems_filesystem_location_info_t *loc, char *buf, size_t bufsize)
Put IMFS symbolic link into buffer.
Definition: imfs_symlink.c:57
IMFS_fchmod
int IMFS_fchmod(const rtems_filesystem_location_info_t *loc, mode_t mode)
Change the IMFS file mode.
Definition: imfs_fchmod.c:24
IMFS_eval_path_devfs
void IMFS_eval_path_devfs(rtems_filesystem_eval_path_context_t *ctx)
IMFS device filesystem evaluation node support.
Definition: imfs_eval_devfs.c:123
rtems_jffs2_initialize
int rtems_jffs2_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
Initialization handler of the JFFS2 file system.
Definition: fs-rtems.c:1216
rtems_filesystem_default_unmount
int rtems_filesystem_default_unmount(rtems_filesystem_mount_table_entry_t *mt_entry)
Definition: default_unmount.c:22
rtems_filesystem_default_lock
void rtems_filesystem_default_lock(const rtems_filesystem_mount_table_entry_t *mt_entry)
Obtains the IO library mutex.
Definition: default_lock_and_unlock.c:29
rtems_filesystem_default_rename
int rtems_filesystem_default_rename(const rtems_filesystem_location_info_t *oldparentloc, const rtems_filesystem_location_info_t *oldloc, const rtems_filesystem_location_info_t *newparentloc, const char *name, size_t namelen)
Definition: default_rename.c:25
rtems_filesystem_default_mknod
int rtems_filesystem_default_mknod(const rtems_filesystem_location_info_t *parentloc, const char *name, size_t namelen, mode_t mode, dev_t dev)
Definition: default_mknod.c:25
rtems_filesystem_default_utime
int rtems_filesystem_default_utime(const rtems_filesystem_location_info_t *loc, time_t actime, time_t modtime)
Definition: default_utime.c:25
rtems_filesystem_default_fchmod
int rtems_filesystem_default_fchmod(const rtems_filesystem_location_info_t *loc, mode_t mode)
Definition: default_fchmod.c:23
rtems_filesystem_default_unlock
void rtems_filesystem_default_unlock(const rtems_filesystem_mount_table_entry_t *mt_entry)
Releases the IO library mutex.
Definition: default_lock_and_unlock.c:36
rtems_filesystem_default_are_nodes_equal
bool rtems_filesystem_default_are_nodes_equal(const rtems_filesystem_location_info_t *a, const rtems_filesystem_location_info_t *b)
Tests if the node access pointer of one location is equal to the node access pointer of the other loc...
Definition: default_are_nodes_equal.c:29
rtems_filesystem_default_rmnod
int rtems_filesystem_default_rmnod(const rtems_filesystem_location_info_t *parentloc, const rtems_filesystem_location_info_t *loc)
Definition: default_rmnod.c:25
rtems_filesystem_default_mount
int rtems_filesystem_default_mount(rtems_filesystem_mount_table_entry_t *mt_entry)
Definition: default_mount.c:22
rtems_filesystem_default_fsunmount
void rtems_filesystem_default_fsunmount(rtems_filesystem_mount_table_entry_t *mt_entry)
Definition: default_fsunmount.c:20
rtems_filesystem_default_symlink
int rtems_filesystem_default_symlink(const rtems_filesystem_location_info_t *parentloc, const char *name, size_t namelen, const char *target)
Definition: default_symlink.c:25
rtems_filesystem_default_statvfs
int rtems_filesystem_default_statvfs(const rtems_filesystem_location_info_t *loc, struct statvfs *buf)
Definition: default_statvfs.c:23
rtems_filesystem_default_chown
int rtems_filesystem_default_chown(const rtems_filesystem_location_info_t *loc, uid_t owner, gid_t group)
Definition: default_chown.c:23
rtems_filesystem_default_readlink
ssize_t rtems_filesystem_default_readlink(const rtems_filesystem_location_info_t *loc, char *buf, size_t bufsize)
Definition: default_readlink.c:25
rtems_filesystem_default_link
int rtems_filesystem_default_link(const rtems_filesystem_location_info_t *parentloc, const rtems_filesystem_location_info_t *targetloc, const char *name, size_t namelen)
Definition: default_link.c:23
rtems_filesystem_initialize
void rtems_filesystem_initialize(void)
Base File System Initialization.
Definition: base_fs.c:32
rtems_rfs_rtems_initialise
int rtems_rfs_rtems_initialise(rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
Definition: rtems-rfs-rtems.c:750
imfs.h
Header File for the In-Memory File System.
libio.h
Basic IO API.
rtems-rfs.h
RFS File system Initialization.
IMFS_fs_info_t
Definition: imfs.h:399
IMFS_mknod_controls
Definition: imfs.h:392
IMFS_mount_data
Definition: imfs.h:404
_rtems_filesystem_operations_table
File system operations table.
Definition: libio.h:472
rtems_filesystem_mount_configuration
Definition: libio.h:1855
rtems_filesystem_table_t
File system table entry.
Definition: libio.h:1656
rtems_libio_tt
An open file data structure.
Definition: libio.h:1320