1 | .. SPDX-License-Identifier: CC-BY-SA-4.0 |
---|
2 | |
---|
3 | .. Copyright (C) 1988, 2002 On-Line Applications Research Corporation (OAR) |
---|
4 | |
---|
5 | In-Memory Filesystem |
---|
6 | ******************** |
---|
7 | |
---|
8 | This chapter describes the In-Memory FileSystem (IMFS). The IMFS is a full |
---|
9 | featured POSIX filesystem that keeps all information in memory. |
---|
10 | |
---|
11 | IMFS Per Node Data Structure |
---|
12 | ============================ |
---|
13 | |
---|
14 | Each regular file, device, hard link, and directory is represented by a data |
---|
15 | structure called a ``jnode``. The ``jnode`` is formally represented by the |
---|
16 | structure: |
---|
17 | |
---|
18 | .. code-block:: c |
---|
19 | |
---|
20 | struct IMFS_jnode_tt { |
---|
21 | Chain_Node Node; /* for chaining them together */ |
---|
22 | IMFS_jnode_t *Parent; /* Parent node */ |
---|
23 | char name[NAME_MAX+1]; /* "basename" */ |
---|
24 | mode_t st_mode; /* File mode */ |
---|
25 | nlink_t st_nlink; /* Link count */ |
---|
26 | ino_t st_ino; /* inode */ |
---|
27 | uid_t st_uid; /* User ID of owner */ |
---|
28 | gid_t st_gid; /* Group ID of owner */ |
---|
29 | time_t st_atime; /* Time of last access */ |
---|
30 | time_t st_mtime; /* Time of last modification */ |
---|
31 | time_t st_ctime; /* Time of last status change */ |
---|
32 | IMFS_jnode_types_t type; /* Type of this entry */ |
---|
33 | IMFS_typs_union info; |
---|
34 | }; |
---|
35 | |
---|
36 | The key elements of this structure are listed below together with a brief |
---|
37 | explanation of their role in the filesystem. |
---|
38 | |
---|
39 | *Node* |
---|
40 | exists to allow the entire ``jnode`` structure to be included in a chain. |
---|
41 | |
---|
42 | *Parent* |
---|
43 | is a pointer to another ``jnode`` structure that is the logical parent of |
---|
44 | the node in which it appears. This field may be NULL if the file |
---|
45 | associated with this node is deleted but there are open file descriptors on |
---|
46 | this file or there are still hard links to this node. |
---|
47 | |
---|
48 | *name* |
---|
49 | is the name of this node within the filesystem hierarchical tree. Example: |
---|
50 | If the fully qualified pathname to the ``jnode`` was ``/a/b/c``, the |
---|
51 | ``jnode`` name field would contain the null terminated string ``"c"``. |
---|
52 | |
---|
53 | *st_mode* |
---|
54 | is the standard Unix access permissions for the file or directory. |
---|
55 | |
---|
56 | *st_nlink* |
---|
57 | is the number of hard links to this file. When a ``jnode`` is first created |
---|
58 | its link count is set to 1. A ``jnode`` and its associated resources cannot |
---|
59 | be deleted unless its link count is less than 1. |
---|
60 | |
---|
61 | *st_ino* |
---|
62 | is a unique node identification number |
---|
63 | |
---|
64 | *st_uid* |
---|
65 | is the user ID of the file's owner |
---|
66 | |
---|
67 | *st_gid* |
---|
68 | is the group ID of the file's owner |
---|
69 | |
---|
70 | *st_atime* |
---|
71 | is the time of the last access to this file |
---|
72 | |
---|
73 | *st_mtime* |
---|
74 | is the time of the last modification of this file |
---|
75 | |
---|
76 | *st_ctime* |
---|
77 | is the time of the last status change to the file |
---|
78 | |
---|
79 | *type* |
---|
80 | is the indication of node type must be one of the following states: |
---|
81 | - IMFS_DIRECTORY |
---|
82 | - IMFS_MEMORY_FILE |
---|
83 | - IMFS_HARD_LINK |
---|
84 | - IMFS_SYM_LINK |
---|
85 | - IMFS_DEVICE |
---|
86 | |
---|
87 | *info* |
---|
88 | is this contains a structure that is unique to file type (See |
---|
89 | IMFS_typs_union in imfs.h). |
---|
90 | |
---|
91 | - IMFS_DIRECTORY |
---|
92 | |
---|
93 | An IMFS directory contains a dynamic chain structure that records all |
---|
94 | files and directories that are subordinate to the directory node. |
---|
95 | |
---|
96 | - IMFS_MEMORY_FILE |
---|
97 | |
---|
98 | Under the in memory filesystem regular files hold data. Data is |
---|
99 | dynamically allocated to the file in 128 byte chunks of memory. The |
---|
100 | individual chunks of memory are tracked by arrays of pointers that record |
---|
101 | the address of the allocated chunk of memory. Single, double, and triple |
---|
102 | indirection pointers are used to record the locations of all segments of |
---|
103 | the file. The memory organization of an IMFS file are discussed |
---|
104 | elsewhere in this manual. |
---|
105 | |
---|
106 | - IMFS_HARD_LINK |
---|
107 | |
---|
108 | The IMFS filesystem supports the concept of hard links to other nodes in |
---|
109 | the IMFS filesystem. These hard links are actual pointers to other nodes |
---|
110 | in the same filesystem. This type of link cannot cross-filesystem |
---|
111 | boundaries. |
---|
112 | |
---|
113 | - IMFS_SYM_LINK |
---|
114 | |
---|
115 | The IMFS filesystem supports the concept of symbolic links to other nodes |
---|
116 | in any filesystem. A symbolic link consists of a pointer to a character |
---|
117 | string that represents the pathname to the target node. This type of link |
---|
118 | can cross-filesystem boundaries. Just as with most versions of UNIX |
---|
119 | supporting symbolic links, a symbolic link can point to a non-existent |
---|
120 | file. |
---|
121 | |
---|
122 | - IMFS_DEVICE |
---|
123 | |
---|
124 | All RTEMS devices now appear as files under the in memory filesystem. On |
---|
125 | system initialization, all devices are registered as nodes under the file |
---|
126 | system. |
---|
127 | |
---|
128 | Miscellaneous IMFS Information |
---|
129 | ============================== |
---|
130 | |
---|
131 | TBD |
---|
132 | |
---|
133 | Memory associated with the IMFS |
---|
134 | =============================== |
---|
135 | |
---|
136 | A memory based filesystem draws its resources for files and directories from |
---|
137 | the memory resources of the system. When it is time to un-mount the filesystem, |
---|
138 | the memory resources that supported filesystem are set free. In order to free |
---|
139 | these resources, a recursive walk of the filesystems tree structure will be |
---|
140 | performed. As the leaf nodes under the filesystem are encountered their |
---|
141 | resources are freed. When directories are made empty by this process, their |
---|
142 | resources are freed. |
---|
143 | |
---|
144 | Node removal constraints for the IMFS |
---|
145 | ------------------------------------- |
---|
146 | |
---|
147 | The IMFS conforms to the general filesystem requirements for node removal. See |
---|
148 | :ref:`file-and-directory-removal-constraints`. |
---|
149 | |
---|
150 | IMFS General Housekeeping Notes |
---|
151 | ------------------------------- |
---|
152 | |
---|
153 | The following is a list of odd housekeeping notes for the IMFS. |
---|
154 | |
---|
155 | - If the global variable rtems_filesystem_current refers to the node that we |
---|
156 | are trying to remove, the node_access element of this structure must be set |
---|
157 | to NULL to invalidate it. |
---|
158 | |
---|
159 | - If the node was of IMFS_MEMORY_FILE type, free the memory associated with the |
---|
160 | memory file before freeing the node. Use the IMFS_memfile_remove() function. |
---|
161 | |
---|
162 | IMFS Operation Tables |
---|
163 | ===================== |
---|
164 | |
---|
165 | IMFS Filesystem Handler Table Functions |
---|
166 | --------------------------------------- |
---|
167 | |
---|
168 | OPS table functions are defined in a rtems_filesystem_operations_table |
---|
169 | structure. It defines functions that are specific to a given filesystem. One |
---|
170 | table exists for each filesystem that is supported in the RTEMS |
---|
171 | configuration. The structure definition appears below and is followed by |
---|
172 | general developmental information on each of the functions contained in this |
---|
173 | function management structure. |
---|
174 | |
---|
175 | .. code-block:: c |
---|
176 | |
---|
177 | rtems_filesystem_operations_table IMFS_ops = { |
---|
178 | IMFS_eval_path, |
---|
179 | IMFS_evaluate_for_make, |
---|
180 | IMFS_link, |
---|
181 | IMFS_unlink, |
---|
182 | IMFS_node_type, |
---|
183 | IMFS_mknod, |
---|
184 | IMFS_rmnod, |
---|
185 | IMFS_chown, |
---|
186 | IMFS_freenodinfo, |
---|
187 | IMFS_mount, |
---|
188 | IMFS_initialize, |
---|
189 | IMFS_unmount, |
---|
190 | IMFS_fsunmount, |
---|
191 | IMFS_utime, |
---|
192 | IMFS_evaluate_link, |
---|
193 | IMFS_symlink, |
---|
194 | IMFS_readlink |
---|
195 | }; |
---|
196 | |
---|
197 | .. COMMENT: @page |
---|
198 | |
---|
199 | IMFS_evalpath() |
---|
200 | ^^^^^^^^^^^^^^^ |
---|
201 | |
---|
202 | Corresponding Structure Element: |
---|
203 | XXX |
---|
204 | |
---|
205 | Arguments: |
---|
206 | XXX |
---|
207 | |
---|
208 | File: |
---|
209 | XXX |
---|
210 | |
---|
211 | Description: |
---|
212 | XXX |
---|
213 | |
---|
214 | IMFS_evalformake() |
---|
215 | ^^^^^^^^^^^^^^^^^^ |
---|
216 | |
---|
217 | Corresponding Structure Element: |
---|
218 | XXX |
---|
219 | |
---|
220 | Arguments: |
---|
221 | XXX |
---|
222 | |
---|
223 | File: |
---|
224 | XXX |
---|
225 | |
---|
226 | Description: |
---|
227 | XXX |
---|
228 | |
---|
229 | IMFS_link() |
---|
230 | ^^^^^^^^^^^ |
---|
231 | |
---|
232 | Corresponding Structure Element: |
---|
233 | ``link`` |
---|
234 | |
---|
235 | Arguments: |
---|
236 | .. code-block:: c |
---|
237 | |
---|
238 | rtems_filesystem_location_info_t *to_loc, /* IN */ |
---|
239 | rtems_filesystem_location_info_t *parent_loc, /* IN */ |
---|
240 | const char *token /* IN */ |
---|
241 | |
---|
242 | File: |
---|
243 | ``imfs_link.c`` |
---|
244 | |
---|
245 | Description: |
---|
246 | |
---|
247 | This routine is used in the IMFS filesystem to create a hard-link. |
---|
248 | |
---|
249 | It will first examine the st_nlink count of the node that we are trying to. |
---|
250 | If the link count exceeds LINK_MAX an error will be returned. |
---|
251 | |
---|
252 | The name of the link will be normalized to remove extraneous separators |
---|
253 | from the end of the name. |
---|
254 | |
---|
255 | IMFS_create_node will be used to create a filesystem node that will have |
---|
256 | the following characteristics: |
---|
257 | |
---|
258 | - parent that was determined in the link() function in file link.c |
---|
259 | |
---|
260 | - Type will be set to IMFS_HARD_LINK |
---|
261 | |
---|
262 | - name will be set to the normalized name |
---|
263 | |
---|
264 | - mode of the hard-link will be set to the mode of the target node |
---|
265 | |
---|
266 | If there was trouble allocating memory for the new node an error will be |
---|
267 | returned. |
---|
268 | |
---|
269 | The st_nlink count of the target node will be incremented to reflect the |
---|
270 | new link. |
---|
271 | |
---|
272 | The time fields of the link will be set to reflect the creation time of the |
---|
273 | hard-link. |
---|
274 | |
---|
275 | IMFS_unlink() |
---|
276 | ^^^^^^^^^^^^^ |
---|
277 | |
---|
278 | Corresponding Structure Element: |
---|
279 | XXX |
---|
280 | |
---|
281 | Arguments: |
---|
282 | XXX |
---|
283 | |
---|
284 | File: |
---|
285 | XXX |
---|
286 | |
---|
287 | Description: |
---|
288 | XXX |
---|
289 | |
---|
290 | IMFS_node_type() |
---|
291 | ^^^^^^^^^^^^^^^^ |
---|
292 | |
---|
293 | Corresponding Structure Element: |
---|
294 | ``IMFS_node_type()`` |
---|
295 | |
---|
296 | Arguments: |
---|
297 | .. code-block:: c |
---|
298 | |
---|
299 | rtems_filesystem_location_info_t *pathloc /* IN */ |
---|
300 | |
---|
301 | File: |
---|
302 | ``imfs_ntype.c`` |
---|
303 | |
---|
304 | Description: |
---|
305 | This routine will locate the IMFS_jnode_t structure that holds ownership |
---|
306 | information for the selected node in the filesystem. |
---|
307 | |
---|
308 | This structure is pointed to by pathloc->node_access. |
---|
309 | |
---|
310 | The IMFS_jnode_t type element indicates one of the node types listed below: |
---|
311 | |
---|
312 | - RTEMS_FILESYSTEM_DIRECTORY |
---|
313 | |
---|
314 | - RTEMS_FILESYSTEM_DEVICE |
---|
315 | |
---|
316 | - RTEMS_FILESYSTEM_HARD_LINK |
---|
317 | |
---|
318 | - RTEMS_FILESYSTEM_MEMORY_FILE |
---|
319 | |
---|
320 | .. COMMENT: @page |
---|
321 | |
---|
322 | IMFS_mknod() |
---|
323 | ^^^^^^^^^^^^ |
---|
324 | |
---|
325 | Corresponding Structure Element: |
---|
326 | ``IMFS_mknod()`` |
---|
327 | |
---|
328 | Arguments: |
---|
329 | .. code-block:: c |
---|
330 | |
---|
331 | const char *token, /* IN */ |
---|
332 | mode_t mode, /* IN */ |
---|
333 | dev_t dev, /* IN */ |
---|
334 | rtems_filesystem_location_info_t *pathloc /* IN/OUT */ |
---|
335 | |
---|
336 | File: |
---|
337 | ``imfs_mknod.c`` |
---|
338 | |
---|
339 | Description: |
---|
340 | This routine will examine the mode argument to determine is we are trying |
---|
341 | to create a directory, regular file and a device node. The creation of |
---|
342 | other node types is not permitted and will cause an assert. |
---|
343 | |
---|
344 | Memory space will be allocated for a ``jnode`` and the node will be set up |
---|
345 | according to the nodal type that was specified. The IMFS_create_node() |
---|
346 | function performs the allocation and setup of the node. |
---|
347 | |
---|
348 | The only problem that is currently reported is the lack of memory when we |
---|
349 | attempt to allocate space for the ``jnode`` (ENOMEN). |
---|
350 | |
---|
351 | IMFS_rmnod() |
---|
352 | ^^^^^^^^^^^^ |
---|
353 | |
---|
354 | Corresponding Structure Element: |
---|
355 | XXX |
---|
356 | |
---|
357 | Arguments: |
---|
358 | XXX |
---|
359 | |
---|
360 | File: |
---|
361 | XXX |
---|
362 | |
---|
363 | Description: |
---|
364 | XXX |
---|
365 | |
---|
366 | IMFS_chown() |
---|
367 | ^^^^^^^^^^^^ |
---|
368 | |
---|
369 | Corresponding Structure Element: |
---|
370 | ``IMFS_chown()`` |
---|
371 | |
---|
372 | Arguments: |
---|
373 | .. code-block:: c |
---|
374 | |
---|
375 | rtems_filesystem_location_info_t *pathloc /* IN */ |
---|
376 | uid_t owner /* IN */ |
---|
377 | gid_t group /* IN */ |
---|
378 | |
---|
379 | File: |
---|
380 | ``imfs_chown.c`` |
---|
381 | |
---|
382 | Description: |
---|
383 | This routine will locate the IMFS_jnode_t structure that holds ownership |
---|
384 | information for the selected node in the filesystem. |
---|
385 | |
---|
386 | This structure is pointed to by pathloc->node_access. |
---|
387 | |
---|
388 | The st_uid and st_gid fields of the node are then modified. Since this is a |
---|
389 | memory based filesystem, no further action is required to alter the |
---|
390 | ownership of the IMFS_jnode_t structure. |
---|
391 | |
---|
392 | IMFS_freenod() |
---|
393 | ^^^^^^^^^^^^^^ |
---|
394 | |
---|
395 | Corresponding Structure Element: |
---|
396 | ``IMFS_freenod()`` |
---|
397 | |
---|
398 | Arguments: |
---|
399 | .. code-block:: c |
---|
400 | |
---|
401 | rtems_filesystem_location_info_t *pathloc /* IN */ |
---|
402 | |
---|
403 | File: |
---|
404 | ``imfs_free.c`` |
---|
405 | |
---|
406 | Description: |
---|
407 | This method is a private function to the IMFS. It is called by IMFS |
---|
408 | routines to free nodes that have been allocated. Examples of where this |
---|
409 | routine may be called from are unlink and rmnod. |
---|
410 | |
---|
411 | Note: This routine should not be confused with the filesystem callback |
---|
412 | freenod. The IMFS allocates memory until the node no longer exists. |
---|
413 | |
---|
414 | IMFS_freenodinfo() |
---|
415 | ^^^^^^^^^^^^^^^^^^ |
---|
416 | |
---|
417 | Corresponding Structure Element: |
---|
418 | ``IMFS_freenodinfo()`` |
---|
419 | |
---|
420 | Arguments: |
---|
421 | .. code-block:: c |
---|
422 | |
---|
423 | rtems_filesystem_location_info_t *pathloc /* IN */ |
---|
424 | |
---|
425 | File: |
---|
426 | ``imfs_free.c`` |
---|
427 | |
---|
428 | Description: |
---|
429 | The In-Memory File System does not need to allocate memory during the |
---|
430 | evaluate routines. Therefore, this routine simply routines PASS. |
---|
431 | |
---|
432 | IMFS_mount() |
---|
433 | ^^^^^^^^^^^^ |
---|
434 | |
---|
435 | Corresponding Structure Element: |
---|
436 | ``IMFS_mount()`` |
---|
437 | |
---|
438 | Arguments: |
---|
439 | .. code-block:: c |
---|
440 | |
---|
441 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
442 | |
---|
443 | File: |
---|
444 | ``imfs_mount.c`` |
---|
445 | |
---|
446 | Description: |
---|
447 | This routine provides the filesystem specific processing required to mount |
---|
448 | a filesystem for the system that contains the mount point. It will |
---|
449 | determine if the point that we are trying to mount onto is a node of |
---|
450 | IMFS_DIRECTORY type. |
---|
451 | |
---|
452 | If it is the node's info element is altered so that the |
---|
453 | info.directory.mt_fs element points to the mount table chain entry that is |
---|
454 | associated with the mounted filesystem at this point. The |
---|
455 | info.directory.mt_fs element can be examined to determine if a filesystem |
---|
456 | is mounted at a directory. If it is NULL, the directory does not serve as a |
---|
457 | mount point. A non-NULL entry indicates that the directory does serve as a |
---|
458 | mount point and the value of info.directory.mt_fs can be used to locate the |
---|
459 | mount table chain entry that describes the filesystem mounted at this |
---|
460 | point. |
---|
461 | |
---|
462 | IMFS_fsmount_me() |
---|
463 | ^^^^^^^^^^^^^^^^^ |
---|
464 | |
---|
465 | Corresponding Structure Element: |
---|
466 | ``IMFS_initialize()`` |
---|
467 | |
---|
468 | Arguments: |
---|
469 | .. code-block:: c |
---|
470 | |
---|
471 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
472 | |
---|
473 | File: |
---|
474 | ``imfs_init.c`` |
---|
475 | |
---|
476 | Description: |
---|
477 | This function is provided with a filesystem to take care of the internal |
---|
478 | filesystem management details associated with mounting that filesystem |
---|
479 | under the RTEMS environment. |
---|
480 | |
---|
481 | It is not responsible for the mounting details associated the filesystem |
---|
482 | containing the mount point. |
---|
483 | |
---|
484 | The rtems_filesystem_mount_table_entry_t structure contains the key |
---|
485 | elements below: |
---|
486 | |
---|
487 | .. code-block:: c |
---|
488 | |
---|
489 | rtems_filesystem_location_info_t *mt_point_node, |
---|
490 | |
---|
491 | This structure contains information about the mount point. This allows us |
---|
492 | to find the ops-table and the handling functions associated with the |
---|
493 | filesystem containing the mount point. |
---|
494 | |
---|
495 | .. code-block:: c |
---|
496 | |
---|
497 | rtems_filesystem_location_info_t *fs_root_node, |
---|
498 | |
---|
499 | This structure contains information about the root node in the file system |
---|
500 | to be mounted. It allows us to find the ops-table and the handling |
---|
501 | functions associated with the filesystem to be mounted. |
---|
502 | |
---|
503 | .. code-block:: c |
---|
504 | |
---|
505 | rtems_filesystem_options_t options, |
---|
506 | |
---|
507 | Read only or read/write access |
---|
508 | |
---|
509 | .. code-block:: c |
---|
510 | |
---|
511 | void *fs_info, |
---|
512 | |
---|
513 | This points to an allocated block of memory the will be used to hold any |
---|
514 | filesystem specific information of a global nature. This allocated region |
---|
515 | if important because it allows us to mount the same filesystem type more |
---|
516 | than once under the RTEMS system. Each instance of the mounted filesystem |
---|
517 | has its own set of global management information that is separate from the |
---|
518 | global management information associated with the other instances of the |
---|
519 | mounted filesystem type. |
---|
520 | |
---|
521 | .. code-block:: c |
---|
522 | |
---|
523 | rtems_filesystem_limits_and_options_t pathconf_info, |
---|
524 | |
---|
525 | The table contains the following set of values associated with the mounted |
---|
526 | filesystem: |
---|
527 | |
---|
528 | - link_max |
---|
529 | |
---|
530 | - max_canon |
---|
531 | |
---|
532 | - max_input |
---|
533 | |
---|
534 | - name_max |
---|
535 | |
---|
536 | - path_max |
---|
537 | |
---|
538 | - pipe_buf |
---|
539 | |
---|
540 | - posix_async_io |
---|
541 | |
---|
542 | - posix_chown_restrictions |
---|
543 | |
---|
544 | - posix_no_trunc |
---|
545 | |
---|
546 | - posix_prio_io |
---|
547 | |
---|
548 | - posix_sync_io |
---|
549 | |
---|
550 | - posix_vdisable |
---|
551 | |
---|
552 | These values are accessed with the pathconf() and the fpathconf () |
---|
553 | functions. |
---|
554 | |
---|
555 | .. code-block:: c |
---|
556 | |
---|
557 | const char *dev |
---|
558 | |
---|
559 | The is intended to contain a string that identifies the device that |
---|
560 | contains the filesystem information. The filesystems that are currently |
---|
561 | implemented are memory based and don't require a device specification. |
---|
562 | |
---|
563 | If the mt_point_node.node_access is NULL then we are mounting the base file |
---|
564 | system. |
---|
565 | |
---|
566 | The routine will create a directory node for the root of the IMFS file |
---|
567 | system. |
---|
568 | |
---|
569 | The node will have read, write and execute permissions for owner, group and |
---|
570 | others. |
---|
571 | |
---|
572 | The node's name will be a null string. |
---|
573 | |
---|
574 | A filesystem information structure(fs_info) will be allocated and |
---|
575 | initialized for the IMFS filesystem. The fs_info pointer in the mount table |
---|
576 | entry will be set to point the filesystem information structure. |
---|
577 | |
---|
578 | The pathconf_info element of the mount table will be set to the appropriate |
---|
579 | table of path configuration constants ( IMFS_LIMITS_AND_OPTIONS ). |
---|
580 | |
---|
581 | The fs_root_node structure will be filled in with the following: |
---|
582 | |
---|
583 | - pointer to the allocated root node of the filesystem |
---|
584 | |
---|
585 | - directory handlers for a directory node under the IMFS filesystem |
---|
586 | |
---|
587 | - OPS table functions for the IMFS |
---|
588 | |
---|
589 | A 0 will be returned to the calling routine if the process succeeded, |
---|
590 | otherwise a 1 will be returned. |
---|
591 | |
---|
592 | IMFS_unmount() |
---|
593 | ^^^^^^^^^^^^^^ |
---|
594 | |
---|
595 | Corresponding Structure Element: |
---|
596 | ``IMFS_unmount()`` |
---|
597 | |
---|
598 | Arguments: |
---|
599 | .. code-block:: c |
---|
600 | |
---|
601 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
602 | |
---|
603 | File: |
---|
604 | ``imfs_unmount.c`` |
---|
605 | |
---|
606 | Description: |
---|
607 | This routine allows the IMFS to unmount a filesystem that has been mounted |
---|
608 | onto a IMFS directory. |
---|
609 | |
---|
610 | The mount entry mount point node access is verified to be a mounted |
---|
611 | directory. It's mt_fs is set to NULL. This identifies to future calles |
---|
612 | into the IMFS that this directory node is no longer a mount point. |
---|
613 | Additionally, it will allow any directories that were hidden by the mounted |
---|
614 | system to again become visible. |
---|
615 | |
---|
616 | IMFS_fsunmount() |
---|
617 | ^^^^^^^^^^^^^^^^ |
---|
618 | |
---|
619 | Corresponding Structure Element: |
---|
620 | ``imfs_fsunmount()`` |
---|
621 | |
---|
622 | Arguments: |
---|
623 | .. code-block:: c |
---|
624 | |
---|
625 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
626 | |
---|
627 | File: |
---|
628 | ``imfs_init.c`` |
---|
629 | |
---|
630 | Description: |
---|
631 | This method unmounts this instance of the IMFS file system. It is the |
---|
632 | counterpart to the IMFS_initialize routine. It is called by the generic |
---|
633 | code under the fsunmount_me callback. |
---|
634 | |
---|
635 | All method loops finding the first encountered node with no children and |
---|
636 | removing the node from the tree, thus returning allocated resources. This |
---|
637 | is done until all allocated nodes are returned. |
---|
638 | |
---|
639 | IMFS_utime() |
---|
640 | ^^^^^^^^^^^^ |
---|
641 | |
---|
642 | Corresponding Structure Element: |
---|
643 | XXX |
---|
644 | |
---|
645 | Arguments: |
---|
646 | XXX |
---|
647 | |
---|
648 | File: |
---|
649 | XXX |
---|
650 | |
---|
651 | Description: |
---|
652 | XXX |
---|
653 | |
---|
654 | IMFS_eval_link() |
---|
655 | ^^^^^^^^^^^^^^^^ |
---|
656 | |
---|
657 | Corresponding Structure Element: |
---|
658 | XXX |
---|
659 | |
---|
660 | Arguments: |
---|
661 | XXX |
---|
662 | |
---|
663 | File: |
---|
664 | XXX |
---|
665 | |
---|
666 | Description: |
---|
667 | XXX |
---|
668 | |
---|
669 | Regular File Handler Table Functions |
---|
670 | ------------------------------------ |
---|
671 | |
---|
672 | Handler table functions are defined in a rtems_filesystem_file_handlers_r |
---|
673 | structure. It defines functions that are specific to a node type in a given |
---|
674 | filesystem. One table exists for each of the filesystem's node types. The |
---|
675 | structure definition appears below. It is followed by general developmental |
---|
676 | information on each of the functions associated with regular files contained in |
---|
677 | this function management structure. |
---|
678 | |
---|
679 | .. code-block:: c |
---|
680 | |
---|
681 | rtems_filesystem_file_handlers_r IMFS_memfile_handlers = { |
---|
682 | memfile_open, |
---|
683 | memfile_close, |
---|
684 | memfile_read, |
---|
685 | memfile_write, |
---|
686 | memfile_ioctl, |
---|
687 | memfile_lseek, |
---|
688 | IMFS_stat, |
---|
689 | IMFS_fchmod, |
---|
690 | memfile_ftruncate, |
---|
691 | NULL, /* fpathconf */ |
---|
692 | NULL, /* fsync */ |
---|
693 | IMFS_fdatasync, |
---|
694 | IMFS_fcntl |
---|
695 | }; |
---|
696 | |
---|
697 | memfile_open() for Regular Files |
---|
698 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
699 | |
---|
700 | Corresponding Structure Element: |
---|
701 | ``memfile_open()`` |
---|
702 | |
---|
703 | Arguments: |
---|
704 | .. code-block:: c |
---|
705 | |
---|
706 | rtems_libio_t *iop, |
---|
707 | const char *pathname, |
---|
708 | unsigned32 flag, |
---|
709 | unsigned32 mode |
---|
710 | |
---|
711 | File: |
---|
712 | ``memfile.c`` |
---|
713 | |
---|
714 | Description: |
---|
715 | Currently this function is a shell. No meaningful processing is performed |
---|
716 | and a success code is always returned. |
---|
717 | |
---|
718 | memfile_close() for Regular Files |
---|
719 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
720 | |
---|
721 | Corresponding Structure Element: |
---|
722 | ``memfile_close()`` |
---|
723 | |
---|
724 | Arguments: |
---|
725 | .. code-block:: c |
---|
726 | |
---|
727 | rtems_libio_t *iop |
---|
728 | |
---|
729 | File: |
---|
730 | ``memfile.c`` |
---|
731 | |
---|
732 | Description: |
---|
733 | This routine is a dummy for regular files under the base filesystem. It |
---|
734 | performs a capture of the IMFS_jnode_t pointer from the file control block |
---|
735 | and then immediately returns a success status. |
---|
736 | |
---|
737 | memfile_read() for Regular Files |
---|
738 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
739 | |
---|
740 | Corresponding Structure Element: |
---|
741 | ``memfile_read()`` |
---|
742 | |
---|
743 | Arguments: |
---|
744 | .. code-block:: c |
---|
745 | |
---|
746 | rtems_libio_t *iop, |
---|
747 | void *buffer, |
---|
748 | unsigned32 count |
---|
749 | |
---|
750 | File: |
---|
751 | ``memfile.c`` |
---|
752 | |
---|
753 | Description: |
---|
754 | This routine will determine the ``jnode`` that is associated with this |
---|
755 | file. |
---|
756 | |
---|
757 | It will then call IMFS_memfile_read() with the ``jnode``, file position |
---|
758 | index, buffer and transfer count as arguments. |
---|
759 | |
---|
760 | IMFS_memfile_read() will do the following: |
---|
761 | |
---|
762 | - Verify that the ``jnode`` is associated with a memory file |
---|
763 | |
---|
764 | - Verify that the destination of the read is valid |
---|
765 | |
---|
766 | - Adjust the length of the read if it is too long |
---|
767 | |
---|
768 | - Acquire data from the memory blocks associated with the file |
---|
769 | |
---|
770 | - Update the access time for the data in the file |
---|
771 | |
---|
772 | memfile_write() for Regular Files |
---|
773 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
774 | |
---|
775 | Corresponding Structure Element: |
---|
776 | XXX |
---|
777 | |
---|
778 | Arguments: |
---|
779 | XXX |
---|
780 | |
---|
781 | File: |
---|
782 | XXX |
---|
783 | |
---|
784 | Description: |
---|
785 | XXX |
---|
786 | |
---|
787 | memfile_ioctl() for Regular Files |
---|
788 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
789 | |
---|
790 | Corresponding Structure Element: |
---|
791 | XXX |
---|
792 | |
---|
793 | Arguments: |
---|
794 | .. code-block:: c |
---|
795 | |
---|
796 | rtems_libio_t *iop, |
---|
797 | unsigned32 command, |
---|
798 | void *buffer |
---|
799 | |
---|
800 | File: |
---|
801 | ``memfile.c`` |
---|
802 | |
---|
803 | Description: |
---|
804 | The current code is a placeholder for future development. The routine |
---|
805 | returns a successful completion status. |
---|
806 | |
---|
807 | memfile_lseek() for Regular Files |
---|
808 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
809 | |
---|
810 | Corresponding Structure Element: |
---|
811 | ``Memfile_lseek()`` |
---|
812 | |
---|
813 | Arguments: |
---|
814 | .. code-block:: c |
---|
815 | |
---|
816 | rtems_libio_t *iop, |
---|
817 | off_t offset, |
---|
818 | int whence |
---|
819 | |
---|
820 | File: |
---|
821 | ``memfile.c`` |
---|
822 | |
---|
823 | Description: |
---|
824 | This routine make sure that the memory based file is sufficiently large to |
---|
825 | allow for the new file position index. |
---|
826 | |
---|
827 | The IMFS_memfile_extend() function is used to evaluate the current size of |
---|
828 | the memory file and allocate additional memory blocks if required by the |
---|
829 | new file position index. A success code is always returned from this |
---|
830 | routine. |
---|
831 | |
---|
832 | IMFS_stat() for Regular Files |
---|
833 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
834 | |
---|
835 | Corresponding Structure Element: |
---|
836 | ``IMFS_stat()`` |
---|
837 | |
---|
838 | Arguments: |
---|
839 | .. code-block:: c |
---|
840 | |
---|
841 | rtems_filesystem_location_info_t *loc, |
---|
842 | struct stat *buf |
---|
843 | |
---|
844 | File: |
---|
845 | ``imfs_stat.c`` |
---|
846 | |
---|
847 | Description: |
---|
848 | This routine actually performs status processing for both devices and |
---|
849 | regular files. |
---|
850 | |
---|
851 | The IMFS_jnode_t structure is referenced to determine the type of node |
---|
852 | under the filesystem. |
---|
853 | |
---|
854 | If the node is associated with a device, node information is extracted and |
---|
855 | transformed to set the st_dev element of the stat structure. |
---|
856 | |
---|
857 | If the node is a regular file, the size of the regular file is extracted |
---|
858 | from the node. |
---|
859 | |
---|
860 | This routine rejects other node types. |
---|
861 | |
---|
862 | The following information is extracted from the node and placed in the stat |
---|
863 | structure: |
---|
864 | |
---|
865 | - st_mode |
---|
866 | |
---|
867 | - st_nlink |
---|
868 | |
---|
869 | - st_ino |
---|
870 | |
---|
871 | - st_uid |
---|
872 | |
---|
873 | - st_gid |
---|
874 | |
---|
875 | - st_atime |
---|
876 | |
---|
877 | - st_mtime |
---|
878 | |
---|
879 | - st_ctime |
---|
880 | |
---|
881 | IMFS_fchmod() for Regular Files |
---|
882 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
883 | |
---|
884 | Corresponding Structure Element: |
---|
885 | ``IMFS_fchmod()`` |
---|
886 | |
---|
887 | Arguments: |
---|
888 | .. code-block:: c |
---|
889 | |
---|
890 | rtems_libio_t *iop |
---|
891 | mode_t mode |
---|
892 | |
---|
893 | File: |
---|
894 | ``imfs_fchmod.c`` |
---|
895 | |
---|
896 | Description: |
---|
897 | This routine will obtain the pointer to the IMFS_jnode_t structure from the |
---|
898 | information currently in the file control block. |
---|
899 | |
---|
900 | Based on configuration the routine will acquire the user ID from a call to |
---|
901 | getuid() or from the IMFS_jnode_t structure. |
---|
902 | |
---|
903 | It then checks to see if we have the ownership rights to alter the mode of |
---|
904 | the file. If the caller does not, an error code is returned. |
---|
905 | |
---|
906 | An additional test is performed to verify that the caller is not trying to |
---|
907 | alter the nature of the node. If the caller is attempting to alter more |
---|
908 | than the permissions associated with user group and other, an error is |
---|
909 | returned. |
---|
910 | |
---|
911 | If all the preconditions are met, the user, group and other fields are set |
---|
912 | based on the mode calling parameter. |
---|
913 | |
---|
914 | memfile_ftruncate() for Regular Files |
---|
915 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
916 | |
---|
917 | Corresponding Structure Element: |
---|
918 | XXX |
---|
919 | |
---|
920 | Arguments: |
---|
921 | XXX |
---|
922 | |
---|
923 | File: |
---|
924 | XXX |
---|
925 | |
---|
926 | Description: |
---|
927 | XXX |
---|
928 | |
---|
929 | No pathconf() for Regular Files |
---|
930 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
931 | |
---|
932 | Corresponding Structure Element: |
---|
933 | ``NULL`` |
---|
934 | |
---|
935 | Arguments: |
---|
936 | Not Implemented |
---|
937 | |
---|
938 | File: |
---|
939 | Not Implemented |
---|
940 | |
---|
941 | Description: |
---|
942 | Not Implemented |
---|
943 | |
---|
944 | No fsync() for Regular Files |
---|
945 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
946 | |
---|
947 | Corresponding Structure Element: |
---|
948 | XXX |
---|
949 | |
---|
950 | Arguments: |
---|
951 | XXX |
---|
952 | |
---|
953 | File: |
---|
954 | XXX |
---|
955 | |
---|
956 | Description: |
---|
957 | XXX |
---|
958 | |
---|
959 | IMFS_fdatasync() for Regular Files |
---|
960 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
961 | |
---|
962 | Corresponding Structure Element: |
---|
963 | XXX |
---|
964 | |
---|
965 | Arguments: |
---|
966 | XXX |
---|
967 | |
---|
968 | File: |
---|
969 | XXX |
---|
970 | |
---|
971 | Description: |
---|
972 | XXX |
---|
973 | |
---|
974 | Directory Handler Table Functions |
---|
975 | --------------------------------- |
---|
976 | |
---|
977 | Handler table functions are defined in a rtems_filesystem_file_handlers_r |
---|
978 | structure. It defines functions that are specific to a node type in a given |
---|
979 | filesystem. One table exists for each of the filesystem's node types. The |
---|
980 | structure definition appears below. It is followed by general developmental |
---|
981 | information on each of the functions associated with directories contained in |
---|
982 | this function management structure. |
---|
983 | |
---|
984 | .. code:: c |
---|
985 | |
---|
986 | rtems_filesystem_file_handlers_r IMFS_directory_handlers = { |
---|
987 | IMFS_dir_open, |
---|
988 | IMFS_dir_close, |
---|
989 | IMFS_dir_read, |
---|
990 | NULL, /* write */ |
---|
991 | NULL, /* ioctl */ |
---|
992 | IMFS_dir_lseek, |
---|
993 | IMFS_dir_fstat, |
---|
994 | IMFS_fchmod, |
---|
995 | NULL, /* ftruncate */ |
---|
996 | NULL, /* fpathconf */ |
---|
997 | NULL, /* fsync */ |
---|
998 | IMFS_fdatasync, |
---|
999 | IMFS_fcntl |
---|
1000 | }; |
---|
1001 | |
---|
1002 | IMFS_dir_open() for Directories |
---|
1003 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1004 | |
---|
1005 | Corresponding Structure Element: |
---|
1006 | ``imfs_dir_open()`` |
---|
1007 | |
---|
1008 | Arguments: |
---|
1009 | .. code-block:: c |
---|
1010 | |
---|
1011 | rtems_libio_t *iop, |
---|
1012 | const char *pathname, |
---|
1013 | unsigned32 flag, |
---|
1014 | unsigned32 mode |
---|
1015 | |
---|
1016 | File: |
---|
1017 | ``imfs_directory.c`` |
---|
1018 | |
---|
1019 | Description: |
---|
1020 | This routine will look into the file control block to find the ``jnode`` |
---|
1021 | that is associated with the directory. |
---|
1022 | |
---|
1023 | The routine will verify that the node is a directory. If its not a |
---|
1024 | directory an error code will be returned. |
---|
1025 | |
---|
1026 | If it is a directory, the offset in the file control block will be set |
---|
1027 | to 0. This allows us to start reading at the beginning of the directory. |
---|
1028 | |
---|
1029 | IMFS_dir_close() for Directories |
---|
1030 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1031 | |
---|
1032 | Corresponding Structure Element: |
---|
1033 | ``imfs_dir_close()`` |
---|
1034 | |
---|
1035 | Arguments: |
---|
1036 | .. code-block:: c |
---|
1037 | |
---|
1038 | rtems_libio_t *iop |
---|
1039 | |
---|
1040 | File: |
---|
1041 | ``imfs_directory.c`` |
---|
1042 | |
---|
1043 | Description: |
---|
1044 | This routine is a dummy for directories under the base filesystem. It |
---|
1045 | immediately returns a success status. |
---|
1046 | |
---|
1047 | IMFS_dir_read() for Directories |
---|
1048 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1049 | |
---|
1050 | Corresponding Structure Element: |
---|
1051 | ``imfs_dir_read`` |
---|
1052 | |
---|
1053 | Arguments: |
---|
1054 | .. code-block:: c |
---|
1055 | |
---|
1056 | rtems_libio_t *iop, |
---|
1057 | void *buffer, |
---|
1058 | unsigned32 count |
---|
1059 | |
---|
1060 | File: |
---|
1061 | ``imfs_directory.c`` |
---|
1062 | |
---|
1063 | Description: |
---|
1064 | This routine will read a fixed number of directory entries from the current |
---|
1065 | directory offset. The number of directory bytes read will be returned from |
---|
1066 | this routine. |
---|
1067 | |
---|
1068 | No write() for Directories |
---|
1069 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1070 | |
---|
1071 | Corresponding Structure Element: |
---|
1072 | XXX |
---|
1073 | |
---|
1074 | Arguments: |
---|
1075 | XXX |
---|
1076 | |
---|
1077 | File: |
---|
1078 | XXX |
---|
1079 | |
---|
1080 | Description: |
---|
1081 | XXX |
---|
1082 | |
---|
1083 | No ioctl() for Directories |
---|
1084 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1085 | |
---|
1086 | Corresponding Structure Element: |
---|
1087 | ``ioctl`` |
---|
1088 | |
---|
1089 | Arguments: |
---|
1090 | Not supported |
---|
1091 | |
---|
1092 | File: |
---|
1093 | Not supported |
---|
1094 | |
---|
1095 | Description: |
---|
1096 | XXX |
---|
1097 | |
---|
1098 | IMFS_dir_lseek() for Directories |
---|
1099 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1100 | |
---|
1101 | Corresponding Structure Element: |
---|
1102 | ``imfs_dir_lseek()`` |
---|
1103 | |
---|
1104 | Arguments: |
---|
1105 | .. code-block:: c |
---|
1106 | |
---|
1107 | rtems_libio_t *iop, |
---|
1108 | off_t offset, |
---|
1109 | int whence |
---|
1110 | |
---|
1111 | File: |
---|
1112 | ``imfs_directory.c`` |
---|
1113 | |
---|
1114 | Description: |
---|
1115 | This routine alters the offset in the file control block. |
---|
1116 | |
---|
1117 | No test is performed on the number of children under the current open |
---|
1118 | directory. The imfs_dir_read() function protects against reads beyond the |
---|
1119 | current size to the directory by returning a 0 bytes transfered to the |
---|
1120 | calling programs whenever the file position index exceeds the last entry in |
---|
1121 | the open directory. |
---|
1122 | |
---|
1123 | IMFS_dir_fstat() for Directories |
---|
1124 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1125 | |
---|
1126 | Corresponding Structure Element: |
---|
1127 | ``imfs_dir_fstat()`` |
---|
1128 | |
---|
1129 | Arguments: |
---|
1130 | .. code-block:: c |
---|
1131 | |
---|
1132 | rtems_filesystem_location_info_t *loc, |
---|
1133 | struct stat *buf |
---|
1134 | |
---|
1135 | File: |
---|
1136 | ``imfs_directory.c`` |
---|
1137 | |
---|
1138 | Description: |
---|
1139 | The node access information in the rtems_filesystem_location_info_t |
---|
1140 | structure is used to locate the appropriate IMFS_jnode_t structure. The |
---|
1141 | following information is taken from the IMFS_jnode_t structure and placed |
---|
1142 | in the stat structure: |
---|
1143 | |
---|
1144 | - st_ino |
---|
1145 | |
---|
1146 | - st_mode |
---|
1147 | |
---|
1148 | - st_nlink |
---|
1149 | |
---|
1150 | - st_uid |
---|
1151 | |
---|
1152 | - st_gid |
---|
1153 | |
---|
1154 | - st_atime |
---|
1155 | |
---|
1156 | - st_mtime |
---|
1157 | |
---|
1158 | - st_ctime |
---|
1159 | |
---|
1160 | The st_size field is obtained by running through the chain of directory |
---|
1161 | entries and summing the sizes of the dirent structures associated with each |
---|
1162 | of the children of the directory. |
---|
1163 | |
---|
1164 | IMFS_fchmod() for Directories |
---|
1165 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1166 | |
---|
1167 | Corresponding Structure Element: |
---|
1168 | ``IMFS_fchmod()`` |
---|
1169 | |
---|
1170 | Arguments: |
---|
1171 | .. code-block:: c |
---|
1172 | |
---|
1173 | rtems_libio_t *iop |
---|
1174 | mode_t mode |
---|
1175 | |
---|
1176 | File: |
---|
1177 | ``imfs_fchmod.c`` |
---|
1178 | |
---|
1179 | Description: |
---|
1180 | This routine will obtain the pointer to the IMFS_jnode_t structure from the |
---|
1181 | information currently in the file control block. |
---|
1182 | |
---|
1183 | Based on configuration the routine will acquire the user ID from a call to |
---|
1184 | getuid() or from the IMFS_jnode_t structure. |
---|
1185 | |
---|
1186 | It then checks to see if we have the ownership rights to alter the mode of |
---|
1187 | the file. If the caller does not, an error code is returned. |
---|
1188 | |
---|
1189 | An additional test is performed to verify that the caller is not trying to |
---|
1190 | alter the nature of the node. If the caller is attempting to alter more |
---|
1191 | than the permissions associated with user group and other, an error is |
---|
1192 | returned. |
---|
1193 | |
---|
1194 | If all the preconditions are met, the user, group and other fields are set |
---|
1195 | based on the mode calling parameter. |
---|
1196 | |
---|
1197 | No ftruncate() for Directories |
---|
1198 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1199 | |
---|
1200 | Corresponding Structure Element: |
---|
1201 | XXX |
---|
1202 | |
---|
1203 | Arguments: |
---|
1204 | XXX |
---|
1205 | |
---|
1206 | File: |
---|
1207 | XXX |
---|
1208 | |
---|
1209 | Description: |
---|
1210 | XXX |
---|
1211 | |
---|
1212 | No fpathconf() for Directories |
---|
1213 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1214 | |
---|
1215 | Corresponding Structure Element: |
---|
1216 | ``fpathconf`` |
---|
1217 | |
---|
1218 | Arguments: |
---|
1219 | Not Implemented |
---|
1220 | |
---|
1221 | File: |
---|
1222 | Not Implemented |
---|
1223 | |
---|
1224 | Description: |
---|
1225 | Not Implemented |
---|
1226 | |
---|
1227 | No fsync() for Directories |
---|
1228 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1229 | |
---|
1230 | Corresponding Structure Element: |
---|
1231 | XXX |
---|
1232 | |
---|
1233 | Arguments: |
---|
1234 | XXX |
---|
1235 | |
---|
1236 | File: |
---|
1237 | XXX |
---|
1238 | |
---|
1239 | Description: |
---|
1240 | XXX |
---|
1241 | |
---|
1242 | IMFS_fdatasync() for Directories |
---|
1243 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1244 | |
---|
1245 | Corresponding Structure Element: |
---|
1246 | XXX |
---|
1247 | |
---|
1248 | Arguments: |
---|
1249 | XXX |
---|
1250 | |
---|
1251 | File: |
---|
1252 | XXX |
---|
1253 | |
---|
1254 | Description: |
---|
1255 | XXX |
---|
1256 | |
---|
1257 | Device Handler Table Functions |
---|
1258 | ------------------------------ |
---|
1259 | |
---|
1260 | Handler table functions are defined in a rtems_filesystem_file_handlers_r |
---|
1261 | structure. It defines functions that are specific to a node type in a given |
---|
1262 | filesystem. One table exists for each of the filesystem's node types. The |
---|
1263 | structure definition appears below. It is followed by general developmental |
---|
1264 | information on each of the functions associated with devices contained in this |
---|
1265 | function management structure. |
---|
1266 | |
---|
1267 | .. code-block:: c |
---|
1268 | |
---|
1269 | typedef struct { |
---|
1270 | rtems_filesystem_open_t open; |
---|
1271 | rtems_filesystem_close_t close; |
---|
1272 | rtems_filesystem_read_t read; |
---|
1273 | rtems_filesystem_write_t write; |
---|
1274 | rtems_filesystem_ioctl_t ioctl; |
---|
1275 | rtems_filesystem_lseek_t lseek; |
---|
1276 | rtems_filesystem_fstat_t fstat; |
---|
1277 | rtems_filesystem_fchmod_t fchmod; |
---|
1278 | rtems_filesystem_ftruncate_t ftruncate; |
---|
1279 | rtems_filesystem_fpathconf_t fpathconf; |
---|
1280 | rtems_filesystem_fsync_t fsync; |
---|
1281 | rtems_filesystem_fdatasync_t fdatasync; |
---|
1282 | } rtems_filesystem_file_handlers_r; |
---|
1283 | |
---|
1284 | device_open() for Devices |
---|
1285 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1286 | |
---|
1287 | Corresponding Structure Element: |
---|
1288 | ``device_open()`` |
---|
1289 | |
---|
1290 | Arguments: |
---|
1291 | .. code-block:: c |
---|
1292 | |
---|
1293 | rtems_libio_t *iop, |
---|
1294 | const char *pathname, |
---|
1295 | unsigned32 flag, |
---|
1296 | unsigned32 mode |
---|
1297 | |
---|
1298 | File: |
---|
1299 | ``deviceio.c`` |
---|
1300 | |
---|
1301 | Description: |
---|
1302 | This routine will use the file control block to locate the node structure |
---|
1303 | for the device. |
---|
1304 | |
---|
1305 | It will extract the major and minor device numbers from the ``jnode``. |
---|
1306 | |
---|
1307 | The major and minor device numbers will be used to make a rtems_io_open() |
---|
1308 | function call to open the device driver. An argument list is sent to the |
---|
1309 | driver that contains the file control block, flags and mode information. |
---|
1310 | |
---|
1311 | device_close() for Devices |
---|
1312 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1313 | |
---|
1314 | Corresponding Structure Element: |
---|
1315 | ``device_close()`` |
---|
1316 | |
---|
1317 | Arguments: |
---|
1318 | .. code-block:: c |
---|
1319 | |
---|
1320 | rtems_libio_t *iop |
---|
1321 | |
---|
1322 | File: |
---|
1323 | ``deviceio.c`` |
---|
1324 | |
---|
1325 | Description: |
---|
1326 | This routine extracts the major and minor device driver numbers from the |
---|
1327 | IMFS_jnode_t that is referenced in the file control block. |
---|
1328 | |
---|
1329 | It also forms an argument list that contains the file control block. |
---|
1330 | |
---|
1331 | A rtems_io_close() function call is made to close the device specified by |
---|
1332 | the major and minor device numbers. |
---|
1333 | |
---|
1334 | device_read() for Devices |
---|
1335 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1336 | |
---|
1337 | Corresponding Structure Element: |
---|
1338 | ``device_read()`` |
---|
1339 | |
---|
1340 | Arguments: |
---|
1341 | .. code-block:: c |
---|
1342 | |
---|
1343 | rtems_libio_t *iop, |
---|
1344 | void *buffer, |
---|
1345 | unsigned32 count |
---|
1346 | |
---|
1347 | File: |
---|
1348 | ``deviceio.c`` |
---|
1349 | |
---|
1350 | Description: |
---|
1351 | This routine will extract the major and minor numbers for the device from |
---|
1352 | the - jnode- associated with the file descriptor. |
---|
1353 | |
---|
1354 | A rtems_io_read() call will be made to the device driver associated with |
---|
1355 | the file descriptor. The major and minor device number will be sent as |
---|
1356 | arguments as well as an argument list consisting of: |
---|
1357 | |
---|
1358 | - file control block |
---|
1359 | |
---|
1360 | - file position index |
---|
1361 | |
---|
1362 | - buffer pointer where the data read is to be placed |
---|
1363 | |
---|
1364 | - count indicating the number of bytes that the program wishes to read from |
---|
1365 | the device |
---|
1366 | |
---|
1367 | - flags from the file control block |
---|
1368 | |
---|
1369 | On return from the rtems_io_read() the number of bytes that were actually |
---|
1370 | read will be returned to the calling program. |
---|
1371 | |
---|
1372 | device_write() for Devices |
---|
1373 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1374 | |
---|
1375 | Corresponding Structure Element: |
---|
1376 | XXX |
---|
1377 | |
---|
1378 | Arguments: |
---|
1379 | XXX |
---|
1380 | |
---|
1381 | File: |
---|
1382 | XXX |
---|
1383 | |
---|
1384 | Description: |
---|
1385 | XXX |
---|
1386 | |
---|
1387 | device_ioctl() for Devices |
---|
1388 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1389 | |
---|
1390 | Corresponding Structure Element: |
---|
1391 | ``ioctl`` |
---|
1392 | |
---|
1393 | Arguments: |
---|
1394 | .. code-block:: c |
---|
1395 | |
---|
1396 | rtems_libio_t *iop, |
---|
1397 | unsigned32 command, |
---|
1398 | void *buffer |
---|
1399 | |
---|
1400 | File: |
---|
1401 | ``deviceio.c`` |
---|
1402 | |
---|
1403 | Description: |
---|
1404 | This handler will obtain status information about a device. |
---|
1405 | |
---|
1406 | The form of status is device dependent. |
---|
1407 | |
---|
1408 | The rtems_io_control() function uses the major and minor number of the |
---|
1409 | device to obtain the status information. |
---|
1410 | |
---|
1411 | rtems_io_control() requires an rtems_libio_ioctl_args_t argument list which |
---|
1412 | contains the file control block, device specific command and a buffer |
---|
1413 | pointer to return the device status information. |
---|
1414 | |
---|
1415 | The device specific command should indicate the nature of the information |
---|
1416 | that is desired from the device. |
---|
1417 | |
---|
1418 | After the rtems_io_control() is processed, the buffer should contain the |
---|
1419 | requested device information. |
---|
1420 | |
---|
1421 | If the device information is not obtained properly a -1 will be returned to |
---|
1422 | the calling program, otherwise the ioctl_return value is returned. |
---|
1423 | |
---|
1424 | device_lseek() for Devices |
---|
1425 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1426 | |
---|
1427 | Corresponding Structure Element: |
---|
1428 | ``device_lseek()`` |
---|
1429 | |
---|
1430 | Arguments: |
---|
1431 | .. code-block:: c |
---|
1432 | |
---|
1433 | rtems_libio_t *iop, |
---|
1434 | off_t offset, |
---|
1435 | int whence |
---|
1436 | |
---|
1437 | File: |
---|
1438 | ``deviceio.c`` |
---|
1439 | |
---|
1440 | Description: |
---|
1441 | At the present time this is a placeholder function. It always returns a |
---|
1442 | successful status. |
---|
1443 | |
---|
1444 | IMFS_stat() for Devices |
---|
1445 | ^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1446 | |
---|
1447 | Corresponding Structure Element: |
---|
1448 | ``IMFS_stat()`` |
---|
1449 | |
---|
1450 | Arguments: |
---|
1451 | .. code-block:: c |
---|
1452 | |
---|
1453 | rtems_filesystem_location_info_t *loc, |
---|
1454 | struct stat *buf |
---|
1455 | |
---|
1456 | File: |
---|
1457 | ``imfs_stat.c`` |
---|
1458 | |
---|
1459 | Description: |
---|
1460 | This routine actually performs status processing for both devices and |
---|
1461 | regular files. |
---|
1462 | |
---|
1463 | The IMFS_jnode_t structure is referenced to determine the type of node |
---|
1464 | under the filesystem. |
---|
1465 | |
---|
1466 | If the node is associated with a device, node information is extracted and |
---|
1467 | transformed to set the st_dev element of the stat structure. |
---|
1468 | |
---|
1469 | If the node is a regular file, the size of the regular file is extracted |
---|
1470 | from the node. |
---|
1471 | |
---|
1472 | This routine rejects other node types. |
---|
1473 | |
---|
1474 | The following information is extracted from the node and placed in the stat |
---|
1475 | structure: |
---|
1476 | |
---|
1477 | - st_mode |
---|
1478 | |
---|
1479 | - st_nlink |
---|
1480 | |
---|
1481 | - st_ino |
---|
1482 | |
---|
1483 | - st_uid |
---|
1484 | |
---|
1485 | - st_gid |
---|
1486 | |
---|
1487 | - st_atime |
---|
1488 | |
---|
1489 | - st_mtime |
---|
1490 | |
---|
1491 | - st_ctime |
---|
1492 | |
---|
1493 | IMFS_fchmod() for Devices |
---|
1494 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1495 | |
---|
1496 | Corresponding Structure Element: |
---|
1497 | ``IMFS_fchmod()`` |
---|
1498 | |
---|
1499 | Arguments: |
---|
1500 | .. code-block:: c |
---|
1501 | |
---|
1502 | rtems_libio_t *iop |
---|
1503 | mode_t mode |
---|
1504 | |
---|
1505 | File: |
---|
1506 | ``imfs_fchmod.c`` |
---|
1507 | |
---|
1508 | Description: |
---|
1509 | This routine will obtain the pointer to the IMFS_jnode_t structure from the |
---|
1510 | information currently in the file control block. |
---|
1511 | |
---|
1512 | Based on configuration the routine will acquire the user ID from a call to |
---|
1513 | getuid() or from the IMFS_jnode_t structure. |
---|
1514 | |
---|
1515 | It then checks to see if we have the ownership rights to alter the mode of |
---|
1516 | the file. If the caller does not, an error code is returned. |
---|
1517 | |
---|
1518 | An additional test is performed to verify that the caller is not trying to |
---|
1519 | alter the nature of the node. If the caller is attempting to alter more |
---|
1520 | than the permissions associated with user group and other, an error is |
---|
1521 | returned. |
---|
1522 | |
---|
1523 | If all the preconditions are met, the user, group and other fields are set |
---|
1524 | based on the mode calling parameter. |
---|
1525 | |
---|
1526 | No ftruncate() for Devices |
---|
1527 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1528 | |
---|
1529 | Corresponding Structure Element: |
---|
1530 | XXX |
---|
1531 | |
---|
1532 | Arguments: |
---|
1533 | XXX |
---|
1534 | |
---|
1535 | File: |
---|
1536 | XXX |
---|
1537 | |
---|
1538 | Description: |
---|
1539 | XXX |
---|
1540 | |
---|
1541 | No fpathconf() for Devices |
---|
1542 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1543 | |
---|
1544 | Corresponding Structure Element: |
---|
1545 | ``fpathconf`` |
---|
1546 | |
---|
1547 | Arguments: |
---|
1548 | Not Implemented |
---|
1549 | |
---|
1550 | File: |
---|
1551 | Not Implemented |
---|
1552 | |
---|
1553 | Description: |
---|
1554 | Not Implemented |
---|
1555 | |
---|
1556 | No fsync() for Devices |
---|
1557 | ^^^^^^^^^^^^^^^^^^^^^^ |
---|
1558 | |
---|
1559 | Corresponding Structure Element: |
---|
1560 | XXX |
---|
1561 | |
---|
1562 | Arguments: |
---|
1563 | XXX |
---|
1564 | |
---|
1565 | File: |
---|
1566 | XXX |
---|
1567 | |
---|
1568 | Description: |
---|
1569 | XXX |
---|
1570 | |
---|
1571 | No fdatasync() for Devices |
---|
1572 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
1573 | |
---|
1574 | Not Implemented |
---|
1575 | |
---|
1576 | Corresponding Structure Element: |
---|
1577 | XXX |
---|
1578 | |
---|
1579 | Arguments: |
---|
1580 | XXX |
---|
1581 | |
---|
1582 | File: |
---|
1583 | XXX |
---|
1584 | |
---|
1585 | Description: |
---|
1586 | XXX |
---|