RTEMS 6.1-rc6
Loading...
Searching...
No Matches
libio.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (C) 2020 embedded brains GmbH & Co. KG
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _RTEMS_CONFDEFS_LIBIO_H
38#define _RTEMS_CONFDEFS_LIBIO_H
39
40#ifndef __CONFIGURATION_TEMPLATE_h
41#error "Do not include this file directly, use <rtems/confdefs.h> instead"
42#endif
43
44#ifdef CONFIGURE_INIT
45
46#include <rtems/confdefs/bsp.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 See #5118 */
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#ifndef CONFIGURE_MAXIMUM_FILE_DESCRIPTORS
90 #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 3
91#endif
92
93#if !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) || \
94 CONFIGURE_MAXIMUM_FILE_DESCRIPTORS > 0
95 #include <rtems/libio.h>
96#endif
97
98#ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
99 #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
100 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM"
101 #endif
102
103 #ifdef CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
104 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM"
105 #endif
106
107 #ifdef CONFIGURE_FILESYSTEM_DOSFS
108 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_DOSFS"
109 #endif
110
111 #ifdef CONFIGURE_FILESYSTEM_FTPFS
112 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_FTPFS"
113 #endif
114
115 #ifdef CONFIGURE_FILESYSTEM_IMFS
116 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_IMFS"
117 #endif
118
119 #ifdef CONFIGURE_FILESYSTEM_JFFS2
120 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_JFFS2"
121 #endif
122
123 #ifdef CONFIGURE_FILESYSTEM_NFS
124 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_NFS"
125 #endif
126
127 #ifdef CONFIGURE_FILESYSTEM_RFS
128 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_RFS"
129 #endif
130
131 #ifdef CONFIGURE_FILESYSTEM_TFTPFS
132 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_TFTPFS"
133 #endif
134#else
135 #include <rtems/imfs.h>
136#endif
137
138#ifdef CONFIGURE_FILESYSTEM_DOSFS
139#include <rtems/dosfs.h>
140#endif
141
142#ifdef CONFIGURE_FILESYSTEM_FTPFS
143#include <rtems/ftpfs.h>
144#endif
145
146#ifdef CONFIGURE_FILESYSTEM_JFFS2
147#include <rtems/jffs2.h>
148
149#ifndef CONFIGURE_JFFS2_DELAYED_WRITE_TASK_PRIORITY
150 #define CONFIGURE_JFFS2_DELAYED_WRITE_TASK_PRIORITY \
151 RTEMS_JFFS2_DELAYED_WRITE_TASK_PRIORITY_DEFAULT
152#endif
153
156};
157
158#endif
159
160#ifdef CONFIGURE_FILESYSTEM_NFS
161#include <librtemsNfs.h>
162#endif
163
164#ifdef CONFIGURE_FILESYSTEM_RFS
165#include <rtems/rtems-rfs.h>
166#endif
167
168#ifdef CONFIGURE_FILESYSTEM_TFTPFS
169#include <rtems/tftp.h>
170#endif
171
172#ifdef __cplusplus
173extern "C" {
174#endif
175
176#ifndef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
177
178#ifndef CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK
179 #define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK \
180 IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK
181#endif
182
183#if CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 16 && \
184 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 32 && \
185 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 64 && \
186 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 128 && \
187 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 256 && \
188 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 512
189 #error "CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK must be a power of two between 16 and 512"
190#endif
191
192const int imfs_memfile_bytes_per_block = CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK;
193
194static IMFS_fs_info_t IMFS_root_fs_info;
195
196static const rtems_filesystem_operations_table IMFS_root_ops = {
199 #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
201 #else
203 #endif
204 #ifdef CONFIGURE_IMFS_DISABLE_LINK
206 #else
207 IMFS_link,
208 #endif
210 #ifdef CONFIGURE_IMFS_DISABLE_MKNOD
212 #else
214 #endif
215 #ifdef CONFIGURE_IMFS_DISABLE_RMNOD
217 #else
219 #endif
220 #ifdef CONFIGURE_IMFS_DISABLE_CHMOD
222 #else
224 #endif
225 #ifdef CONFIGURE_IMFS_DISABLE_CHOWN
227 #else
229 #endif
232 #ifdef CONFIGURE_IMFS_DISABLE_MOUNT
234 #else
236 #endif
237 #ifdef CONFIGURE_IMFS_DISABLE_UNMOUNT
239 #else
241 #endif
243 #ifdef CONFIGURE_IMFS_DISABLE_UTIME
245 #else
247 #endif
248 #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK
250 #else
252 #endif
253 #ifdef CONFIGURE_IMFS_DISABLE_READLINK
255 #else
257 #endif
258 #ifdef CONFIGURE_IMFS_DISABLE_RENAME
260 #else
262 #endif
264};
265
266static const IMFS_mknod_controls IMFS_root_mknod_controls = {
267 #ifdef CONFIGURE_IMFS_DISABLE_READDIR
268 &IMFS_mknod_control_dir_minimal,
269 #else
270 &IMFS_mknod_control_dir_default,
271 #endif
272 #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_DEVICE
273 &IMFS_mknod_control_enosys,
274 #else
275 &IMFS_mknod_control_device,
276 #endif
277 #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_FILE
278 &IMFS_mknod_control_enosys,
279 #else
280 &IMFS_mknod_control_memfile,
281 #endif
282 #ifdef CONFIGURE_IMFS_ENABLE_MKFIFO
283 &IMFS_mknod_control_fifo
284 #else
285 &IMFS_mknod_control_enosys
286 #endif
287};
288
289static const IMFS_mount_data IMFS_root_mount_data = {
290 &IMFS_root_fs_info,
291 &IMFS_root_ops,
292 &IMFS_root_mknod_controls
293};
294
296 { "/", IMFS_initialize_support },
297 #ifdef CONFIGURE_FILESYSTEM_DOSFS
298 { RTEMS_FILESYSTEM_TYPE_DOSFS, rtems_dosfs_initialize },
299 #endif
300 #ifdef CONFIGURE_FILESYSTEM_FTPFS
301 { RTEMS_FILESYSTEM_TYPE_FTPFS, rtems_ftpfs_initialize },
302 #endif
303 #ifdef CONFIGURE_FILESYSTEM_IMFS
304 { RTEMS_FILESYSTEM_TYPE_IMFS, IMFS_initialize },
305 #endif
306 #ifdef CONFIGURE_FILESYSTEM_JFFS2
307 { RTEMS_FILESYSTEM_TYPE_JFFS2, rtems_jffs2_initialize },
308 #endif
309 #ifdef CONFIGURE_FILESYSTEM_NFS
310 { RTEMS_FILESYSTEM_TYPE_NFS, rtems_nfs_initialize },
311 #endif
312 #ifdef CONFIGURE_FILESYSTEM_RFS
313 { RTEMS_FILESYSTEM_TYPE_RFS, rtems_rfs_rtems_initialise },
314 #endif
315 #ifdef CONFIGURE_FILESYSTEM_TFTPFS
316 { RTEMS_FILESYSTEM_TYPE_TFTPFS, rtems_tftpfs_initialize },
317 #endif
318 { NULL, NULL }
319};
320
322rtems_filesystem_root_configuration = {
323 NULL,
324 NULL,
325 "/",
326 RTEMS_FILESYSTEM_READ_WRITE,
327 &IMFS_root_mount_data
328};
329
332 RTEMS_SYSINIT_ROOT_FILESYSTEM,
333 RTEMS_SYSINIT_ORDER_MIDDLE
334);
335
336#endif /* !CONFIGURE_APPLICATION_DISABLE_FILESYSTEM */
337
338#if CONFIGURE_MAXIMUM_FILE_DESCRIPTORS > 0
340
341 const uint32_t rtems_libio_number_iops = RTEMS_ARRAY_SIZE( rtems_libio_iops );
342#endif
343
344#ifdef __cplusplus
345}
346#endif
347
348#endif /* CONFIGURE_INIT */
349
350#endif /* _RTEMS_CONFDEFS_LIBIO_H */
This header file evaluates configuration options related to the BSP configuration.
Application Interface to FAT Filesystem.
File Transfer Protocol file system (FTP client).
int rtems_ftpfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
Do not call directly, use mount().
Definition: ftpfs.c:1266
const rtems_filesystem_table_t rtems_filesystem_table[]
Static table of file systems.
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:47
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:46
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:45
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:69
void IMFS_node_free(const rtems_filesystem_location_info_t *loc)
Free an IMFS node.
Definition: imfs_node.c:107
int IMFS_unmount(rtems_filesystem_mount_table_entry_t *mt_entry)
Unmount an IMFS.
Definition: imfs_unmount.c:46
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:47
int IMFS_node_clone(rtems_filesystem_location_info_t *loc)
Clone an IMFS node.
Definition: imfs_node.c:91
int IMFS_mount(rtems_filesystem_mount_table_entry_t *mt_entry)
Mount an IMFS.
Definition: imfs_mount.c:46
int IMFS_utimens(const rtems_filesystem_location_info_t *loc, struct timespec times[2])
Set IMFS file access and modification times.
Definition: imfs_utimens.c:44
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:63
void IMFS_eval_path(rtems_filesystem_eval_path_context_t *ctx)
IMFS evaluation node support.
Definition: imfs_eval.c:195
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:76
int IMFS_fchmod(const rtems_filesystem_location_info_t *loc, mode_t mode)
Change the IMFS file mode.
Definition: imfs_fchmod.c:43
void IMFS_eval_path_devfs(rtems_filesystem_eval_path_context_t *ctx)
IMFS device filesystem evaluation node support.
Definition: imfs_eval_devfs.c:123
const rtems_jffs2_config jffs2_config
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:1363
int rtems_filesystem_default_unmount(rtems_filesystem_mount_table_entry_t *mt_entry)
Definition: default_unmount.c:41
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:42
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:44
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:44
int rtems_filesystem_default_fchmod(const rtems_filesystem_location_info_t *loc, mode_t mode)
Definition: default_fchmod.c:42
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:49
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:42
int rtems_filesystem_default_rmnod(const rtems_filesystem_location_info_t *parentloc, const rtems_filesystem_location_info_t *loc)
Definition: default_rmnod.c:44
int rtems_filesystem_default_mount(rtems_filesystem_mount_table_entry_t *mt_entry)
Definition: default_mount.c:41
void rtems_filesystem_default_fsunmount(rtems_filesystem_mount_table_entry_t *mt_entry)
Definition: default_fsunmount.c:39
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:44
int rtems_filesystem_default_statvfs(const rtems_filesystem_location_info_t *loc, struct statvfs *buf)
Definition: default_statvfs.c:42
int rtems_filesystem_default_chown(const rtems_filesystem_location_info_t *loc, uid_t owner, gid_t group)
Definition: default_chown.c:42
ssize_t rtems_filesystem_default_readlink(const rtems_filesystem_location_info_t *loc, char *buf, size_t bufsize)
Definition: default_readlink.c:44
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:42
int rtems_filesystem_default_utimens(const rtems_filesystem_location_info_t *loc, struct timespec times[2])
Definition: default_utimens.c:43
void rtems_filesystem_initialize(void)
Base File System Initialization.
Definition: base_fs.c:51
#define RTEMS_ARRAY_SIZE(_array)
Gets the element count of the array.
Definition: basedefs.h:244
#define RTEMS_SYSINIT_ITEM(handler, module, order)
Creates the system initialization item associated with the handler, module, and order.
Definition: sysinit.h:204
#define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK
This configuration option is an integer define.
Definition: appl-config.h:2476
#define CONFIGURE_JFFS2_DELAYED_WRITE_TASK_PRIORITY
This configuration option is an integer define.
Definition: appl-config.h:2504
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS
This configuration option is an integer define.
Definition: appl-config.h:2928
int rtems_tftpfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
Do not call directly, use mount().
Definition: tftpfs.c:150
int rtems_rfs_rtems_initialise(rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
Definition: rtems-rfs-rtems.c:767
This header file defines the API of the In-Memory File System.
Basic IO API.
RFS File system Initialization.
Definition: imfs.h:381
Definition: imfs.h:374
Definition: imfs.h:386
File system operations table.
Definition: libio.h:489
Definition: libio.h:1874
File system table entry.
Definition: libio.h:1675
Definition: jffs2.h:746
An open file data structure.
Definition: libio.h:1338
This header file provides the API of the System Initialization Support.
This header file provides interfaces and functions used to implement the TFTP file system.