1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup LibIO |
---|
5 | * |
---|
6 | * @brief Basic IO API. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2008. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * Modifications to support reference counting in the file system are |
---|
14 | * Copyright (c) 2012 embedded brains GmbH. |
---|
15 | * |
---|
16 | * The license and distribution terms for this file may be |
---|
17 | * found in the file LICENSE in this distribution or at |
---|
18 | * http://www.rtems.com/license/LICENSE. |
---|
19 | * |
---|
20 | * $Id$ |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef _RTEMS_RTEMS_LIBIO_H |
---|
24 | #define _RTEMS_RTEMS_LIBIO_H |
---|
25 | |
---|
26 | #include <sys/types.h> |
---|
27 | #include <sys/stat.h> |
---|
28 | #include <sys/ioctl.h> |
---|
29 | #include <sys/statvfs.h> |
---|
30 | |
---|
31 | #include <unistd.h> |
---|
32 | #include <termios.h> |
---|
33 | |
---|
34 | #include <rtems.h> |
---|
35 | #include <rtems/fs.h> |
---|
36 | #include <rtems/chain.h> |
---|
37 | |
---|
38 | #ifdef __cplusplus |
---|
39 | extern "C" { |
---|
40 | #endif |
---|
41 | |
---|
42 | /** |
---|
43 | * @defgroup LibIOFSOps File System Operations |
---|
44 | * |
---|
45 | * @ingroup LibIO |
---|
46 | * |
---|
47 | * @brief File system operations. |
---|
48 | * |
---|
49 | * @{ |
---|
50 | */ |
---|
51 | |
---|
52 | /** |
---|
53 | * @brief File system node types. |
---|
54 | */ |
---|
55 | typedef enum { |
---|
56 | RTEMS_FILESYSTEM_DIRECTORY, |
---|
57 | RTEMS_FILESYSTEM_DEVICE, |
---|
58 | RTEMS_FILESYSTEM_HARD_LINK, |
---|
59 | RTEMS_FILESYSTEM_SYM_LINK, |
---|
60 | RTEMS_FILESYSTEM_MEMORY_FILE, |
---|
61 | RTEMS_FILESYSTEM_INVALID_NODE_TYPE |
---|
62 | } rtems_filesystem_node_types_t; |
---|
63 | |
---|
64 | /** |
---|
65 | * @brief Locks a file system instance. |
---|
66 | * |
---|
67 | * This lock must allow nesting. |
---|
68 | * |
---|
69 | * @param[in, out] mt_entry The mount table entry of the file system instance. |
---|
70 | * |
---|
71 | * @see rtems_filesystem_default_lock(). |
---|
72 | */ |
---|
73 | typedef void (*rtems_filesystem_mt_entry_lock_t)( |
---|
74 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
75 | ); |
---|
76 | |
---|
77 | /** |
---|
78 | * @brief Unlocks a file system instance. |
---|
79 | * |
---|
80 | * @param[in, out] mt_entry The mount table entry of the file system instance. |
---|
81 | * |
---|
82 | * @see rtems_filesystem_default_unlock(). |
---|
83 | */ |
---|
84 | typedef void (*rtems_filesystem_mt_entry_unlock_t)( |
---|
85 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
86 | ); |
---|
87 | |
---|
88 | /** |
---|
89 | * @brief Path evaluation context. |
---|
90 | */ |
---|
91 | typedef struct { |
---|
92 | /** |
---|
93 | * The contents of the remaining path to be evaluated. |
---|
94 | */ |
---|
95 | const char *path; |
---|
96 | |
---|
97 | /** |
---|
98 | * The length of the remaining path to be evaluated. |
---|
99 | */ |
---|
100 | size_t pathlen; |
---|
101 | |
---|
102 | /** |
---|
103 | * The contents of the token to be evaluated with respect to the current |
---|
104 | * location. |
---|
105 | */ |
---|
106 | const char *token; |
---|
107 | |
---|
108 | /** |
---|
109 | * The length of the token to be evaluated with respect to the current |
---|
110 | * location. |
---|
111 | */ |
---|
112 | size_t tokenlen; |
---|
113 | |
---|
114 | /** |
---|
115 | * The path evaluation is controlled by the following flags |
---|
116 | * - RTEMS_LIBIO_PERMS_READ, |
---|
117 | * - RTEMS_LIBIO_PERMS_WRITE, |
---|
118 | * - RTEMS_LIBIO_PERMS_EXEC, |
---|
119 | * - RTEMS_LIBIO_PERMS_SEARCH, |
---|
120 | * - RTEMS_LIBIO_FOLLOW_HARD_LINK, |
---|
121 | * - RTEMS_LIBIO_FOLLOW_SYM_LINK, |
---|
122 | * - RTEMS_LIBIO_MAKE, |
---|
123 | * - RTEMS_LIBIO_EXCLUSIVE, |
---|
124 | * - RTEMS_LIBIO_ACCEPT_RESIDUAL_DELIMITERS, and |
---|
125 | * - RTEMS_LIBIO_REJECT_TERMINAL_DOT. |
---|
126 | */ |
---|
127 | int flags; |
---|
128 | |
---|
129 | /** |
---|
130 | * Symbolic link evaluation is a recursive operation. This field helps to |
---|
131 | * limit the recursion level and thus prevents a stack overflow. The |
---|
132 | * recursion level is limited by RTEMS_FILESYSTEM_SYMLOOP_MAX. |
---|
133 | */ |
---|
134 | int recursionlevel; |
---|
135 | |
---|
136 | /** |
---|
137 | * This is the current file system location of the evaluation process. |
---|
138 | * Tokens are evaluated with respect to the current location. The token |
---|
139 | * interpretation may change the current location. The purpose of the path |
---|
140 | * evaluation is to change the start location into a final current location |
---|
141 | * according to the path. |
---|
142 | */ |
---|
143 | rtems_filesystem_location_info_t currentloc; |
---|
144 | |
---|
145 | /** |
---|
146 | * The location of the root directory of the user environment during the |
---|
147 | * evaluation start. |
---|
148 | */ |
---|
149 | rtems_filesystem_global_location_t *rootloc; |
---|
150 | |
---|
151 | /** |
---|
152 | * The start location of the evaluation process. The start location my |
---|
153 | * change during symbolic link evaluation. |
---|
154 | */ |
---|
155 | rtems_filesystem_global_location_t *startloc; |
---|
156 | } rtems_filesystem_eval_path_context_t; |
---|
157 | |
---|
158 | /** |
---|
159 | * @brief Path evaluation. |
---|
160 | * |
---|
161 | * @param[in, out] ctx The path evaluation context. |
---|
162 | * |
---|
163 | * @see rtems_filesystem_default_eval_path(). |
---|
164 | */ |
---|
165 | typedef void (*rtems_filesystem_eval_path_t)( |
---|
166 | rtems_filesystem_eval_path_context_t *ctx |
---|
167 | ); |
---|
168 | |
---|
169 | /** |
---|
170 | * @brief Creates a new link for the existing file. |
---|
171 | * |
---|
172 | * @param[in] parentloc The location of the parent of the new link. |
---|
173 | * @param[in] targetloc The location of the target file. |
---|
174 | * @param[in] name Name for the new link. |
---|
175 | * @param[in] namelen Length of the name for the new link in characters. |
---|
176 | * |
---|
177 | * @retval 0 Successful operation. |
---|
178 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
179 | * |
---|
180 | * @see rtems_filesystem_default_link(). |
---|
181 | */ |
---|
182 | typedef int (*rtems_filesystem_link_t)( |
---|
183 | const rtems_filesystem_location_info_t *parentloc, |
---|
184 | const rtems_filesystem_location_info_t *targetloc, |
---|
185 | const char *name, |
---|
186 | size_t namelen |
---|
187 | ); |
---|
188 | |
---|
189 | /** |
---|
190 | * @brief Changes the mode of a node. |
---|
191 | * |
---|
192 | * @param[in] loc The location of the node. |
---|
193 | * @param[in] mode The new mode of the node |
---|
194 | * |
---|
195 | * @retval 0 Successful operation. |
---|
196 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
197 | * |
---|
198 | * @see rtems_filesystem_default_fchmod(). |
---|
199 | */ |
---|
200 | typedef int (*rtems_filesystem_fchmod_t)( |
---|
201 | const rtems_filesystem_location_info_t *loc, |
---|
202 | mode_t mode |
---|
203 | ); |
---|
204 | |
---|
205 | /** |
---|
206 | * @brief Changes owner and group of a node. |
---|
207 | * |
---|
208 | * @param[in] loc The location of the node. |
---|
209 | * @param[in] owner User ID for the node. |
---|
210 | * @param[in] group Group ID for the node. |
---|
211 | * |
---|
212 | * @retval 0 Successful operation. |
---|
213 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
214 | * |
---|
215 | * @see rtems_filesystem_default_chown(). |
---|
216 | */ |
---|
217 | typedef int (*rtems_filesystem_chown_t)( |
---|
218 | const rtems_filesystem_location_info_t *loc, |
---|
219 | uid_t owner, |
---|
220 | gid_t group |
---|
221 | ); |
---|
222 | |
---|
223 | /** |
---|
224 | * @brief Clones a location. |
---|
225 | * |
---|
226 | * The location is initialized with a bitwise copy of an existing location. |
---|
227 | * The caller must ensure that this location is protected from a release during |
---|
228 | * the clone operation. After a successful clone operation the clone will be |
---|
229 | * added to the location chain of the corresponding mount table entry. |
---|
230 | * |
---|
231 | * @param[in, out] loc Location to clone. |
---|
232 | * |
---|
233 | * @retval 0 Successful operation. |
---|
234 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
235 | * |
---|
236 | * @see rtems_filesystem_default_clonenode(). |
---|
237 | */ |
---|
238 | typedef int (*rtems_filesystem_clonenode_t)( |
---|
239 | rtems_filesystem_location_info_t *loc |
---|
240 | ); |
---|
241 | |
---|
242 | /** |
---|
243 | * @brief Frees the location of a node. |
---|
244 | * |
---|
245 | * @param[in] loc The location of the node. |
---|
246 | * |
---|
247 | * @see rtems_filesystem_default_freenode(). |
---|
248 | */ |
---|
249 | typedef void (*rtems_filesystem_freenode_t)( |
---|
250 | const rtems_filesystem_location_info_t *loc |
---|
251 | ); |
---|
252 | |
---|
253 | /** |
---|
254 | * @brief Mounts a file system instance in a mount point (directory). |
---|
255 | * |
---|
256 | * The mount point belongs to the file system instance of the handler and is |
---|
257 | * specified by a field of the mount table entry. The handler must check that |
---|
258 | * the mount point is capable of mounting a file system instance. This is the |
---|
259 | * last step during the mount process. The file system instance is fully |
---|
260 | * initialized at this point. |
---|
261 | * |
---|
262 | * @param[in] mt_entry The mount table entry. |
---|
263 | * |
---|
264 | * @retval 0 Successful operation. |
---|
265 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
266 | * |
---|
267 | * @see rtems_filesystem_default_mount(). |
---|
268 | */ |
---|
269 | typedef int (*rtems_filesystem_mount_t) ( |
---|
270 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
271 | ); |
---|
272 | |
---|
273 | /** |
---|
274 | * @brief Initializes a file system instance. |
---|
275 | * |
---|
276 | * This function must initialize the file system root node in the mount table |
---|
277 | * entry. |
---|
278 | * |
---|
279 | * @param[in] mt_entry The mount table entry. |
---|
280 | * @param[in] data The data provided by the user. |
---|
281 | * |
---|
282 | * @retval 0 Successful operation. |
---|
283 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
284 | */ |
---|
285 | typedef int (*rtems_filesystem_fsmount_me_t)( |
---|
286 | rtems_filesystem_mount_table_entry_t *mt_entry, |
---|
287 | const void *data |
---|
288 | ); |
---|
289 | |
---|
290 | /** |
---|
291 | * @brief Unmounts a file system instance in a mount point (directory). |
---|
292 | * |
---|
293 | * In case this function is successful the file system instance will be marked |
---|
294 | * as unmounted. The file system instance will be destroyed when the last |
---|
295 | * reference to it vanishes. |
---|
296 | * |
---|
297 | * @param[in] mt_entry The mount table entry. |
---|
298 | * |
---|
299 | * @retval 0 Successful operation. |
---|
300 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
301 | * |
---|
302 | * @see rtems_filesystem_default_unmount(). |
---|
303 | */ |
---|
304 | typedef int (*rtems_filesystem_unmount_t) ( |
---|
305 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
306 | ); |
---|
307 | |
---|
308 | /** |
---|
309 | * @brief Destroys a file system instance. |
---|
310 | * |
---|
311 | * The mount point node location of the mount table entry is invalid. This |
---|
312 | * handler must free the file system root location and all remaining resources |
---|
313 | * of the file system instance. |
---|
314 | * |
---|
315 | * @param[in] mt_entry The mount table entry. |
---|
316 | * |
---|
317 | * @see rtems_filesystem_default_fsunmount(). |
---|
318 | */ |
---|
319 | typedef void (*rtems_filesystem_fsunmount_me_t)( |
---|
320 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
321 | ); |
---|
322 | |
---|
323 | /** |
---|
324 | * @brief Tests if the node of one location is equal to the node of the other |
---|
325 | * location. |
---|
326 | * |
---|
327 | * The caller ensures that both nodes are within the same file system instance. |
---|
328 | * |
---|
329 | * @param[in] a The one location. |
---|
330 | * @param[in] b The other location. |
---|
331 | * |
---|
332 | * @retval true The nodes of the locations are equal. |
---|
333 | * @retval false Otherwise. |
---|
334 | * |
---|
335 | * @see rtems_filesystem_default_are_nodes_equal(). |
---|
336 | */ |
---|
337 | typedef bool (*rtems_filesystem_are_nodes_equal_t)( |
---|
338 | const rtems_filesystem_location_info_t *a, |
---|
339 | const rtems_filesystem_location_info_t *b |
---|
340 | ); |
---|
341 | |
---|
342 | /** |
---|
343 | * @brief Returns the node type. |
---|
344 | * |
---|
345 | * @param[in] loc The location of the node. |
---|
346 | * |
---|
347 | * @return Type of the node. |
---|
348 | * |
---|
349 | * @see rtems_filesystem_default_node_type(). |
---|
350 | */ |
---|
351 | typedef rtems_filesystem_node_types_t (*rtems_filesystem_node_type_t)( |
---|
352 | const rtems_filesystem_location_info_t *loc |
---|
353 | ); |
---|
354 | |
---|
355 | /** |
---|
356 | * @brief Creates a new node. |
---|
357 | * |
---|
358 | * This handler should create a new node according to the parameters. |
---|
359 | * |
---|
360 | * @param[in] parentloc The location of the parent of the new node. |
---|
361 | * @param[in] name Name for the new node. |
---|
362 | * @param[in] namelen Length of the name for the new node in characters. |
---|
363 | * @param[in] mode Mode for the new node. |
---|
364 | * @param[in] dev Optional device identifier for the new node. |
---|
365 | * |
---|
366 | * @retval 0 Successful operation. |
---|
367 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
368 | * |
---|
369 | * @see rtems_filesystem_default_mknod(). |
---|
370 | */ |
---|
371 | typedef int (*rtems_filesystem_mknod_t)( |
---|
372 | const rtems_filesystem_location_info_t *parentloc, |
---|
373 | const char *name, |
---|
374 | size_t namelen, |
---|
375 | mode_t mode, |
---|
376 | dev_t dev |
---|
377 | ); |
---|
378 | |
---|
379 | /** |
---|
380 | * @brief Removes a node. |
---|
381 | * |
---|
382 | * @param[in] parentloc The location of the parent of the node. |
---|
383 | * @param[in] loc The location of the node. |
---|
384 | * |
---|
385 | * @retval 0 Successful operation. |
---|
386 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
387 | * |
---|
388 | * @see rtems_filesystem_default_rmnod(). |
---|
389 | */ |
---|
390 | typedef int (*rtems_filesystem_rmnod_t)( |
---|
391 | const rtems_filesystem_location_info_t *parentloc, |
---|
392 | const rtems_filesystem_location_info_t *loc |
---|
393 | ); |
---|
394 | |
---|
395 | /** |
---|
396 | * @brief Set node access and modification times. |
---|
397 | * |
---|
398 | * @param[in] loc The location of the node. |
---|
399 | * @param[in] actime Access time for the node. |
---|
400 | * @param[in] modtime Modification for the node. |
---|
401 | * |
---|
402 | * @retval 0 Successful operation. |
---|
403 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
404 | * |
---|
405 | * @see rtems_filesystem_default_utime(). |
---|
406 | */ |
---|
407 | typedef int (*rtems_filesystem_utime_t)( |
---|
408 | const rtems_filesystem_location_info_t *loc, |
---|
409 | time_t actime, |
---|
410 | time_t modtime |
---|
411 | ); |
---|
412 | |
---|
413 | /** |
---|
414 | * @brief Makes a symbolic link to a node. |
---|
415 | * |
---|
416 | * @param[in] parentloc The location of the parent of the new symbolic link. |
---|
417 | * @param[in] name Name for the new symbolic link. |
---|
418 | * @param[in] namelen Length of the name for the new symbolic link in |
---|
419 | * characters. |
---|
420 | * @param[in] target Contents for the symbolic link. |
---|
421 | * |
---|
422 | * @retval 0 Successful operation. |
---|
423 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
424 | * |
---|
425 | * @see rtems_filesystem_default_symlink(). |
---|
426 | */ |
---|
427 | typedef int (*rtems_filesystem_symlink_t)( |
---|
428 | const rtems_filesystem_location_info_t *parentloc, |
---|
429 | const char *name, |
---|
430 | size_t namelen, |
---|
431 | const char *target |
---|
432 | ); |
---|
433 | |
---|
434 | /** |
---|
435 | * @brief Reads the contents of a symbolic link. |
---|
436 | * |
---|
437 | * @param[in] loc The location of the symbolic link. |
---|
438 | * @param[out] buf The buffer for the contents. |
---|
439 | * @param[in] bufsize The size of the buffer in characters. |
---|
440 | * |
---|
441 | * @retval non-negative Size of the actual contents in characters. |
---|
442 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
443 | * |
---|
444 | * @see rtems_filesystem_default_readlink(). |
---|
445 | */ |
---|
446 | typedef ssize_t (*rtems_filesystem_readlink_t)( |
---|
447 | const rtems_filesystem_location_info_t *loc, |
---|
448 | char *buf, |
---|
449 | size_t bufsize |
---|
450 | ); |
---|
451 | |
---|
452 | /** |
---|
453 | * @brief Renames a node. |
---|
454 | * |
---|
455 | * @param[in] oldparentloc The location of the parent of the old node. |
---|
456 | * @param[in] oldloc The location of the old node. |
---|
457 | * @param[in] newparentloc The location of the parent of the new node. |
---|
458 | * @param[in] name Name for the new node. |
---|
459 | * @param[in] namelen Length of the name for the new node in characters. |
---|
460 | * |
---|
461 | * @retval 0 Successful operation. |
---|
462 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
463 | * |
---|
464 | * @see rtems_filesystem_default_rename(). |
---|
465 | */ |
---|
466 | typedef int (*rtems_filesystem_rename_t)( |
---|
467 | const rtems_filesystem_location_info_t *oldparentloc, |
---|
468 | const rtems_filesystem_location_info_t *oldloc, |
---|
469 | const rtems_filesystem_location_info_t *newparentloc, |
---|
470 | const char *name, |
---|
471 | size_t namelen |
---|
472 | ); |
---|
473 | |
---|
474 | /** |
---|
475 | * @brief Gets file system information. |
---|
476 | * |
---|
477 | * @param[in] loc The location of a node. |
---|
478 | * @param[out] buf Buffer for file system information. |
---|
479 | * |
---|
480 | * @retval 0 Successful operation. |
---|
481 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
482 | * |
---|
483 | * @see rtems_filesystem_default_statvfs(). |
---|
484 | */ |
---|
485 | typedef int (*rtems_filesystem_statvfs_t)( |
---|
486 | const rtems_filesystem_location_info_t *loc, |
---|
487 | struct statvfs *buf |
---|
488 | ); |
---|
489 | |
---|
490 | /** |
---|
491 | * @brief File system operations table. |
---|
492 | */ |
---|
493 | struct _rtems_filesystem_operations_table { |
---|
494 | rtems_filesystem_mt_entry_lock_t lock_h; |
---|
495 | rtems_filesystem_mt_entry_unlock_t unlock_h; |
---|
496 | rtems_filesystem_eval_path_t eval_path_h; |
---|
497 | rtems_filesystem_link_t link_h; |
---|
498 | rtems_filesystem_are_nodes_equal_t are_nodes_equal_h; |
---|
499 | rtems_filesystem_node_type_t node_type_h; |
---|
500 | rtems_filesystem_mknod_t mknod_h; |
---|
501 | rtems_filesystem_rmnod_t rmnod_h; |
---|
502 | rtems_filesystem_fchmod_t fchmod_h; |
---|
503 | rtems_filesystem_chown_t chown_h; |
---|
504 | rtems_filesystem_clonenode_t clonenod_h; |
---|
505 | rtems_filesystem_freenode_t freenod_h; |
---|
506 | rtems_filesystem_mount_t mount_h; |
---|
507 | rtems_filesystem_fsmount_me_t fsmount_me_h; |
---|
508 | rtems_filesystem_unmount_t unmount_h; |
---|
509 | rtems_filesystem_fsunmount_me_t fsunmount_me_h; |
---|
510 | rtems_filesystem_utime_t utime_h; |
---|
511 | rtems_filesystem_symlink_t symlink_h; |
---|
512 | rtems_filesystem_readlink_t readlink_h; |
---|
513 | rtems_filesystem_rename_t rename_h; |
---|
514 | rtems_filesystem_statvfs_t statvfs_h; |
---|
515 | }; |
---|
516 | |
---|
517 | /** |
---|
518 | * @brief File system operations table with default operations. |
---|
519 | */ |
---|
520 | extern const rtems_filesystem_operations_table |
---|
521 | rtems_filesystem_operations_default; |
---|
522 | |
---|
523 | /** |
---|
524 | * @brief Obtains the IO library mutex. |
---|
525 | * |
---|
526 | * @see rtems_filesystem_mt_entry_lock_t. |
---|
527 | */ |
---|
528 | void rtems_filesystem_default_lock( |
---|
529 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
530 | ); |
---|
531 | |
---|
532 | /** |
---|
533 | * @brief Releases the IO library mutex. |
---|
534 | * |
---|
535 | * @see rtems_filesystem_mt_entry_unlock_t. |
---|
536 | */ |
---|
537 | void rtems_filesystem_default_unlock( |
---|
538 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
539 | ); |
---|
540 | |
---|
541 | /** |
---|
542 | * @brief Terminates the path evaluation and replaces the current location with |
---|
543 | * the null location. |
---|
544 | * |
---|
545 | * @see rtems_filesystem_eval_path_t. |
---|
546 | */ |
---|
547 | void rtems_filesystem_default_eval_path( |
---|
548 | rtems_filesystem_eval_path_context_t *ctx |
---|
549 | ); |
---|
550 | |
---|
551 | /** |
---|
552 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
553 | * |
---|
554 | * @see rtems_filesystem_link_t. |
---|
555 | */ |
---|
556 | int rtems_filesystem_default_link( |
---|
557 | const rtems_filesystem_location_info_t *parentloc, |
---|
558 | const rtems_filesystem_location_info_t *targetloc, |
---|
559 | const char *name, |
---|
560 | size_t namelen |
---|
561 | ); |
---|
562 | |
---|
563 | /** |
---|
564 | * @brief Tests if the node access pointer of one location is equal to |
---|
565 | * the node access pointer of the other location. |
---|
566 | * |
---|
567 | * @param[in] a The one location. |
---|
568 | * @param[in] b The other location. |
---|
569 | * |
---|
570 | * @retval true The node access pointers of the locations are equal. |
---|
571 | * @retval false Otherwise. |
---|
572 | * |
---|
573 | * @see rtems_filesystem_are_nodes_equal_t. |
---|
574 | */ |
---|
575 | bool rtems_filesystem_default_are_nodes_equal( |
---|
576 | const rtems_filesystem_location_info_t *a, |
---|
577 | const rtems_filesystem_location_info_t *b |
---|
578 | ); |
---|
579 | |
---|
580 | /** |
---|
581 | * @retval RTEMS_FILESYSTEM_INVALID_NODE_TYPE Always. |
---|
582 | * |
---|
583 | * @see rtems_filesystem_node_type_t. |
---|
584 | */ |
---|
585 | rtems_filesystem_node_types_t rtems_filesystem_default_node_type( |
---|
586 | const rtems_filesystem_location_info_t *pathloc |
---|
587 | ); |
---|
588 | |
---|
589 | /** |
---|
590 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
591 | * |
---|
592 | * @see rtems_filesystem_mknod_t. |
---|
593 | */ |
---|
594 | int rtems_filesystem_default_mknod( |
---|
595 | const rtems_filesystem_location_info_t *parentloc, |
---|
596 | const char *name, |
---|
597 | size_t namelen, |
---|
598 | mode_t mode, |
---|
599 | dev_t dev |
---|
600 | ); |
---|
601 | |
---|
602 | /** |
---|
603 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
604 | * |
---|
605 | * @see rtems_filesystem_rmnod_t. |
---|
606 | */ |
---|
607 | int rtems_filesystem_default_rmnod( |
---|
608 | const rtems_filesystem_location_info_t *parentloc, |
---|
609 | const rtems_filesystem_location_info_t *loc |
---|
610 | ); |
---|
611 | |
---|
612 | /** |
---|
613 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
614 | * |
---|
615 | * @see rtems_filesystem_fchmod_t. |
---|
616 | */ |
---|
617 | int rtems_filesystem_default_fchmod( |
---|
618 | const rtems_filesystem_location_info_t *loc, |
---|
619 | mode_t mode |
---|
620 | ); |
---|
621 | |
---|
622 | /** |
---|
623 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
624 | * |
---|
625 | * @see rtems_filesystem_chown_t. |
---|
626 | */ |
---|
627 | int rtems_filesystem_default_chown( |
---|
628 | const rtems_filesystem_location_info_t *loc, |
---|
629 | uid_t owner, |
---|
630 | gid_t group |
---|
631 | ); |
---|
632 | |
---|
633 | /** |
---|
634 | * @retval 0 Always. |
---|
635 | * |
---|
636 | * @see rtems_filesystem_clonenode_t. |
---|
637 | */ |
---|
638 | int rtems_filesystem_default_clonenode( |
---|
639 | rtems_filesystem_location_info_t *loc |
---|
640 | ); |
---|
641 | |
---|
642 | /** |
---|
643 | * @see rtems_filesystem_freenode_t. |
---|
644 | */ |
---|
645 | void rtems_filesystem_default_freenode( |
---|
646 | const rtems_filesystem_location_info_t *loc |
---|
647 | ); |
---|
648 | |
---|
649 | /** |
---|
650 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
651 | * |
---|
652 | * @see rtems_filesystem_mount_t. |
---|
653 | */ |
---|
654 | int rtems_filesystem_default_mount ( |
---|
655 | rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ |
---|
656 | ); |
---|
657 | |
---|
658 | /** |
---|
659 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
660 | * |
---|
661 | * @see rtems_filesystem_fsmount_me_t. |
---|
662 | */ |
---|
663 | int rtems_filesystem_default_fsmount( |
---|
664 | rtems_filesystem_mount_table_entry_t *mt_entry, /* IN */ |
---|
665 | const void *data /* IN */ |
---|
666 | ); |
---|
667 | |
---|
668 | /** |
---|
669 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
670 | * |
---|
671 | * @see rtems_filesystem_unmount_t. |
---|
672 | */ |
---|
673 | int rtems_filesystem_default_unmount( |
---|
674 | rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ |
---|
675 | ); |
---|
676 | |
---|
677 | /** |
---|
678 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
679 | * |
---|
680 | * @see rtems_filesystem_fsunmount_me_t. |
---|
681 | */ |
---|
682 | void rtems_filesystem_default_fsunmount( |
---|
683 | rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ |
---|
684 | ); |
---|
685 | |
---|
686 | /** |
---|
687 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
688 | * |
---|
689 | * @see rtems_filesystem_utime_t. |
---|
690 | */ |
---|
691 | int rtems_filesystem_default_utime( |
---|
692 | const rtems_filesystem_location_info_t *loc, |
---|
693 | time_t actime, |
---|
694 | time_t modtime |
---|
695 | ); |
---|
696 | |
---|
697 | /** |
---|
698 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
699 | * |
---|
700 | * @see rtems_filesystem_symlink_t. |
---|
701 | */ |
---|
702 | int rtems_filesystem_default_symlink( |
---|
703 | const rtems_filesystem_location_info_t *parentloc, |
---|
704 | const char *name, |
---|
705 | size_t namelen, |
---|
706 | const char *target |
---|
707 | ); |
---|
708 | |
---|
709 | /** |
---|
710 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
711 | * |
---|
712 | * @see rtems_filesystem_readlink_t. |
---|
713 | */ |
---|
714 | ssize_t rtems_filesystem_default_readlink( |
---|
715 | const rtems_filesystem_location_info_t *loc, |
---|
716 | char *buf, |
---|
717 | size_t bufsize |
---|
718 | ); |
---|
719 | |
---|
720 | /** |
---|
721 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
722 | * |
---|
723 | * @see rtems_filesystem_rename_t. |
---|
724 | */ |
---|
725 | int rtems_filesystem_default_rename( |
---|
726 | const rtems_filesystem_location_info_t *oldparentloc, |
---|
727 | const rtems_filesystem_location_info_t *oldloc, |
---|
728 | const rtems_filesystem_location_info_t *newparentloc, |
---|
729 | const char *name, |
---|
730 | size_t namelen |
---|
731 | ); |
---|
732 | |
---|
733 | /** |
---|
734 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
735 | * |
---|
736 | * @see rtems_filesystem_statvfs_t. |
---|
737 | */ |
---|
738 | int rtems_filesystem_default_statvfs( |
---|
739 | const rtems_filesystem_location_info_t *loc, |
---|
740 | struct statvfs *buf |
---|
741 | ); |
---|
742 | |
---|
743 | /** @} */ |
---|
744 | |
---|
745 | /** |
---|
746 | * @defgroup LibIOFSHandler File System Node Handler |
---|
747 | * |
---|
748 | * @ingroup LibIO |
---|
749 | * |
---|
750 | * @brief File system node handler. |
---|
751 | * |
---|
752 | * @{ |
---|
753 | */ |
---|
754 | |
---|
755 | /** |
---|
756 | * @brief Opens a node. |
---|
757 | * |
---|
758 | * @param[in, out] iop The IO pointer. |
---|
759 | * @param[in] path The path. |
---|
760 | * @param[in] oflag The open flags. |
---|
761 | * @param[in] mode Optional mode for node creation. |
---|
762 | * |
---|
763 | * @retval 0 Successful operation. |
---|
764 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
765 | * |
---|
766 | * @see rtems_filesystem_default_open(). |
---|
767 | */ |
---|
768 | typedef int (*rtems_filesystem_open_t)( |
---|
769 | rtems_libio_t *iop, |
---|
770 | const char *path, |
---|
771 | int oflag, |
---|
772 | mode_t mode |
---|
773 | ); |
---|
774 | |
---|
775 | /** |
---|
776 | * @brief Closes a node. |
---|
777 | * |
---|
778 | * @param[in, out] iop The IO pointer. |
---|
779 | * |
---|
780 | * @retval 0 Successful operation. |
---|
781 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
782 | * |
---|
783 | * @see rtems_filesystem_default_close(). |
---|
784 | */ |
---|
785 | typedef int (*rtems_filesystem_close_t)( |
---|
786 | rtems_libio_t *iop |
---|
787 | ); |
---|
788 | |
---|
789 | /** |
---|
790 | * @brief Reads from a node. |
---|
791 | * |
---|
792 | * @param[in, out] iop The IO pointer. |
---|
793 | * @param[out] buffer The buffer for read data. |
---|
794 | * @param[in] count The size of the buffer in characters. |
---|
795 | * |
---|
796 | * @retval non-negative Count of read characters. |
---|
797 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
798 | * |
---|
799 | * @see rtems_filesystem_default_read(). |
---|
800 | */ |
---|
801 | typedef ssize_t (*rtems_filesystem_read_t)( |
---|
802 | rtems_libio_t *iop, |
---|
803 | void *buffer, |
---|
804 | size_t count |
---|
805 | ); |
---|
806 | |
---|
807 | /** |
---|
808 | * @brief Writes to a node. |
---|
809 | * |
---|
810 | * @param[in, out] iop The IO pointer. |
---|
811 | * @param[out] buffer The buffer for write data. |
---|
812 | * @param[in] count The size of the buffer in characters. |
---|
813 | * |
---|
814 | * @retval non-negative Count of written characters. |
---|
815 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
816 | * |
---|
817 | * @see rtems_filesystem_default_write(). |
---|
818 | */ |
---|
819 | typedef ssize_t (*rtems_filesystem_write_t)( |
---|
820 | rtems_libio_t *iop, |
---|
821 | const void *buffer, |
---|
822 | size_t count |
---|
823 | ); |
---|
824 | |
---|
825 | /** |
---|
826 | * @brief IO control of a node. |
---|
827 | * |
---|
828 | * @param[in, out] iop The IO pointer. |
---|
829 | * @param[in] request The IO control request. |
---|
830 | * @param[in, out] buffer The buffer for IO control request data. |
---|
831 | * |
---|
832 | * @retval 0 Successful operation. |
---|
833 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
834 | * |
---|
835 | * @see rtems_filesystem_default_ioctl(). |
---|
836 | */ |
---|
837 | typedef int (*rtems_filesystem_ioctl_t)( |
---|
838 | rtems_libio_t *iop, |
---|
839 | uint32_t request, |
---|
840 | void *buffer |
---|
841 | ); |
---|
842 | |
---|
843 | /** |
---|
844 | * @brief Moves the read/write file offset. |
---|
845 | * |
---|
846 | * @param[in, out] iop The IO pointer. |
---|
847 | * @param[in] offset The offset. |
---|
848 | * @param[in] whence The reference position for the offset. |
---|
849 | * |
---|
850 | * @retval non-negative The new offset from the beginning of the file. |
---|
851 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
852 | * |
---|
853 | * @see rtems_filesystem_default_lseek() and |
---|
854 | * rtems_filesystem_default_lseek_success(). |
---|
855 | */ |
---|
856 | typedef off_t (*rtems_filesystem_lseek_t)( |
---|
857 | rtems_libio_t *iop, |
---|
858 | off_t offset, |
---|
859 | int whence |
---|
860 | ); |
---|
861 | |
---|
862 | /** |
---|
863 | * @brief Gets a node status. |
---|
864 | * |
---|
865 | * @param[in, out] iop The IO pointer. |
---|
866 | * @param[out] stat The buffer to status information. |
---|
867 | * |
---|
868 | * @retval 0 Successful operation. |
---|
869 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
870 | * |
---|
871 | * @see rtems_filesystem_default_fstat(). |
---|
872 | */ |
---|
873 | typedef int (*rtems_filesystem_fstat_t)( |
---|
874 | const rtems_filesystem_location_info_t *loc, |
---|
875 | struct stat *buf |
---|
876 | ); |
---|
877 | |
---|
878 | /** |
---|
879 | * @brief Truncates a file to a specified length. |
---|
880 | * |
---|
881 | * @param[in, out] iop The IO pointer. |
---|
882 | * @param[in] length The new length in characters. |
---|
883 | * |
---|
884 | * @retval 0 Successful operation. |
---|
885 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
886 | * |
---|
887 | * @see rtems_filesystem_default_ftruncate() and |
---|
888 | * rtems_filesystem_default_ftruncate_directory(). |
---|
889 | */ |
---|
890 | typedef int (*rtems_filesystem_ftruncate_t)( |
---|
891 | rtems_libio_t *iop, |
---|
892 | off_t length |
---|
893 | ); |
---|
894 | |
---|
895 | /** |
---|
896 | * @brief Synchronizes changes to a file. |
---|
897 | * |
---|
898 | * @param[in, out] iop The IO pointer. |
---|
899 | * |
---|
900 | * @retval 0 Successful operation. |
---|
901 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
902 | * |
---|
903 | * @see rtems_filesystem_default_fsync_or_fdatasync() and |
---|
904 | * rtems_filesystem_default_fsync_or_fdatasync_success(). |
---|
905 | */ |
---|
906 | typedef int (*rtems_filesystem_fsync_t)( |
---|
907 | rtems_libio_t *iop |
---|
908 | ); |
---|
909 | |
---|
910 | /** |
---|
911 | * @brief Synchronizes the data of a file. |
---|
912 | * |
---|
913 | * @param[in, out] iop The IO pointer. |
---|
914 | * |
---|
915 | * @retval 0 Successful operation. |
---|
916 | * @retval -1 An error occured. The errno is set to indicate the error. |
---|
917 | * |
---|
918 | * @see rtems_filesystem_default_fsync_or_fdatasync() and |
---|
919 | * rtems_filesystem_default_fsync_or_fdatasync_success(). |
---|
920 | */ |
---|
921 | typedef int (*rtems_filesystem_fdatasync_t)( |
---|
922 | rtems_libio_t *iop |
---|
923 | ); |
---|
924 | |
---|
925 | /** |
---|
926 | * @brief File control. |
---|
927 | * |
---|
928 | * @param[in, out] iop The IO pointer. |
---|
929 | * @param[in] cmd Control command. |
---|
930 | * |
---|
931 | * @retval 0 Successful operation. |
---|
932 | * @retval errno An error occured. This value is assigned to errno. |
---|
933 | * |
---|
934 | * @see rtems_filesystem_default_fcntl(). |
---|
935 | */ |
---|
936 | typedef int (*rtems_filesystem_fcntl_t)( |
---|
937 | rtems_libio_t *iop, |
---|
938 | int cmd |
---|
939 | ); |
---|
940 | |
---|
941 | /** |
---|
942 | * @brief File system node operations table. |
---|
943 | */ |
---|
944 | struct _rtems_filesystem_file_handlers_r { |
---|
945 | rtems_filesystem_open_t open_h; |
---|
946 | rtems_filesystem_close_t close_h; |
---|
947 | rtems_filesystem_read_t read_h; |
---|
948 | rtems_filesystem_write_t write_h; |
---|
949 | rtems_filesystem_ioctl_t ioctl_h; |
---|
950 | rtems_filesystem_lseek_t lseek_h; |
---|
951 | rtems_filesystem_fstat_t fstat_h; |
---|
952 | rtems_filesystem_ftruncate_t ftruncate_h; |
---|
953 | rtems_filesystem_fsync_t fsync_h; |
---|
954 | rtems_filesystem_fdatasync_t fdatasync_h; |
---|
955 | rtems_filesystem_fcntl_t fcntl_h; |
---|
956 | }; |
---|
957 | |
---|
958 | /** |
---|
959 | * @brief File system node handler table with default node handlers. |
---|
960 | */ |
---|
961 | extern const rtems_filesystem_file_handlers_r |
---|
962 | rtems_filesystem_handlers_default; |
---|
963 | |
---|
964 | /** |
---|
965 | * @retval 0 Always. |
---|
966 | * |
---|
967 | * @see rtems_filesystem_open_t. |
---|
968 | */ |
---|
969 | int rtems_filesystem_default_open( |
---|
970 | rtems_libio_t *iop, |
---|
971 | const char *path, |
---|
972 | int oflag, |
---|
973 | mode_t mode |
---|
974 | ); |
---|
975 | |
---|
976 | /** |
---|
977 | * @retval 0 Always. |
---|
978 | * |
---|
979 | * @see rtems_filesystem_close_t. |
---|
980 | */ |
---|
981 | int rtems_filesystem_default_close( |
---|
982 | rtems_libio_t *iop |
---|
983 | ); |
---|
984 | |
---|
985 | /** |
---|
986 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
987 | * |
---|
988 | * @see rtems_filesystem_read_t. |
---|
989 | */ |
---|
990 | ssize_t rtems_filesystem_default_read( |
---|
991 | rtems_libio_t *iop, |
---|
992 | void *buffer, |
---|
993 | size_t count |
---|
994 | ); |
---|
995 | |
---|
996 | /** |
---|
997 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
998 | * |
---|
999 | * @see rtems_filesystem_write_t. |
---|
1000 | */ |
---|
1001 | ssize_t rtems_filesystem_default_write( |
---|
1002 | rtems_libio_t *iop, |
---|
1003 | const void *buffer, |
---|
1004 | size_t count |
---|
1005 | ); |
---|
1006 | |
---|
1007 | /** |
---|
1008 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
1009 | * |
---|
1010 | * @see rtems_filesystem_ioctl_t. |
---|
1011 | */ |
---|
1012 | int rtems_filesystem_default_ioctl( |
---|
1013 | rtems_libio_t *iop, |
---|
1014 | uint32_t command, |
---|
1015 | void *buffer |
---|
1016 | ); |
---|
1017 | |
---|
1018 | /** |
---|
1019 | * @retval -1 Always. The errno is set to ESPIPE. |
---|
1020 | * |
---|
1021 | * @see rtems_filesystem_lseek_t. |
---|
1022 | */ |
---|
1023 | off_t rtems_filesystem_default_lseek( |
---|
1024 | rtems_libio_t *iop, |
---|
1025 | off_t offset, |
---|
1026 | int whence |
---|
1027 | ); |
---|
1028 | |
---|
1029 | /** |
---|
1030 | * @retval 0 Always. |
---|
1031 | * |
---|
1032 | * @see rtems_filesystem_lseek_t. |
---|
1033 | */ |
---|
1034 | off_t rtems_filesystem_default_lseek_success( |
---|
1035 | rtems_libio_t *iop, |
---|
1036 | off_t offset, |
---|
1037 | int whence |
---|
1038 | ); |
---|
1039 | |
---|
1040 | /** |
---|
1041 | * @brief Sets the mode to S_IRWXU | S_IRWXG | S_IRWXO. |
---|
1042 | * |
---|
1043 | * @retval 0 Always. |
---|
1044 | * |
---|
1045 | * @see rtems_filesystem_fstat_t. |
---|
1046 | */ |
---|
1047 | int rtems_filesystem_default_fstat( |
---|
1048 | const rtems_filesystem_location_info_t *loc, |
---|
1049 | struct stat *buf |
---|
1050 | ); |
---|
1051 | |
---|
1052 | /** |
---|
1053 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
1054 | * |
---|
1055 | * @see rtems_filesystem_ftruncate_t. |
---|
1056 | */ |
---|
1057 | int rtems_filesystem_default_ftruncate( |
---|
1058 | rtems_libio_t *iop, |
---|
1059 | off_t length |
---|
1060 | ); |
---|
1061 | |
---|
1062 | /** |
---|
1063 | * @retval -1 Always. The errno is set to EISDIR. |
---|
1064 | * |
---|
1065 | * @see rtems_filesystem_ftruncate_t. |
---|
1066 | */ |
---|
1067 | int rtems_filesystem_default_ftruncate_directory( |
---|
1068 | rtems_libio_t *iop, |
---|
1069 | off_t length |
---|
1070 | ); |
---|
1071 | |
---|
1072 | /** |
---|
1073 | * @retval -1 Always. The errno is set to EINVAL. |
---|
1074 | * |
---|
1075 | * @see rtems_filesystem_fsync_t and rtems_filesystem_fdatasync_t. |
---|
1076 | */ |
---|
1077 | int rtems_filesystem_default_fsync_or_fdatasync( |
---|
1078 | rtems_libio_t *iop |
---|
1079 | ); |
---|
1080 | |
---|
1081 | /** |
---|
1082 | * @retval 0 Always. |
---|
1083 | * |
---|
1084 | * @see rtems_filesystem_fsync_t and rtems_filesystem_fdatasync_t. |
---|
1085 | */ |
---|
1086 | int rtems_filesystem_default_fsync_or_fdatasync_success( |
---|
1087 | rtems_libio_t *iop |
---|
1088 | ); |
---|
1089 | |
---|
1090 | /** |
---|
1091 | * @retval 0 Always. |
---|
1092 | * |
---|
1093 | * @see rtems_filesystem_fcntl_t. |
---|
1094 | */ |
---|
1095 | int rtems_filesystem_default_fcntl( |
---|
1096 | rtems_libio_t *iop, |
---|
1097 | int cmd |
---|
1098 | ); |
---|
1099 | |
---|
1100 | /** @} */ |
---|
1101 | |
---|
1102 | /** |
---|
1103 | * @defgroup LibIO IO Library |
---|
1104 | * |
---|
1105 | * @brief Provides system call and file system interface definitions. |
---|
1106 | * |
---|
1107 | * General purpose communication channel for RTEMS to allow UNIX/POSIX |
---|
1108 | * system call behavior under RTEMS. Initially this supported only |
---|
1109 | * IO to devices but has since been enhanced to support networking |
---|
1110 | * and support for mounted file systems. |
---|
1111 | * |
---|
1112 | * @{ |
---|
1113 | */ |
---|
1114 | |
---|
1115 | typedef off_t rtems_off64_t __attribute__((deprecated)); |
---|
1116 | |
---|
1117 | /** |
---|
1118 | * @brief Gets the mount handler for the file system @a type. |
---|
1119 | * |
---|
1120 | * @return The file system mount handler associated with the @a type, or |
---|
1121 | * @c NULL if no such association exists. |
---|
1122 | */ |
---|
1123 | rtems_filesystem_fsmount_me_t |
---|
1124 | rtems_filesystem_get_mount_handler( |
---|
1125 | const char *type |
---|
1126 | ); |
---|
1127 | |
---|
1128 | /** |
---|
1129 | * @brief Contain file system specific information which is required to support |
---|
1130 | * fpathconf(). |
---|
1131 | */ |
---|
1132 | typedef struct { |
---|
1133 | int link_max; /* count */ |
---|
1134 | int max_canon; /* max formatted input line size */ |
---|
1135 | int max_input; /* max input line size */ |
---|
1136 | int name_max; /* max name length */ |
---|
1137 | int path_max; /* max path */ |
---|
1138 | int pipe_buf; /* pipe buffer size */ |
---|
1139 | int posix_async_io; /* async IO supported on fs, 0=no, 1=yes */ |
---|
1140 | int posix_chown_restrictions; /* can chown: 0=no, 1=yes */ |
---|
1141 | int posix_no_trunc; /* error on names > max name, 0=no, 1=yes */ |
---|
1142 | int posix_prio_io; /* priority IO, 0=no, 1=yes */ |
---|
1143 | int posix_sync_io; /* file can be sync'ed, 0=no, 1=yes */ |
---|
1144 | int posix_vdisable; /* special char processing, 0=no, 1=yes */ |
---|
1145 | } rtems_filesystem_limits_and_options_t; |
---|
1146 | |
---|
1147 | /** |
---|
1148 | * @brief Default pathconf settings. |
---|
1149 | * |
---|
1150 | * Override in a filesystem. |
---|
1151 | */ |
---|
1152 | extern const rtems_filesystem_limits_and_options_t |
---|
1153 | rtems_filesystem_default_pathconf; |
---|
1154 | |
---|
1155 | /** |
---|
1156 | * @brief An open file data structure. |
---|
1157 | * |
---|
1158 | * It will be indexed by 'fd'. |
---|
1159 | * |
---|
1160 | * @todo Should really have a separate per/file data structure that this points |
---|
1161 | * to (eg: size, offset, driver, pathname should be in that) |
---|
1162 | */ |
---|
1163 | struct rtems_libio_tt { |
---|
1164 | rtems_driver_name_t *driver; |
---|
1165 | off_t size; /* size of file */ |
---|
1166 | off_t offset; /* current offset into file */ |
---|
1167 | uint32_t flags; |
---|
1168 | rtems_filesystem_location_info_t pathinfo; |
---|
1169 | rtems_id sem; |
---|
1170 | uint32_t data0; /* private to "driver" */ |
---|
1171 | void *data1; /* ... */ |
---|
1172 | }; |
---|
1173 | |
---|
1174 | /** |
---|
1175 | * @brief Paramameter block for read/write. |
---|
1176 | * |
---|
1177 | * It must include 'offset' instead of using iop's offset since we can have |
---|
1178 | * multiple outstanding i/o's on a device. |
---|
1179 | */ |
---|
1180 | typedef struct { |
---|
1181 | rtems_libio_t *iop; |
---|
1182 | off_t offset; |
---|
1183 | char *buffer; |
---|
1184 | uint32_t count; |
---|
1185 | uint32_t flags; |
---|
1186 | uint32_t bytes_moved; |
---|
1187 | } rtems_libio_rw_args_t; |
---|
1188 | |
---|
1189 | /** |
---|
1190 | * @brief Parameter block for open/close. |
---|
1191 | */ |
---|
1192 | typedef struct { |
---|
1193 | rtems_libio_t *iop; |
---|
1194 | uint32_t flags; |
---|
1195 | uint32_t mode; |
---|
1196 | } rtems_libio_open_close_args_t; |
---|
1197 | |
---|
1198 | /** |
---|
1199 | * @brief Parameter block for ioctl. |
---|
1200 | */ |
---|
1201 | typedef struct { |
---|
1202 | rtems_libio_t *iop; |
---|
1203 | uint32_t command; |
---|
1204 | void *buffer; |
---|
1205 | uint32_t ioctl_return; |
---|
1206 | } rtems_libio_ioctl_args_t; |
---|
1207 | |
---|
1208 | /** |
---|
1209 | * @name Flag Values |
---|
1210 | * |
---|
1211 | * @{ |
---|
1212 | */ |
---|
1213 | |
---|
1214 | #define LIBIO_FLAGS_NO_DELAY 0x0001U /* return immediately if no data */ |
---|
1215 | #define LIBIO_FLAGS_READ 0x0002U /* reading */ |
---|
1216 | #define LIBIO_FLAGS_WRITE 0x0004U /* writing */ |
---|
1217 | #define LIBIO_FLAGS_OPEN 0x0100U /* device is open */ |
---|
1218 | #define LIBIO_FLAGS_APPEND 0x0200U /* all writes append */ |
---|
1219 | #define LIBIO_FLAGS_CREATE 0x0400U /* create file */ |
---|
1220 | #define LIBIO_FLAGS_CLOSE_ON_EXEC 0x0800U /* close on process exec() */ |
---|
1221 | #define LIBIO_FLAGS_READ_WRITE (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE) |
---|
1222 | |
---|
1223 | /** @} */ |
---|
1224 | |
---|
1225 | void rtems_libio_init(void); |
---|
1226 | |
---|
1227 | /** |
---|
1228 | * @name External I/O Handlers |
---|
1229 | * |
---|
1230 | * @{ |
---|
1231 | */ |
---|
1232 | |
---|
1233 | typedef int (*rtems_libio_open_t)( |
---|
1234 | const char *pathname, |
---|
1235 | uint32_t flag, |
---|
1236 | uint32_t mode |
---|
1237 | ); |
---|
1238 | |
---|
1239 | typedef int (*rtems_libio_close_t)( |
---|
1240 | int fd |
---|
1241 | ); |
---|
1242 | |
---|
1243 | typedef ssize_t (*rtems_libio_read_t)( |
---|
1244 | int fd, |
---|
1245 | void *buffer, |
---|
1246 | size_t count |
---|
1247 | ); |
---|
1248 | |
---|
1249 | typedef ssize_t (*rtems_libio_write_t)( |
---|
1250 | int fd, |
---|
1251 | const void *buffer, |
---|
1252 | size_t count |
---|
1253 | ); |
---|
1254 | |
---|
1255 | typedef int (*rtems_libio_ioctl_t)( |
---|
1256 | int fd, |
---|
1257 | uint32_t command, |
---|
1258 | void *buffer |
---|
1259 | ); |
---|
1260 | |
---|
1261 | typedef off_t (*rtems_libio_lseek_t)( |
---|
1262 | int fd, |
---|
1263 | off_t offset, |
---|
1264 | int whence |
---|
1265 | ); |
---|
1266 | |
---|
1267 | /** @} */ |
---|
1268 | |
---|
1269 | /** |
---|
1270 | * @name Permission Macros |
---|
1271 | * |
---|
1272 | * @{ |
---|
1273 | */ |
---|
1274 | |
---|
1275 | /* |
---|
1276 | * The following macros are used to build up the permissions sets |
---|
1277 | * used to check permissions. These are similar in style to the |
---|
1278 | * mode_t bits and should stay compatible with them. |
---|
1279 | */ |
---|
1280 | #define RTEMS_LIBIO_PERMS_READ 0x4 |
---|
1281 | #define RTEMS_LIBIO_PERMS_WRITE 0x2 |
---|
1282 | #define RTEMS_LIBIO_PERMS_EXEC 0x1 |
---|
1283 | #define RTEMS_LIBIO_PERMS_SEARCH RTEMS_LIBIO_PERMS_EXEC |
---|
1284 | #define RTEMS_LIBIO_PERMS_RDWR \ |
---|
1285 | (RTEMS_LIBIO_PERMS_READ | RTEMS_LIBIO_PERMS_WRITE) |
---|
1286 | #define RTEMS_LIBIO_PERMS_RWX \ |
---|
1287 | (RTEMS_LIBIO_PERMS_RDWR | RTEMS_LIBIO_PERMS_EXEC) |
---|
1288 | #define RTEMS_LIBIO_FOLLOW_HARD_LINK 0x8 |
---|
1289 | #define RTEMS_LIBIO_FOLLOW_SYM_LINK 0x10 |
---|
1290 | #define RTEMS_LIBIO_FOLLOW_LINK \ |
---|
1291 | (RTEMS_LIBIO_FOLLOW_HARD_LINK | RTEMS_LIBIO_FOLLOW_SYM_LINK) |
---|
1292 | #define RTEMS_LIBIO_MAKE 0x20 |
---|
1293 | #define RTEMS_LIBIO_EXCLUSIVE 0x40 |
---|
1294 | #define RTEMS_LIBIO_ACCEPT_RESIDUAL_DELIMITERS 0x80 |
---|
1295 | #define RTEMS_LIBIO_REJECT_TERMINAL_DOT 0x100 |
---|
1296 | |
---|
1297 | /** @} */ |
---|
1298 | |
---|
1299 | union __rtems_dev_t { |
---|
1300 | dev_t device; |
---|
1301 | struct { |
---|
1302 | rtems_device_major_number major; |
---|
1303 | rtems_device_minor_number minor; |
---|
1304 | } __overlay; |
---|
1305 | }; |
---|
1306 | |
---|
1307 | static inline dev_t rtems_filesystem_make_dev_t( |
---|
1308 | rtems_device_major_number _major, |
---|
1309 | rtems_device_minor_number _minor |
---|
1310 | ) |
---|
1311 | { |
---|
1312 | union __rtems_dev_t temp; |
---|
1313 | |
---|
1314 | temp.__overlay.major = _major; |
---|
1315 | temp.__overlay.minor = _minor; |
---|
1316 | return temp.device; |
---|
1317 | } |
---|
1318 | |
---|
1319 | static inline rtems_device_major_number rtems_filesystem_dev_major_t( |
---|
1320 | dev_t device |
---|
1321 | ) |
---|
1322 | { |
---|
1323 | union __rtems_dev_t temp; |
---|
1324 | |
---|
1325 | temp.device = device; |
---|
1326 | return temp.__overlay.major; |
---|
1327 | } |
---|
1328 | |
---|
1329 | |
---|
1330 | static inline rtems_device_minor_number rtems_filesystem_dev_minor_t( |
---|
1331 | dev_t device |
---|
1332 | ) |
---|
1333 | { |
---|
1334 | union __rtems_dev_t temp; |
---|
1335 | |
---|
1336 | temp.device = device; |
---|
1337 | return temp.__overlay.minor; |
---|
1338 | } |
---|
1339 | |
---|
1340 | #define rtems_filesystem_split_dev_t( _dev, _major, _minor ) \ |
---|
1341 | do { \ |
---|
1342 | (_major) = rtems_filesystem_dev_major_t ( _dev ); \ |
---|
1343 | (_minor) = rtems_filesystem_dev_minor_t( _dev ); \ |
---|
1344 | } while(0) |
---|
1345 | |
---|
1346 | /* |
---|
1347 | * Prototypes for filesystem |
---|
1348 | */ |
---|
1349 | |
---|
1350 | void rtems_filesystem_initialize( void ); |
---|
1351 | |
---|
1352 | typedef void (*rtems_libio_init_functions_t)(void); |
---|
1353 | extern rtems_libio_init_functions_t rtems_libio_init_helper; |
---|
1354 | |
---|
1355 | void open_dev_console(void); |
---|
1356 | |
---|
1357 | typedef void (*rtems_libio_supp_functions_t)(void); |
---|
1358 | extern rtems_libio_supp_functions_t rtems_libio_supp_helper; |
---|
1359 | |
---|
1360 | typedef void (*rtems_fs_init_functions_t)(void); |
---|
1361 | extern rtems_fs_init_functions_t rtems_fs_init_helper; |
---|
1362 | |
---|
1363 | /** |
---|
1364 | * @brief Creates a directory and all its parent directories according to |
---|
1365 | * @a path. |
---|
1366 | * |
---|
1367 | * The @a mode value selects the access permissions of the directory. |
---|
1368 | * |
---|
1369 | * @retval 0 Successful operation. |
---|
1370 | * @retval -1 An error occured. The @c errno indicates the error. |
---|
1371 | */ |
---|
1372 | extern int rtems_mkdir(const char *path, mode_t mode); |
---|
1373 | |
---|
1374 | /** @} */ |
---|
1375 | |
---|
1376 | /** |
---|
1377 | * @defgroup FileSystemTypesAndMount File System Types and Mount |
---|
1378 | * |
---|
1379 | * @ingroup LibIO |
---|
1380 | * |
---|
1381 | * @brief File system types and mount. |
---|
1382 | * |
---|
1383 | * @{ |
---|
1384 | */ |
---|
1385 | |
---|
1386 | /** |
---|
1387 | * @name File System Types |
---|
1388 | * |
---|
1389 | * @{ |
---|
1390 | */ |
---|
1391 | |
---|
1392 | #define RTEMS_FILESYSTEM_TYPE_IMFS "imfs" |
---|
1393 | #define RTEMS_FILESYSTEM_TYPE_MINIIMFS "mimfs" |
---|
1394 | #define RTEMS_FILESYSTEM_TYPE_DEVFS "devfs" |
---|
1395 | #define RTEMS_FILESYSTEM_TYPE_FTPFS "ftpfs" |
---|
1396 | #define RTEMS_FILESYSTEM_TYPE_TFTPFS "tftpfs" |
---|
1397 | #define RTEMS_FILESYSTEM_TYPE_NFS "nfs" |
---|
1398 | #define RTEMS_FILESYSTEM_TYPE_DOSFS "dosfs" |
---|
1399 | #define RTEMS_FILESYSTEM_TYPE_RFS "rfs" |
---|
1400 | |
---|
1401 | /** @} */ |
---|
1402 | |
---|
1403 | /** |
---|
1404 | * @brief Mount table entry. |
---|
1405 | */ |
---|
1406 | struct rtems_filesystem_mount_table_entry_tt { |
---|
1407 | rtems_chain_node mt_node; |
---|
1408 | rtems_chain_control location_chain; |
---|
1409 | rtems_filesystem_global_location_t *mt_point_node; |
---|
1410 | rtems_filesystem_global_location_t *mt_fs_root; |
---|
1411 | bool mounted; |
---|
1412 | bool writeable; |
---|
1413 | void *fs_info; |
---|
1414 | const void *immutable_fs_info; |
---|
1415 | rtems_filesystem_limits_and_options_t pathconf_limits_and_options; |
---|
1416 | |
---|
1417 | /* |
---|
1418 | * The target or mount point of the file system. |
---|
1419 | */ |
---|
1420 | const char *target; |
---|
1421 | |
---|
1422 | /* |
---|
1423 | * The type of filesystem or the name of the filesystem. |
---|
1424 | */ |
---|
1425 | const char *type; |
---|
1426 | |
---|
1427 | /* |
---|
1428 | * When someone adds a mounted filesystem on a real device, |
---|
1429 | * this will need to be used. |
---|
1430 | * |
---|
1431 | * The lower layers can manage how this is managed. Leave as a |
---|
1432 | * string. |
---|
1433 | */ |
---|
1434 | char *dev; |
---|
1435 | }; |
---|
1436 | |
---|
1437 | /** |
---|
1438 | * @brief File system options. |
---|
1439 | */ |
---|
1440 | typedef enum { |
---|
1441 | RTEMS_FILESYSTEM_READ_ONLY, |
---|
1442 | RTEMS_FILESYSTEM_READ_WRITE, |
---|
1443 | RTEMS_FILESYSTEM_BAD_OPTIONS |
---|
1444 | } rtems_filesystem_options_t; |
---|
1445 | |
---|
1446 | /** |
---|
1447 | * @brief File system table entry. |
---|
1448 | */ |
---|
1449 | typedef struct rtems_filesystem_table_t { |
---|
1450 | const char *type; |
---|
1451 | rtems_filesystem_fsmount_me_t mount_h; |
---|
1452 | } rtems_filesystem_table_t; |
---|
1453 | |
---|
1454 | /** |
---|
1455 | * @brief Static table of file systems. |
---|
1456 | * |
---|
1457 | * Externally defined by confdefs.h or the user. |
---|
1458 | */ |
---|
1459 | extern const rtems_filesystem_table_t rtems_filesystem_table []; |
---|
1460 | |
---|
1461 | extern rtems_chain_control rtems_filesystem_mount_table; |
---|
1462 | |
---|
1463 | /** |
---|
1464 | * @brief Registers a file system @a type. |
---|
1465 | * |
---|
1466 | * The @a mount_h handler will be used to mount a file system of this @a type. |
---|
1467 | * |
---|
1468 | * @retval 0 Successful operation. |
---|
1469 | * @retval -1 An error occured. The @c errno indicates the error. |
---|
1470 | */ |
---|
1471 | int rtems_filesystem_register( |
---|
1472 | const char *type, |
---|
1473 | rtems_filesystem_fsmount_me_t mount_h |
---|
1474 | ); |
---|
1475 | |
---|
1476 | /** |
---|
1477 | * @brief Unregisters a file system @a type. |
---|
1478 | * |
---|
1479 | * @retval 0 Successful operation. |
---|
1480 | * @retval -1 An error occured. The @c errno indicates the error. |
---|
1481 | */ |
---|
1482 | int rtems_filesystem_unregister( |
---|
1483 | const char *type |
---|
1484 | ); |
---|
1485 | |
---|
1486 | /** |
---|
1487 | * @brief Unmounts the file system at @a mount_path. |
---|
1488 | * |
---|
1489 | * @todo Due to file system implementation shortcomings it is possible to |
---|
1490 | * unmount file systems in use. This likely leads to heap corruption. Unmount |
---|
1491 | * only file systems which are not in use by the application. |
---|
1492 | * |
---|
1493 | * @retval 0 Successful operation. |
---|
1494 | * @retval -1 An error occured. The @c errno indicates the error. |
---|
1495 | */ |
---|
1496 | int unmount( |
---|
1497 | const char *mount_path |
---|
1498 | ); |
---|
1499 | |
---|
1500 | /** |
---|
1501 | * @brief Mounts a file system at @a target. |
---|
1502 | * |
---|
1503 | * The @a source may be a path to the corresponding device file, or @c NULL. |
---|
1504 | * The @a target path must lead to an existing directory, or @c NULL. In case |
---|
1505 | * @a target is @c NULL, the root file system will be mounted. The @a data |
---|
1506 | * parameter will be forwarded to the file system initialization handler. The |
---|
1507 | * file system type is selected by @a filesystemtype and may be one of |
---|
1508 | * - RTEMS_FILESYSTEM_TYPE_DEVFS, |
---|
1509 | * - RTEMS_FILESYSTEM_TYPE_DOSFS, |
---|
1510 | * - RTEMS_FILESYSTEM_TYPE_FTPFS, |
---|
1511 | * - RTEMS_FILESYSTEM_TYPE_IMFS, |
---|
1512 | * - RTEMS_FILESYSTEM_TYPE_MINIIMFS, |
---|
1513 | * - RTEMS_FILESYSTEM_TYPE_NFS, |
---|
1514 | * - RTEMS_FILESYSTEM_TYPE_RFS, or |
---|
1515 | * - RTEMS_FILESYSTEM_TYPE_TFTPFS. |
---|
1516 | * |
---|
1517 | * Only configured or registered file system types are available. You can add |
---|
1518 | * file system types to your application configuration with |
---|
1519 | * - CONFIGURE_FILESYSTEM_DEVFS, |
---|
1520 | * - CONFIGURE_FILESYSTEM_DOSFS, |
---|
1521 | * - CONFIGURE_FILESYSTEM_FTPFS, |
---|
1522 | * - CONFIGURE_FILESYSTEM_IMFS, |
---|
1523 | * - CONFIGURE_FILESYSTEM_MINIIMFS, |
---|
1524 | * - CONFIGURE_FILESYSTEM_NFS, |
---|
1525 | * - CONFIGURE_FILESYSTEM_RFS, and |
---|
1526 | * - CONFIGURE_FILESYSTEM_TFTPFS. |
---|
1527 | * |
---|
1528 | * @see rtems_filesystem_register() and mount_and_make_target_path(). |
---|
1529 | * |
---|
1530 | * @retval 0 Successful operation. |
---|
1531 | * @retval -1 An error occured. The @c errno indicates the error. |
---|
1532 | */ |
---|
1533 | int mount( |
---|
1534 | const char *source, |
---|
1535 | const char *target, |
---|
1536 | const char *filesystemtype, |
---|
1537 | rtems_filesystem_options_t options, |
---|
1538 | const void *data |
---|
1539 | ); |
---|
1540 | |
---|
1541 | /** |
---|
1542 | * @brief Mounts a file system and makes the @a target path. |
---|
1543 | * |
---|
1544 | * The @a target path will be created with rtems_mkdir() and must not be |
---|
1545 | * @c NULL. |
---|
1546 | * |
---|
1547 | * @see mount(). |
---|
1548 | * |
---|
1549 | * @retval 0 Successful operation. |
---|
1550 | * @retval -1 An error occured. The @c errno indicates the error. |
---|
1551 | */ |
---|
1552 | int mount_and_make_target_path( |
---|
1553 | const char *source, |
---|
1554 | const char *target, |
---|
1555 | const char *filesystemtype, |
---|
1556 | rtems_filesystem_options_t options, |
---|
1557 | const void *data |
---|
1558 | ); |
---|
1559 | |
---|
1560 | /** |
---|
1561 | * @brief Per file system type routine. |
---|
1562 | * |
---|
1563 | * @see rtems_filesystem_iterate(). |
---|
1564 | * |
---|
1565 | * @retval true Stop the iteration. |
---|
1566 | * @retval false Continue the iteration. |
---|
1567 | */ |
---|
1568 | typedef bool (*rtems_per_filesystem_routine)( |
---|
1569 | const rtems_filesystem_table_t *fs_entry, |
---|
1570 | void *arg |
---|
1571 | ); |
---|
1572 | |
---|
1573 | /** |
---|
1574 | * @brief Iterates over all file system types. |
---|
1575 | * |
---|
1576 | * For each file system type the @a routine will be called with the entry and |
---|
1577 | * the @a routine_arg parameter. |
---|
1578 | * |
---|
1579 | * Do not register or unregister file system types in @a routine. |
---|
1580 | * |
---|
1581 | * The iteration is protected by the IO library mutex. |
---|
1582 | * |
---|
1583 | * @retval true Iteration stopped due to @a routine return status. |
---|
1584 | * @retval false Iteration through all entries. |
---|
1585 | */ |
---|
1586 | bool rtems_filesystem_iterate( |
---|
1587 | rtems_per_filesystem_routine routine, |
---|
1588 | void *routine_arg |
---|
1589 | ); |
---|
1590 | |
---|
1591 | /** |
---|
1592 | * @brief Mount table entry visitor. |
---|
1593 | * |
---|
1594 | * @retval true Stop the iteration. |
---|
1595 | * @retval false Continue the iteration. |
---|
1596 | * |
---|
1597 | * @see rtems_filesystem_mount_iterate(). |
---|
1598 | */ |
---|
1599 | typedef bool (*rtems_filesystem_mt_entry_visitor)( |
---|
1600 | const rtems_filesystem_mount_table_entry_t *mt_entry, |
---|
1601 | void *arg |
---|
1602 | ); |
---|
1603 | |
---|
1604 | /** |
---|
1605 | * @brief Iterates over all file system mount entries. |
---|
1606 | * |
---|
1607 | * The iteration is protected by the IO library mutex. Do not mount or unmount |
---|
1608 | * file systems in the visitor function. |
---|
1609 | * |
---|
1610 | * @param[in] visitor For each file system mount entry the visitor function |
---|
1611 | * will be called with the entry and the visitor argument as parameters. |
---|
1612 | * @param[in] visitor_arg The second parameter for the visitor function. |
---|
1613 | * |
---|
1614 | * @retval true Iteration stopped due to visitor function return status. |
---|
1615 | * @retval false Iteration through all entries. |
---|
1616 | */ |
---|
1617 | bool rtems_filesystem_mount_iterate( |
---|
1618 | rtems_filesystem_mt_entry_visitor visitor, |
---|
1619 | void *visitor_arg |
---|
1620 | ); |
---|
1621 | |
---|
1622 | typedef struct { |
---|
1623 | const char *source; |
---|
1624 | const char *target; |
---|
1625 | const char *filesystemtype; |
---|
1626 | rtems_filesystem_options_t options; |
---|
1627 | const void *data; |
---|
1628 | } rtems_filesystem_mount_configuration; |
---|
1629 | |
---|
1630 | extern const rtems_filesystem_mount_configuration |
---|
1631 | rtems_filesystem_root_configuration; |
---|
1632 | |
---|
1633 | /** @} */ |
---|
1634 | |
---|
1635 | /** |
---|
1636 | * @defgroup Termios Termios |
---|
1637 | * |
---|
1638 | * @ingroup LibIO |
---|
1639 | * |
---|
1640 | * @brief Termios |
---|
1641 | * |
---|
1642 | * @{ |
---|
1643 | */ |
---|
1644 | |
---|
1645 | typedef struct rtems_termios_callbacks { |
---|
1646 | int (*firstOpen)(int major, int minor, void *arg); |
---|
1647 | int (*lastClose)(int major, int minor, void *arg); |
---|
1648 | int (*pollRead)(int minor); |
---|
1649 | ssize_t (*write)(int minor, const char *buf, size_t len); |
---|
1650 | int (*setAttributes)(int minor, const struct termios *t); |
---|
1651 | int (*stopRemoteTx)(int minor); |
---|
1652 | int (*startRemoteTx)(int minor); |
---|
1653 | int outputUsesInterrupts; |
---|
1654 | } rtems_termios_callbacks; |
---|
1655 | |
---|
1656 | void rtems_termios_initialize (void); |
---|
1657 | |
---|
1658 | /* |
---|
1659 | * CCJ: Change before opening a tty. Newer code from Eric is coming |
---|
1660 | * so extra work to handle an open tty is not worth it. If the tty |
---|
1661 | * is open, close then open it again. |
---|
1662 | */ |
---|
1663 | rtems_status_code rtems_termios_bufsize ( |
---|
1664 | size_t cbufsize, /* cooked buffer size */ |
---|
1665 | size_t raw_input, /* raw input buffer size */ |
---|
1666 | size_t raw_output /* raw output buffer size */ |
---|
1667 | ); |
---|
1668 | |
---|
1669 | rtems_status_code rtems_termios_open ( |
---|
1670 | rtems_device_major_number major, |
---|
1671 | rtems_device_minor_number minor, |
---|
1672 | void *arg, |
---|
1673 | const rtems_termios_callbacks *callbacks |
---|
1674 | ); |
---|
1675 | |
---|
1676 | rtems_status_code rtems_termios_close( |
---|
1677 | void *arg |
---|
1678 | ); |
---|
1679 | |
---|
1680 | rtems_status_code rtems_termios_read( |
---|
1681 | void *arg |
---|
1682 | ); |
---|
1683 | |
---|
1684 | rtems_status_code rtems_termios_write( |
---|
1685 | void *arg |
---|
1686 | ); |
---|
1687 | |
---|
1688 | rtems_status_code rtems_termios_ioctl( |
---|
1689 | void *arg |
---|
1690 | ); |
---|
1691 | |
---|
1692 | int rtems_termios_enqueue_raw_characters( |
---|
1693 | void *ttyp, |
---|
1694 | const char *buf, |
---|
1695 | int len |
---|
1696 | ); |
---|
1697 | |
---|
1698 | int rtems_termios_dequeue_characters( |
---|
1699 | void *ttyp, |
---|
1700 | int len |
---|
1701 | ); |
---|
1702 | |
---|
1703 | /** @} */ |
---|
1704 | |
---|
1705 | /** |
---|
1706 | * @brief The pathconf setting for a file system. |
---|
1707 | */ |
---|
1708 | #define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options) |
---|
1709 | |
---|
1710 | /** |
---|
1711 | * @brief The type of file system. Its name. |
---|
1712 | */ |
---|
1713 | #define rtems_filesystem_type(_mte) ((_mte)->type) |
---|
1714 | |
---|
1715 | /** |
---|
1716 | * @brief The mount point of a file system. |
---|
1717 | */ |
---|
1718 | #define rtems_filesystem_mount_point(_mte) ((_mte)->target) |
---|
1719 | |
---|
1720 | /** |
---|
1721 | * @brief The device entry of a file system. |
---|
1722 | */ |
---|
1723 | #define rtems_filesystem_mount_device(_mte) ((_mte)->dev) |
---|
1724 | |
---|
1725 | #ifdef __cplusplus |
---|
1726 | } |
---|
1727 | #endif |
---|
1728 | |
---|
1729 | #endif /* _RTEMS_LIBIO_H */ |
---|