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