RTEMS 7.0-rc1
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_FATFS
52 #define CONFIGURE_FILESYSTEM_FTPFS
53 #define CONFIGURE_FILESYSTEM_IMFS
54 #define CONFIGURE_FILESYSTEM_JFFS2
55 /* #define CONFIGURE_FILESYSTEM_NFS See #5118 */
56 #define CONFIGURE_FILESYSTEM_RFS
57 #define CONFIGURE_FILESYSTEM_TFTPFS
58#endif
59
60#ifdef CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
61 #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
62 #error "CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM cannot be used together with CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM"
63 #endif
64
65 #define CONFIGURE_IMFS_DISABLE_CHMOD
66 #define CONFIGURE_IMFS_DISABLE_CHOWN
67 #define CONFIGURE_IMFS_DISABLE_LINK
68 #define CONFIGURE_IMFS_DISABLE_READLINK
69 #define CONFIGURE_IMFS_DISABLE_RENAME
70 #define CONFIGURE_IMFS_DISABLE_SYMLINK
71 #define CONFIGURE_IMFS_DISABLE_UNMOUNT
72 #define CONFIGURE_IMFS_DISABLE_UTIME
73#endif
74
75#ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
76 #define CONFIGURE_IMFS_DISABLE_CHMOD
77 #define CONFIGURE_IMFS_DISABLE_CHOWN
78 #define CONFIGURE_IMFS_DISABLE_LINK
79 #define CONFIGURE_IMFS_DISABLE_MKNOD_FILE
80 #define CONFIGURE_IMFS_DISABLE_MOUNT
81 #define CONFIGURE_IMFS_DISABLE_READDIR
82 #define CONFIGURE_IMFS_DISABLE_READLINK
83 #define CONFIGURE_IMFS_DISABLE_RENAME
84 #define CONFIGURE_IMFS_DISABLE_RMNOD
85 #define CONFIGURE_IMFS_DISABLE_SYMLINK
86 #define CONFIGURE_IMFS_DISABLE_UNMOUNT
87 #define CONFIGURE_IMFS_DISABLE_UTIME
88#endif
89
90#ifndef CONFIGURE_MAXIMUM_FILE_DESCRIPTORS
91 #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 3
92#endif
93
94#if !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) || \
95 CONFIGURE_MAXIMUM_FILE_DESCRIPTORS > 0
96 #include <rtems/libio.h>
97#endif
98
99#ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
100 #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
101 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM"
102 #endif
103
104 #ifdef CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
105 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM"
106 #endif
107
108 #ifdef CONFIGURE_FILESYSTEM_DOSFS
109 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_DOSFS"
110 #endif
111
112 #ifdef CONFIGURE_FILESYSTEM_FATFS
113 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_FATFS"
114 #endif
115
116 #ifdef CONFIGURE_FILESYSTEM_FTPFS
117 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_FTPFS"
118 #endif
119
120 #ifdef CONFIGURE_FILESYSTEM_IMFS
121 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_IMFS"
122 #endif
123
124 #ifdef CONFIGURE_FILESYSTEM_JFFS2
125 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_JFFS2"
126 #endif
127
128 #ifdef CONFIGURE_FILESYSTEM_NFS
129 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_NFS"
130 #endif
131
132 #ifdef CONFIGURE_FILESYSTEM_RFS
133 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_RFS"
134 #endif
135
136 #ifdef CONFIGURE_FILESYSTEM_TFTPFS
137 #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_TFTPFS"
138 #endif
139#else
140 #include <rtems/imfs.h>
141#endif
142
143#ifdef CONFIGURE_FILESYSTEM_DOSFS
144#include <rtems/dosfs.h>
145#endif
146
147#ifdef CONFIGURE_FILESYSTEM_FATFS
148#include <rtems/fatfs.h>
149#endif
150
151#ifdef CONFIGURE_FILESYSTEM_FTPFS
152#include <rtems/ftpfs.h>
153#endif
154
155#ifdef CONFIGURE_FILESYSTEM_JFFS2
156#include <rtems/jffs2.h>
157
158#ifndef CONFIGURE_JFFS2_DELAYED_WRITE_TASK_PRIORITY
159 #define CONFIGURE_JFFS2_DELAYED_WRITE_TASK_PRIORITY \
160 RTEMS_JFFS2_DELAYED_WRITE_TASK_PRIORITY_DEFAULT
161#endif
162
165};
166
167#endif
168
169#ifdef CONFIGURE_FILESYSTEM_NFS
170#include <librtemsNfs.h>
171#endif
172
173#ifdef CONFIGURE_FILESYSTEM_RFS
174#include <rtems/rtems-rfs.h>
175#endif
176
177#ifdef CONFIGURE_FILESYSTEM_TFTPFS
178#include <rtems/tftp.h>
179#endif
180
181#ifdef __cplusplus
182extern "C" {
183#endif
184
185#ifndef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
186
187#ifndef CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK
188 #define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK \
189 IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK
190#endif
191
192#if CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 16 && \
193 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 32 && \
194 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 64 && \
195 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 128 && \
196 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 256 && \
197 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 512 && \
198 CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 1024
199 #error "CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK must be a power of two between 16 and 1024"
200#endif
201
202const size_t imfs_memfile_bytes_per_block =
204
205/*
206 * Using the default ops if user doesn't configure ops
207 */
208#ifndef CONFIGURE_IMFS_MEMFILE_OPS
209 #define CONFIGURE_IMFS_MEMFILE_OPS IMFS_MEMFILE_DEFAULT_OPS
210#endif
211
212IMFS_memfile_ops_t imfs_memfile_ops = CONFIGURE_IMFS_MEMFILE_OPS;
213
214static IMFS_fs_info_t IMFS_root_fs_info;
215
216static const rtems_filesystem_operations_table IMFS_root_ops = {
219 #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
221 #else
223 #endif
224 #ifdef CONFIGURE_IMFS_DISABLE_LINK
226 #else
227 IMFS_link,
228 #endif
230 #ifdef CONFIGURE_IMFS_DISABLE_MKNOD
232 #else
234 #endif
235 #ifdef CONFIGURE_IMFS_DISABLE_RMNOD
237 #else
239 #endif
240 #ifdef CONFIGURE_IMFS_DISABLE_CHMOD
242 #else
244 #endif
245 #ifdef CONFIGURE_IMFS_DISABLE_CHOWN
247 #else
249 #endif
252 #ifdef CONFIGURE_IMFS_DISABLE_MOUNT
254 #else
256 #endif
257 #ifdef CONFIGURE_IMFS_DISABLE_UNMOUNT
259 #else
261 #endif
263 #ifdef CONFIGURE_IMFS_DISABLE_UTIME
265 #else
267 #endif
268 #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK
270 #else
272 #endif
273 #ifdef CONFIGURE_IMFS_DISABLE_READLINK
275 #else
277 #endif
278 #ifdef CONFIGURE_IMFS_DISABLE_RENAME
280 #else
282 #endif
284};
285
286static const IMFS_mknod_controls IMFS_root_mknod_controls = {
287 #ifdef CONFIGURE_IMFS_DISABLE_READDIR
288 &IMFS_mknod_control_dir_minimal,
289 #else
290 &IMFS_mknod_control_dir_default,
291 #endif
292 #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_DEVICE
293 &IMFS_mknod_control_enosys,
294 #else
295 &IMFS_mknod_control_device,
296 #endif
297 #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_FILE
298 &IMFS_mknod_control_enosys,
299 #else
300 &IMFS_mknod_control_memfile,
301 #endif
302 #ifdef CONFIGURE_IMFS_ENABLE_MKFIFO
303 &IMFS_mknod_control_fifo
304 #else
305 &IMFS_mknod_control_enosys
306 #endif
307};
308
309static const IMFS_mount_data IMFS_root_mount_data = {
310 &IMFS_root_fs_info,
311 &IMFS_root_ops,
312 &IMFS_root_mknod_controls
313};
314
316 { "/", IMFS_initialize_support },
317 #ifdef CONFIGURE_FILESYSTEM_DOSFS
318 { RTEMS_FILESYSTEM_TYPE_DOSFS, rtems_dosfs_initialize },
319 #endif
320 #ifdef CONFIGURE_FILESYSTEM_FATFS
321 { RTEMS_FILESYSTEM_TYPE_FATFS, rtems_fatfs_initialize },
322 #endif
323 #ifdef CONFIGURE_FILESYSTEM_FTPFS
324 { RTEMS_FILESYSTEM_TYPE_FTPFS, rtems_ftpfs_initialize },
325 #endif
326 #ifdef CONFIGURE_FILESYSTEM_IMFS
327 { RTEMS_FILESYSTEM_TYPE_IMFS, IMFS_initialize },
328 #endif
329 #ifdef CONFIGURE_FILESYSTEM_JFFS2
330 { RTEMS_FILESYSTEM_TYPE_JFFS2, rtems_jffs2_initialize },
331 #endif
332 #ifdef CONFIGURE_FILESYSTEM_NFS
333 { RTEMS_FILESYSTEM_TYPE_NFS, rtems_nfs_initialize },
334 #endif
335 #ifdef CONFIGURE_FILESYSTEM_RFS
336 { RTEMS_FILESYSTEM_TYPE_RFS, rtems_rfs_rtems_initialise },
337 #endif
338 #ifdef CONFIGURE_FILESYSTEM_TFTPFS
339 { RTEMS_FILESYSTEM_TYPE_TFTPFS, rtems_tftpfs_initialize },
340 #endif
341 { NULL, NULL }
342};
343
345rtems_filesystem_root_configuration = {
346 NULL,
347 NULL,
348 "/",
349 RTEMS_FILESYSTEM_READ_WRITE,
350 &IMFS_root_mount_data
351};
352
355 RTEMS_SYSINIT_ROOT_FILESYSTEM,
356 RTEMS_SYSINIT_ORDER_MIDDLE
357);
358
359#endif /* !CONFIGURE_APPLICATION_DISABLE_FILESYSTEM */
360
361#if CONFIGURE_MAXIMUM_FILE_DESCRIPTORS > 0
363
364 const uint32_t rtems_libio_number_iops = RTEMS_ARRAY_SIZE( rtems_libio_iops );
365#endif
366
367#ifdef __cplusplus
368}
369#endif
370
371#endif /* CONFIGURE_INIT */
372
373#endif /* _RTEMS_CONFDEFS_LIBIO_H */
This header file evaluates configuration options related to the BSP configuration.
Application Interface to FAT Filesystem.
RTEMS FatFS Filesystem Public API.
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:1275
int rtems_fatfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
Initialize FatFS filesystem.
Definition: rtems-fatfs-init.c:150
const rtems_filesystem_table_t rtems_filesystem_table[]
Static table of file systems.
int IMFS_statvfs(const rtems_filesystem_location_info_t *loc, struct statvfs *buf)
Sets buf with the IMFS statistics.
Definition: imfs_statvfs.c:41
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
int IMFS_mount(rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
Mount an IMFS.
Definition: imfs_mount.c:46
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_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:199
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:1369
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:51
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
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_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_mount(rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
Definition: default_mount.c:41
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:2496
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS
This configuration option is an integer define.
Definition: appl-config.h:2920
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:769
This header file defines the API of the In-Memory File System.
Basic IO API.
RFS File system Initialization.
Definition: imfs.h:444
The ops table for user defined allocator-deallocator for IMFS memfile data blocks.
Definition: imfs.h:314
Definition: imfs.h:437
Definition: imfs.h:450
File system operations table.
Definition: libio.h:475
Definition: libio.h:1913
File system table entry.
Definition: libio.h:1714
Definition: jffs2.h:746
An open file data structure.
Definition: libio.h:1325
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.