1 | .. SPDX-License-Identifier: CC-BY-SA-4.0 |
---|
2 | |
---|
3 | .. Copyright (C) 1988, 2002 On-Line Applications Research Corporation (OAR) |
---|
4 | |
---|
5 | Filesystem Implementation Requirements |
---|
6 | ************************************** |
---|
7 | |
---|
8 | This chapter details the behavioral requirements that all filesystem |
---|
9 | implementations must adhere to. |
---|
10 | |
---|
11 | General |
---|
12 | ======= |
---|
13 | |
---|
14 | The RTEMS filesystem framework was intended to be compliant with the POSIX |
---|
15 | Files and Directories interface standard. The following filesystem |
---|
16 | characteristics resulted in a functional switching layer. |
---|
17 | |
---|
18 | .. code-block:: shell |
---|
19 | |
---|
20 | Figure of the Filesystem Functional Layering goes here. |
---|
21 | This figure includes networking and disk caching layering. |
---|
22 | |
---|
23 | # Application programs are presented with a standard set of POSIX compliant |
---|
24 | functions that allow them to interface with the files, devices and |
---|
25 | directories in the filesystem. The interfaces to these routines do not |
---|
26 | reflect the type of subordinate filesystem implementation in which the file |
---|
27 | will be found. |
---|
28 | |
---|
29 | # The filesystem framework developed under RTEMS allows for mounting filesystem |
---|
30 | of different types under the base filesystem. |
---|
31 | |
---|
32 | # The mechanics of locating file information may be quite different between |
---|
33 | filesystem types. |
---|
34 | |
---|
35 | # The process of locating a file may require crossing filesystem boundaries. |
---|
36 | |
---|
37 | # The transitions between filesystem and the processing required to access |
---|
38 | information in different filesystem is not visible at the level of the POSIX |
---|
39 | function call. |
---|
40 | |
---|
41 | # The POSIX interface standard provides file access by character pathname to |
---|
42 | the file in some functions and through an integer file descriptor in other |
---|
43 | functions. |
---|
44 | |
---|
45 | # The nature of the integer file descriptor and its associated processing is |
---|
46 | operating system and filesystem specific. |
---|
47 | |
---|
48 | # Directory and device information must be processed with some of the same |
---|
49 | routines that apply to files. |
---|
50 | |
---|
51 | # The form and content of directory and device information differs greatly from |
---|
52 | that of a regular file. |
---|
53 | |
---|
54 | # Files, directories and devices represent elements (nodes) of a tree |
---|
55 | hierarchy. |
---|
56 | |
---|
57 | # The rules for processing each of the node types that exist under the |
---|
58 | filesystem are node specific but are still not reflected in the POSIX |
---|
59 | interface routines. |
---|
60 | |
---|
61 | .. code-block:: shell |
---|
62 | |
---|
63 | Figure of the Filesystem Functional Layering goes here. |
---|
64 | This figure focuses on the Base Filesystem and IMFS. |
---|
65 | |
---|
66 | .. code-block:: shell |
---|
67 | |
---|
68 | Figure of the IMFS Memfile control blocks |
---|
69 | |
---|
70 | .. _file-and-directory-removal-constraints: |
---|
71 | |
---|
72 | File and Directory Removal Constraints |
---|
73 | ====================================== |
---|
74 | |
---|
75 | The following POSIX constraints must be honored by all filesystems. |
---|
76 | |
---|
77 | - If a node is a directory with children it cannot be removed. |
---|
78 | |
---|
79 | - The root node of any filesystem, whether the base filesystem or a mounted |
---|
80 | filesystem, cannot be removed. |
---|
81 | |
---|
82 | - A node that is a directory that is acting as the mount point of a file system |
---|
83 | cannot be removed. |
---|
84 | |
---|
85 | - On filesystems supporting hard links, a link count is maintained. Prior to |
---|
86 | node removal, the node's link count is decremented by one. The link count |
---|
87 | must be less than one to allow for removal of the node. |
---|
88 | |
---|
89 | API Layering |
---|
90 | ============ |
---|
91 | |
---|
92 | Mapping of Generic System Calls to Filesystem Specific Functions |
---|
93 | ---------------------------------------------------------------- |
---|
94 | |
---|
95 | The list of generic system calls includes the routines open(), read(), write(), |
---|
96 | close(), etc.. |
---|
97 | |
---|
98 | The Files and Directories section of the POSIX Application Programs Interface |
---|
99 | specifies a set of functions with calling arguments that are used to gain |
---|
100 | access to the information in a filesystem. To the application program, these |
---|
101 | functions allow access to information in any mounted filesystem without |
---|
102 | explicit knowledge of the filesystem type or the filesystem mount |
---|
103 | configuration. The following are functions that are provided to the |
---|
104 | application: |
---|
105 | |
---|
106 | #. access() |
---|
107 | |
---|
108 | #. chdir() |
---|
109 | |
---|
110 | #. chmod() |
---|
111 | |
---|
112 | #. chown() |
---|
113 | |
---|
114 | #. close() |
---|
115 | |
---|
116 | #. closedir() |
---|
117 | |
---|
118 | #. fchmod() |
---|
119 | |
---|
120 | #. fcntl() |
---|
121 | |
---|
122 | #. fdatasync() |
---|
123 | |
---|
124 | #. fpathconf() |
---|
125 | |
---|
126 | #. fstat() |
---|
127 | |
---|
128 | #. fsync() |
---|
129 | |
---|
130 | #. ftruncate() |
---|
131 | |
---|
132 | #. link() |
---|
133 | |
---|
134 | #. lseek() |
---|
135 | |
---|
136 | #. mkdir() |
---|
137 | |
---|
138 | #. mknod() |
---|
139 | |
---|
140 | #. mount() |
---|
141 | |
---|
142 | #. open() |
---|
143 | |
---|
144 | #. opendir() |
---|
145 | |
---|
146 | #. pathconf() |
---|
147 | |
---|
148 | #. read() |
---|
149 | |
---|
150 | #. readdir() |
---|
151 | |
---|
152 | #. rewinddir() |
---|
153 | |
---|
154 | #. rmdir() |
---|
155 | |
---|
156 | #. rmnod() |
---|
157 | |
---|
158 | #. scandir() |
---|
159 | |
---|
160 | #. seekdir() |
---|
161 | |
---|
162 | #. stat() |
---|
163 | |
---|
164 | #. telldir() |
---|
165 | |
---|
166 | #. umask() |
---|
167 | |
---|
168 | #. unlink() |
---|
169 | |
---|
170 | #. unmount() |
---|
171 | |
---|
172 | #. utime() |
---|
173 | |
---|
174 | #. write() |
---|
175 | |
---|
176 | The filesystem's type as well as the node type within the filesystem determine |
---|
177 | the nature of the processing that must be performed for each of the functions |
---|
178 | above. The RTEMS filesystem provides a framework that allows new filesystem to |
---|
179 | be developed and integrated without alteration to the basic framework. |
---|
180 | |
---|
181 | To provide the functional switching that is required, each of the POSIX file |
---|
182 | and directory functions have been implemented as a shell function. The shell |
---|
183 | function adheres to the POSIX interface standard. Within this functional shell, |
---|
184 | filesystem and node type information is accessed which is then used to invoke |
---|
185 | the appropriate filesystem and node type specific routine to process the POSIX |
---|
186 | function call. |
---|
187 | |
---|
188 | File/Device/Directory function access via file control block - rtems_libio_t structure |
---|
189 | -------------------------------------------------------------------------------------- |
---|
190 | |
---|
191 | The POSIX open() function returns an integer file descriptor that is used as a |
---|
192 | reference to file control block information for a specific file. The file |
---|
193 | control block contains information that is used to locate node, file system, |
---|
194 | mount table and functional handler information. The diagram in Figure 8 depicts |
---|
195 | the relationship between and among the following components. |
---|
196 | |
---|
197 | File Descriptor Table: |
---|
198 | This is an internal RTEMS structure that tracks all currently defined file |
---|
199 | descriptors in the system. The index that is returned by the file open() |
---|
200 | operation references a slot in this table. The slot contains a pointer to the |
---|
201 | file descriptor table entry for this file. The rtems_libio_t structure |
---|
202 | represents the file control block. |
---|
203 | |
---|
204 | Allocation of entry in the File Descriptor Table: |
---|
205 | Access to the file descriptor table is controlled through a semaphore that is |
---|
206 | implemented using the rtems_libio_allocate() function. This routine will grab |
---|
207 | a semaphore and then scan the file control blocks to determine which slot is |
---|
208 | free for use. The first free slot is marked as used and the index to this |
---|
209 | slot is returned as the file descriptor for the open() request. After the |
---|
210 | alterations have been made to the file control block table, the semaphore is |
---|
211 | released to allow further operations on the table. |
---|
212 | |
---|
213 | Maximum number of entries in the file descriptor table is configurable |
---|
214 | through the src/exec/sapi/headers/confdefs.h file. If the |
---|
215 | ``CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS`` constant is defined its value |
---|
216 | will represent the maximum number of file descriptors that are allowed. If |
---|
217 | ``CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS`` is not specified a default value |
---|
218 | of 20 will be used as the maximum number of file descriptors allowed. |
---|
219 | |
---|
220 | File control block - rtems_libio_t structure: |
---|
221 | .. code-block:: c |
---|
222 | |
---|
223 | struct rtems_libio_tt { |
---|
224 | rtems_driver_name_t *driver; |
---|
225 | off_t size; |
---|
226 | off_t offset; |
---|
227 | unsigned32 flags; |
---|
228 | rtems_filesystem_location_info_t pathinfo; |
---|
229 | Objects_Id sem; |
---|
230 | unsigned32 data0; |
---|
231 | void data1; |
---|
232 | void file_info; |
---|
233 | rtems_filesystem_file_handlers_r handlers; |
---|
234 | }; |
---|
235 | |
---|
236 | A file control block can exist for regular files, devices and directories. |
---|
237 | The following fields are important for regular file and directory access: |
---|
238 | |
---|
239 | - Size - For a file this represents the number of bytes currently stored in a |
---|
240 | file. For a directory this field is not filled in. |
---|
241 | |
---|
242 | - Offset - For a file this is the byte file position index relative to the |
---|
243 | start of the file. For a directory this is the byte offset into a sequence |
---|
244 | of dirent structures. |
---|
245 | |
---|
246 | - Pathinfo - This is a structure that provides a pointer to node information, |
---|
247 | OPS table functions, Handler functions and the mount table entry associated |
---|
248 | with this node. |
---|
249 | |
---|
250 | - file_info - A pointer to node information that is used by Handler functions |
---|
251 | |
---|
252 | - handlers - A pointer to a table of handler functions that operate on a |
---|
253 | file, device or directory through a file descriptor index |
---|
254 | |
---|
255 | File/Directory function access via rtems_filesystem_location_info_t structure |
---|
256 | ----------------------------------------------------------------------------- |
---|
257 | |
---|
258 | The ``rtems_filesystem_location_info_tt`` structure below provides sufficient |
---|
259 | information to process nodes under a mounted filesystem. |
---|
260 | |
---|
261 | .. code-block:: c |
---|
262 | |
---|
263 | struct rtems_filesystem_location_info_tt { |
---|
264 | void *node_access; |
---|
265 | rtems_filesystem_file_handlers_r *handlers; |
---|
266 | rtems_filesystem_operations_table *ops; |
---|
267 | rtems_filesystem_mount_table_entry_t *mt_entry; |
---|
268 | }; |
---|
269 | |
---|
270 | It contains a void pointer to filesystem specific nodal structure, pointers to |
---|
271 | the OPS table for the filesystem that contains the node, the node type specific |
---|
272 | handlers for the node and a reference pointer to the mount table entry |
---|
273 | associated with the filesystem containing the node |
---|
274 | |
---|
275 | Operation Tables |
---|
276 | ================ |
---|
277 | |
---|
278 | Filesystem specific operations are invoked indirectly. The set of routines |
---|
279 | that implement the filesystem are configured into two tables. The Filesystem |
---|
280 | Handler Table has routines that are specific to a filesystem but remain |
---|
281 | constant regardless of the actual file type. The File Handler Table has |
---|
282 | routines that are both filesystem and file type specific. |
---|
283 | |
---|
284 | Filesystem Handler Table Functions |
---|
285 | ---------------------------------- |
---|
286 | |
---|
287 | OPS table functions are defined in a ``rtems_filesystem_operations_table`` |
---|
288 | structure. It defines functions that are specific to a given filesystem. One |
---|
289 | table exists for each filesystem that is supported in the RTEMS |
---|
290 | configuration. The structure definition appears below and is followed by |
---|
291 | general developmental information on each of the functions contained in this |
---|
292 | function management structure. |
---|
293 | |
---|
294 | .. code-block:: c |
---|
295 | |
---|
296 | typedef struct { |
---|
297 | rtems_filesystem_evalpath_t evalpath; |
---|
298 | rtems_filesystem_evalmake_t evalformake; |
---|
299 | rtems_filesystem_link_t link; |
---|
300 | rtems_filesystem_unlink_t unlink; |
---|
301 | rtems_filesystem_node_type_t node_type; |
---|
302 | rtems_filesystem_mknod_t mknod; |
---|
303 | rtems_filesystem_rmnod_t rmnod; |
---|
304 | rtems_filesystem_chown_t chown; |
---|
305 | rtems_filesystem_freenode_t freenod; |
---|
306 | rtems_filesystem_mount_t mount; |
---|
307 | rtems_filesystem_fsmount_me_t fsmount_me; |
---|
308 | rtems_filesystem_unmount_t unmount; |
---|
309 | rtems_filesystem_fsunmount_me_t fsunmount_me; |
---|
310 | rtems_filesystem_utime_t utime; |
---|
311 | rtems_filesystem_evaluate_link_t eval_link; |
---|
312 | rtems_filesystem_symlink_t symlink; |
---|
313 | } rtems_filesystem_operations_table; |
---|
314 | |
---|
315 | evalpath Handler |
---|
316 | ^^^^^^^^^^^^^^^^ |
---|
317 | |
---|
318 | Corresponding Structure Element: |
---|
319 | ``evalpath`` |
---|
320 | |
---|
321 | Arguments: |
---|
322 | .. code-block:: c |
---|
323 | |
---|
324 | const char *pathname, /* IN */ |
---|
325 | int flags, /* IN */ |
---|
326 | rtems_filesystem_location_info_t *pathloc /* IN/OUT */ |
---|
327 | |
---|
328 | Description: |
---|
329 | This routine is responsible for evaluating the pathname passed in based |
---|
330 | upon the flags and the valid ``rthems_filesystem_location_info_t``. |
---|
331 | Additionally, it must make any changes to pathloc necessary to identify the |
---|
332 | pathname node. This should include calling the evalpath for a mounted |
---|
333 | filesystem, if the given filesystem supports the mount command. |
---|
334 | |
---|
335 | This routine returns a 0 if the evaluation was successful. Otherwise, it |
---|
336 | returns a -1 and sets errno to the correct error. |
---|
337 | |
---|
338 | This routine is required and should NOT be set to NULL. |
---|
339 | |
---|
340 | evalformake Handler |
---|
341 | ^^^^^^^^^^^^^^^^^^^ |
---|
342 | |
---|
343 | Corresponding Structure Element: |
---|
344 | ``evalformake`` |
---|
345 | |
---|
346 | Arguments: |
---|
347 | .. code-block:: c |
---|
348 | |
---|
349 | const char *path, /* IN */ |
---|
350 | rtems_filesystem_location_info_t *pathloc, /* IN/OUT */ |
---|
351 | const char **name /* OUT */ |
---|
352 | |
---|
353 | Description: |
---|
354 | This method is given a path to evaluate and a valid start location. It is |
---|
355 | responsible for finding the parent node for a requested make command, |
---|
356 | setting pathloc information to identify the parent node, and setting the |
---|
357 | name pointer to the first character of the name of the new node. |
---|
358 | Additionally, if the filesystem supports the mount command, this method |
---|
359 | should call the evalformake routine for the mounted filesystem. |
---|
360 | |
---|
361 | This routine returns a 0 if the evaluation was successful. Otherwise, it |
---|
362 | returns a -1 and sets errno to the correct error. |
---|
363 | |
---|
364 | This routine is required and should NOT be set to NULL. However, if the |
---|
365 | filesystem does not support user creation of a new node, it may set errno |
---|
366 | to ENOSYS and return -1. |
---|
367 | |
---|
368 | link Handler |
---|
369 | ^^^^^^^^^^^^ |
---|
370 | |
---|
371 | Corresponding Structure Element: |
---|
372 | ``link`` |
---|
373 | |
---|
374 | Arguments: |
---|
375 | .. code-block:: c |
---|
376 | |
---|
377 | rtems_filesystem_location_info_t *to_loc, /* IN */ |
---|
378 | rtems_filesystem_location_info_t *parent_loc, /* IN */ |
---|
379 | const char *token /* IN */ |
---|
380 | |
---|
381 | Description: |
---|
382 | This routine is used to create a hard-link. |
---|
383 | |
---|
384 | It will first examine the st_nlink count of the node that we are trying to. |
---|
385 | If the link count exceeds LINK_MAX an error will be returned. |
---|
386 | |
---|
387 | The name of the link will be normalized to remove extraneous separators |
---|
388 | from the end of the name. |
---|
389 | |
---|
390 | This routine is not required and may be set to NULL. |
---|
391 | |
---|
392 | unlink Handler |
---|
393 | ^^^^^^^^^^^^^^ |
---|
394 | |
---|
395 | Corresponding Structure Element: |
---|
396 | ``unlink`` |
---|
397 | |
---|
398 | Arguments: |
---|
399 | XXX |
---|
400 | |
---|
401 | Description: |
---|
402 | XXX |
---|
403 | |
---|
404 | node_type Handler |
---|
405 | ^^^^^^^^^^^^^^^^^ |
---|
406 | |
---|
407 | Corresponding Structure Element: |
---|
408 | ``node_type()`` |
---|
409 | |
---|
410 | Arguments: |
---|
411 | .. code-block:: c |
---|
412 | |
---|
413 | rtems_filesystem_location_info_t *pathloc /* IN */ |
---|
414 | |
---|
415 | Description: |
---|
416 | XXX |
---|
417 | |
---|
418 | mknod Handler |
---|
419 | ^^^^^^^^^^^^^ |
---|
420 | |
---|
421 | Corresponding Structure Element: |
---|
422 | ``mknod()`` |
---|
423 | |
---|
424 | Arguments: |
---|
425 | .. code-block:: c |
---|
426 | |
---|
427 | const char *token, /* IN */ |
---|
428 | mode_t mode, /* IN */ |
---|
429 | dev_t dev, /* IN */ |
---|
430 | rtems_filesystem_location_info_t *pathloc /* IN/OUT */ |
---|
431 | |
---|
432 | Description: |
---|
433 | XXX |
---|
434 | |
---|
435 | rmnod Handler |
---|
436 | ^^^^^^^^^^^^^ |
---|
437 | |
---|
438 | Corresponding Structure Element: |
---|
439 | ``rmnod()`` |
---|
440 | |
---|
441 | Arguments: |
---|
442 | XXX |
---|
443 | |
---|
444 | Description: |
---|
445 | XXX |
---|
446 | |
---|
447 | chown Handler |
---|
448 | ^^^^^^^^^^^^^ |
---|
449 | |
---|
450 | Corresponding Structure Element: |
---|
451 | ``chown()`` |
---|
452 | |
---|
453 | Arguments: |
---|
454 | .. code-block:: c |
---|
455 | |
---|
456 | rtems_filesystem_location_info_t *pathloc /* IN */ |
---|
457 | uid_t owner /* IN */ |
---|
458 | gid_t group /* IN */ |
---|
459 | |
---|
460 | Description: |
---|
461 | XXX |
---|
462 | |
---|
463 | freenod Handler |
---|
464 | ^^^^^^^^^^^^^^^ |
---|
465 | |
---|
466 | Corresponding Structure Element: |
---|
467 | ``freenod()`` |
---|
468 | |
---|
469 | Arguments: |
---|
470 | .. code-block:: c |
---|
471 | |
---|
472 | rtems_filesystem_location_info_t *pathloc /* IN */ |
---|
473 | |
---|
474 | Description: |
---|
475 | This routine is used by the generic code to allow memory to be allocated |
---|
476 | during the evaluate routines, and set free when the generic code is |
---|
477 | finished accessing a node. If the evaluate routines allocate memory to |
---|
478 | identify a node this routine should be utilized to free that memory. |
---|
479 | |
---|
480 | This routine is not required and may be set to NULL. |
---|
481 | |
---|
482 | mount Handler |
---|
483 | ^^^^^^^^^^^^^ |
---|
484 | |
---|
485 | Corresponding Structure Element: |
---|
486 | ``mount()`` |
---|
487 | |
---|
488 | Arguments: |
---|
489 | .. code-block:: c |
---|
490 | |
---|
491 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
492 | |
---|
493 | Description: |
---|
494 | XXX |
---|
495 | |
---|
496 | fsmount_me Handler |
---|
497 | ^^^^^^^^^^^^^^^^^^ |
---|
498 | |
---|
499 | Corresponding Structure Element: |
---|
500 | ``imfs_fsmount_me`` |
---|
501 | |
---|
502 | Arguments: |
---|
503 | .. code-block:: c |
---|
504 | |
---|
505 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
506 | |
---|
507 | Description: |
---|
508 | This function is provided with a filesystem to take care of the internal |
---|
509 | filesystem management details associated with mounting that filesystem |
---|
510 | under the RTEMS environment. |
---|
511 | |
---|
512 | It is not responsible for the mounting details associated the filesystem |
---|
513 | containing the mount point. |
---|
514 | |
---|
515 | The rtems_filesystem_mount_table_entry_t structure contains the key |
---|
516 | elements below: |
---|
517 | |
---|
518 | .. code-block:: c |
---|
519 | |
---|
520 | rtems_filesystem_location_info_t *mt_point_node, |
---|
521 | |
---|
522 | This structure contains information about the mount point. This allows us |
---|
523 | to find the ops-table and the handling functions associated with the |
---|
524 | filesystem containing the mount point. |
---|
525 | |
---|
526 | .. code-block:: c |
---|
527 | |
---|
528 | rtems_filesystem_location_info_t *fs_root_node, |
---|
529 | |
---|
530 | This structure contains information about the root node in the file system |
---|
531 | to be mounted. It allows us to find the ops-table and the handling |
---|
532 | functions associated with the filesystem to be mounted. |
---|
533 | |
---|
534 | .. code-block:: c |
---|
535 | |
---|
536 | rtems_filesystem_options_t options, |
---|
537 | |
---|
538 | Read only or read/write access |
---|
539 | |
---|
540 | .. code-block:: c |
---|
541 | |
---|
542 | void *fs_info, |
---|
543 | |
---|
544 | This points to an allocated block of memory the will be used to hold any |
---|
545 | filesystem specific information of a global nature. This allocated region |
---|
546 | if important because it allows us to mount the same filesystem type more |
---|
547 | than once under the RTEMS system. Each instance of the mounted filesystem |
---|
548 | has its own set of global management information that is separate from the |
---|
549 | global management information associated with the other instances of the |
---|
550 | mounted filesystem type. |
---|
551 | |
---|
552 | .. code-block:: c |
---|
553 | |
---|
554 | rtems_filesystem_limits_and_options_t pathconf_info, |
---|
555 | |
---|
556 | The table contains the following set of values associated with the mounted |
---|
557 | filesystem: |
---|
558 | |
---|
559 | - link_max |
---|
560 | |
---|
561 | - max_canon |
---|
562 | |
---|
563 | - max_input |
---|
564 | |
---|
565 | - name_max |
---|
566 | |
---|
567 | - path_max |
---|
568 | |
---|
569 | - pipe_buf |
---|
570 | |
---|
571 | - posix_async_io |
---|
572 | |
---|
573 | - posix_chown_restrictions |
---|
574 | |
---|
575 | - posix_no_trunc |
---|
576 | |
---|
577 | - posix_prio_io |
---|
578 | |
---|
579 | - posix_sync_io |
---|
580 | |
---|
581 | - posix_vdisable |
---|
582 | |
---|
583 | These values are accessed with the pathconf() and the fpathconf () functions. |
---|
584 | |
---|
585 | .. code-block:: c |
---|
586 | |
---|
587 | const char *dev |
---|
588 | |
---|
589 | The is intended to contain a string that identifies the device that |
---|
590 | contains the filesystem information. The filesystems that are currently |
---|
591 | implemented are memory based and don't require a device specification. |
---|
592 | |
---|
593 | If the mt_point_node.node_access is NULL then we are mounting the base file |
---|
594 | system. |
---|
595 | |
---|
596 | The routine will create a directory node for the root of the IMFS file |
---|
597 | system. |
---|
598 | |
---|
599 | The node will have read, write and execute permissions for owner, group and |
---|
600 | others. |
---|
601 | |
---|
602 | The node's name will be a null string. |
---|
603 | |
---|
604 | A filesystem information structure(fs_info) will be allocated and |
---|
605 | initialized for the IMFS filesystem. The fs_info pointer in the mount table |
---|
606 | entry will be set to point the filesystem information structure. |
---|
607 | |
---|
608 | The pathconf_info element of the mount table will be set to the appropriate |
---|
609 | table of path configuration constants (LIMITS_AND_OPTIONS). |
---|
610 | |
---|
611 | The fs_root_node structure will be filled in with the following: |
---|
612 | |
---|
613 | - pointer to the allocated root node of the filesystem |
---|
614 | |
---|
615 | - directory handlers for a directory node under the IMFS filesystem |
---|
616 | |
---|
617 | - OPS table functions for the IMFS |
---|
618 | |
---|
619 | A 0 will be returned to the calling routine if the process succeeded, |
---|
620 | otherwise a 1 will be returned. |
---|
621 | |
---|
622 | unmount Handler |
---|
623 | ^^^^^^^^^^^^^^^ |
---|
624 | |
---|
625 | Corresponding Structure Element: |
---|
626 | XXX |
---|
627 | |
---|
628 | Arguments: |
---|
629 | XXX |
---|
630 | |
---|
631 | Description: |
---|
632 | XXX |
---|
633 | |
---|
634 | fsunmount_me Handler |
---|
635 | ^^^^^^^^^^^^^^^^^^^^ |
---|
636 | |
---|
637 | Corresponding Structure Element: |
---|
638 | ``imfs_fsunmount_me()`` |
---|
639 | |
---|
640 | Arguments: |
---|
641 | .. code-block:: c |
---|
642 | |
---|
643 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
644 | |
---|
645 | Description: |
---|
646 | XXX |
---|
647 | |
---|
648 | utime Handler |
---|
649 | ^^^^^^^^^^^^^ |
---|
650 | |
---|
651 | Corresponding Structure Element: |
---|
652 | XXX |
---|
653 | |
---|
654 | Arguments: |
---|
655 | XXX |
---|
656 | |
---|
657 | Description: |
---|
658 | XXX |
---|
659 | |
---|
660 | eval_link Handler |
---|
661 | ^^^^^^^^^^^^^^^^^ |
---|
662 | |
---|
663 | Corresponding Structure Element: |
---|
664 | XXX |
---|
665 | |
---|
666 | Arguments: |
---|
667 | XXX |
---|
668 | |
---|
669 | Description: |
---|
670 | XXX |
---|
671 | |
---|
672 | symlink Handler |
---|
673 | ^^^^^^^^^^^^^^^ |
---|
674 | |
---|
675 | Corresponding Structure Element: |
---|
676 | XXX |
---|
677 | |
---|
678 | Arguments: |
---|
679 | XXX |
---|
680 | |
---|
681 | Description: |
---|
682 | XXX |
---|
683 | |
---|
684 | File Handler Table Functions |
---|
685 | ---------------------------- |
---|
686 | |
---|
687 | Handler table functions are defined in a ``rtems_filesystem_file_handlers_r`` |
---|
688 | structure. It defines functions that are specific to a node type in a given |
---|
689 | filesystem. One table exists for each of the filesystem's node types. The |
---|
690 | structure definition appears below. It is followed by general developmental |
---|
691 | information on each of the functions associated with regular files contained in |
---|
692 | this function management structure. |
---|
693 | |
---|
694 | .. code-block:: c |
---|
695 | |
---|
696 | typedef struct { |
---|
697 | rtems_filesystem_open_t open; |
---|
698 | rtems_filesystem_close_t close; |
---|
699 | rtems_filesystem_read_t read; |
---|
700 | rtems_filesystem_write_t write; |
---|
701 | rtems_filesystem_ioctl_t ioctl; |
---|
702 | rtems_filesystem_lseek_t lseek; |
---|
703 | rtems_filesystem_fstat_t fstat; |
---|
704 | rtems_filesystem_fchmod_t fchmod; |
---|
705 | rtems_filesystem_ftruncate_t ftruncate; |
---|
706 | rtems_filesystem_fpathconf_t fpathconf; |
---|
707 | rtems_filesystem_fsync_t fsync; |
---|
708 | rtems_filesystem_fdatasync_t fdatasync; |
---|
709 | rtems_filesystem_fcntl_t fcntl; |
---|
710 | } rtems_filesystem_file_handlers_r; |
---|
711 | |
---|
712 | open Handler |
---|
713 | ^^^^^^^^^^^^ |
---|
714 | |
---|
715 | Corresponding Structure Element: |
---|
716 | ``open()`` |
---|
717 | |
---|
718 | Arguments: |
---|
719 | .. code-block:: c |
---|
720 | |
---|
721 | rtems_libio_t *iop, |
---|
722 | const char *pathname, |
---|
723 | unsigned32 flag, |
---|
724 | unsigned32 mode |
---|
725 | |
---|
726 | Description: |
---|
727 | XXX |
---|
728 | |
---|
729 | close Handler |
---|
730 | ~~~~~~~~~~~~~ |
---|
731 | |
---|
732 | Corresponding Structure Element: |
---|
733 | ``close()`` |
---|
734 | |
---|
735 | Arguments: |
---|
736 | .. code-block:: c |
---|
737 | |
---|
738 | rtems_libio_t *iop |
---|
739 | |
---|
740 | Description: |
---|
741 | XXX |
---|
742 | |
---|
743 | NOTES: |
---|
744 | XXX |
---|
745 | |
---|
746 | read Handler |
---|
747 | ~~~~~~~~~~~~ |
---|
748 | |
---|
749 | Corresponding Structure Element: |
---|
750 | ``read()`` |
---|
751 | |
---|
752 | Arguments: |
---|
753 | .. code-block:: c |
---|
754 | |
---|
755 | rtems_libio_t *iop, |
---|
756 | void *buffer, |
---|
757 | unsigned32 count |
---|
758 | |
---|
759 | Description: |
---|
760 | XXX |
---|
761 | |
---|
762 | NOTES: |
---|
763 | XXX |
---|
764 | |
---|
765 | write Handler |
---|
766 | ~~~~~~~~~~~~~ |
---|
767 | |
---|
768 | Corresponding Structure Element: |
---|
769 | XXX |
---|
770 | |
---|
771 | Arguments: |
---|
772 | XXX |
---|
773 | |
---|
774 | Description: |
---|
775 | XXX |
---|
776 | |
---|
777 | NOTES: |
---|
778 | XXX |
---|
779 | |
---|
780 | ioctl Handler |
---|
781 | ~~~~~~~~~~~~~ |
---|
782 | |
---|
783 | Corresponding Structure Element: |
---|
784 | XXX |
---|
785 | |
---|
786 | Arguments: |
---|
787 | .. code-block:: c |
---|
788 | |
---|
789 | rtems_libio_t *iop, |
---|
790 | unsigned32 command, |
---|
791 | void *buffer |
---|
792 | |
---|
793 | Description: |
---|
794 | XXX |
---|
795 | |
---|
796 | NOTES: |
---|
797 | XXX |
---|
798 | |
---|
799 | lseek Handler |
---|
800 | ~~~~~~~~~~~~~ |
---|
801 | |
---|
802 | Corresponding Structure Element: |
---|
803 | ``lseek()`` |
---|
804 | |
---|
805 | Arguments: |
---|
806 | .. code-block:: c |
---|
807 | |
---|
808 | rtems_libio_t *iop, |
---|
809 | off_t offset, |
---|
810 | int whence |
---|
811 | |
---|
812 | Description: |
---|
813 | XXX |
---|
814 | |
---|
815 | NOTES: |
---|
816 | XXX |
---|
817 | |
---|
818 | fstat Handler |
---|
819 | ~~~~~~~~~~~~~ |
---|
820 | |
---|
821 | Corresponding Structure Element: |
---|
822 | ``fstat()`` |
---|
823 | |
---|
824 | Arguments: |
---|
825 | .. code-block:: c |
---|
826 | |
---|
827 | rtems_filesystem_location_info_t *loc, |
---|
828 | struct stat *buf |
---|
829 | |
---|
830 | Description: |
---|
831 | The following information is extracted from the filesystem specific node |
---|
832 | and placed in the ``stat`` structure: |
---|
833 | |
---|
834 | - st_mode |
---|
835 | |
---|
836 | - st_nlink |
---|
837 | |
---|
838 | - st_ino |
---|
839 | |
---|
840 | - st_uid |
---|
841 | |
---|
842 | - st_gid |
---|
843 | |
---|
844 | - st_atime |
---|
845 | |
---|
846 | - st_mtime |
---|
847 | |
---|
848 | - st_ctime |
---|
849 | |
---|
850 | NOTES: |
---|
851 | Both the ``stat()`` and ``lstat()`` services are implemented directly using |
---|
852 | the ``fstat()`` handler. The difference in behavior is determined by how |
---|
853 | the path is evaluated prior to this handler being called on a particular |
---|
854 | file entity. |
---|
855 | |
---|
856 | The ``fstat()`` system call is implemented directly on top of this |
---|
857 | filesystem handler. |
---|
858 | |
---|
859 | fchmod Handler |
---|
860 | ~~~~~~~~~~~~~~ |
---|
861 | |
---|
862 | Corresponding Structure Element: |
---|
863 | ``fchmod()`` |
---|
864 | |
---|
865 | Arguments: |
---|
866 | .. code-block:: c |
---|
867 | |
---|
868 | rtems_libio_t *iop |
---|
869 | mode_t mode |
---|
870 | |
---|
871 | Description: |
---|
872 | XXX |
---|
873 | |
---|
874 | NOTES: |
---|
875 | XXX |
---|
876 | |
---|
877 | ftruncate Handler |
---|
878 | ~~~~~~~~~~~~~~~~~ |
---|
879 | |
---|
880 | Corresponding Structure Element: |
---|
881 | XXX |
---|
882 | |
---|
883 | Arguments: |
---|
884 | XXX |
---|
885 | |
---|
886 | Description: |
---|
887 | XXX |
---|
888 | |
---|
889 | NOTES: |
---|
890 | XXX |
---|
891 | |
---|
892 | fpathconf Handler |
---|
893 | ~~~~~~~~~~~~~~~~~ |
---|
894 | |
---|
895 | Corresponding Structure Element: |
---|
896 | XXX |
---|
897 | |
---|
898 | Arguments: |
---|
899 | XXX |
---|
900 | |
---|
901 | Description: |
---|
902 | XXX |
---|
903 | |
---|
904 | NOTES: |
---|
905 | XXX |
---|
906 | |
---|
907 | fsync Handler |
---|
908 | ~~~~~~~~~~~~~ |
---|
909 | |
---|
910 | Corresponding Structure Element: |
---|
911 | XXX |
---|
912 | |
---|
913 | Arguments: |
---|
914 | XXX |
---|
915 | |
---|
916 | Description: |
---|
917 | XXX |
---|
918 | |
---|
919 | NOTES: |
---|
920 | XXX |
---|
921 | |
---|
922 | fdatasync Handler |
---|
923 | ~~~~~~~~~~~~~~~~~ |
---|
924 | |
---|
925 | Corresponding Structure Element: |
---|
926 | XXX |
---|
927 | |
---|
928 | Arguments: |
---|
929 | XXX |
---|
930 | |
---|
931 | Description: |
---|
932 | XXX |
---|
933 | |
---|
934 | NOTES: |
---|
935 | XXX |
---|
936 | |
---|
937 | fcntl Handler |
---|
938 | ~~~~~~~~~~~~~ |
---|
939 | |
---|
940 | Corresponding Structure Element: |
---|
941 | XXX |
---|
942 | |
---|
943 | Arguments: |
---|
944 | XXX |
---|
945 | |
---|
946 | Description: |
---|
947 | XXX |
---|
948 | |
---|
949 | NOTES: |
---|
950 | XXX |
---|