RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 = {
180 #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
182 #else
184 #endif
185 #ifdef CONFIGURE_IMFS_DISABLE_LINK
187 #else
188 IMFS_link,
189 #endif
191 #ifdef CONFIGURE_IMFS_DISABLE_MKNOD
193 #else
195 #endif
196 #ifdef CONFIGURE_IMFS_DISABLE_RMNOD
198 #else
200 #endif
201 #ifdef CONFIGURE_IMFS_DISABLE_CHMOD
203 #else
205 #endif
206 #ifdef CONFIGURE_IMFS_DISABLE_CHOWN
208 #else
210 #endif
213 #ifdef CONFIGURE_IMFS_DISABLE_MOUNT
215 #else
217 #endif
218 #ifdef CONFIGURE_IMFS_DISABLE_UNMOUNT
220 #else
222 #endif
224 #ifdef CONFIGURE_IMFS_DISABLE_UTIME
226 #else
228 #endif
229 #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK
231 #else
233 #endif
234 #ifdef CONFIGURE_IMFS_DISABLE_READLINK
236 #else
238 #endif
239 #ifdef CONFIGURE_IMFS_DISABLE_RENAME
241 #else
243 #endif
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
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
303rtems_filesystem_root_configuration = {
304 NULL,
305 NULL,
306 "/",
307 RTEMS_FILESYSTEM_READ_WRITE,
308 &IMFS_root_mount_data
309};
310
311RTEMS_SYSINIT_ITEM(
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
323rtems_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 */
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
Evaluate BSP Related Configuration Options.
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().
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:28
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
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
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
void IMFS_node_free(const rtems_filesystem_location_info_t *loc)
Free an IMFS node.
Definition: imfs_node.c:88
int IMFS_unmount(rtems_filesystem_mount_table_entry_t *mt_entry)
Unmount an IMFS.
Definition: imfs_unmount.c:27
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
int IMFS_node_clone(rtems_filesystem_location_info_t *loc)
Clone an IMFS node.
Definition: imfs_node.c:72
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
int IMFS_mount(rtems_filesystem_mount_table_entry_t *mt_entry)
Mount an IMFS.
Definition: imfs_mount.c:27
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
void IMFS_eval_path(rtems_filesystem_eval_path_context_t *ctx)
IMFS evaluation node support.
Definition: imfs_eval.c:176
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
int IMFS_fchmod(const rtems_filesystem_location_info_t *loc, mode_t mode)
Change the IMFS file mode.
Definition: imfs_fchmod.c:24
void IMFS_eval_path_devfs(rtems_filesystem_eval_path_context_t *ctx)
IMFS device filesystem evaluation node support.
Definition: imfs_eval_devfs.c:123
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
int rtems_filesystem_default_unmount(rtems_filesystem_mount_table_entry_t *mt_entry)
Definition: default_unmount.c:22
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
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
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
int rtems_filesystem_default_utime(const rtems_filesystem_location_info_t *loc, time_t actime, time_t modtime)
Definition: default_utime.c:25
int rtems_filesystem_default_fchmod(const rtems_filesystem_location_info_t *loc, mode_t mode)
Definition: default_fchmod.c:23
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
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
int rtems_filesystem_default_rmnod(const rtems_filesystem_location_info_t *parentloc, const rtems_filesystem_location_info_t *loc)
Definition: default_rmnod.c:25
int rtems_filesystem_default_mount(rtems_filesystem_mount_table_entry_t *mt_entry)
Definition: default_mount.c:22
void rtems_filesystem_default_fsunmount(rtems_filesystem_mount_table_entry_t *mt_entry)
Definition: default_fsunmount.c:20
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
int rtems_filesystem_default_statvfs(const rtems_filesystem_location_info_t *loc, struct statvfs *buf)
Definition: default_statvfs.c:23
int rtems_filesystem_default_chown(const rtems_filesystem_location_info_t *loc, uid_t owner, gid_t group)
Definition: default_chown.c:23
ssize_t rtems_filesystem_default_readlink(const rtems_filesystem_location_info_t *loc, char *buf, size_t bufsize)
Definition: default_readlink.c:25
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
void rtems_filesystem_initialize(void)
Base File System Initialization.
Definition: base_fs.c:32
int rtems_rfs_rtems_initialise(rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
Definition: rtems-rfs-rtems.c:750
Header File for the In-Memory File System.
Basic IO API.
RFS File system Initialization.
Definition: imfs.h:399
Definition: imfs.h:392
Definition: imfs.h:404
File system operations table.
Definition: libio.h:472
Definition: libio.h:1855
File system table entry.
Definition: libio.h:1656
An open file data structure.
Definition: libio.h:1320