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