1 | .. SPDX-License-Identifier: CC-BY-SA-4.0 |
---|
2 | |
---|
3 | .. Copyright (C) 1988, 2002 On-Line Applications Research Corporation (OAR) |
---|
4 | |
---|
5 | Pathname Evaluation |
---|
6 | ******************* |
---|
7 | |
---|
8 | This chapter describes the pathname evaluation process for the RTEMS Filesystem |
---|
9 | Infrastructure. |
---|
10 | |
---|
11 | .. code-block:: shell |
---|
12 | |
---|
13 | XXX Include graphic of the path evaluation process |
---|
14 | |
---|
15 | Pathname Evaluation Handlers |
---|
16 | ============================ |
---|
17 | |
---|
18 | There are two pathname evaluation routines. The handler patheval() is called |
---|
19 | to find, verify privlages on and return information on a node that exists. The |
---|
20 | handler ``evalformake()`` is called to find, verify permissions, and return |
---|
21 | information on a node that is to become a parent. Additionally, evalformake() |
---|
22 | returns a pointer to the start of the name of the new node to be created. |
---|
23 | |
---|
24 | Pathname evaluation is specific to a filesystem. Each filesystem is required |
---|
25 | to provide both a ``patheval()`` and an ``evalformake()`` routine. Both of |
---|
26 | these routines gets a name to evaluate and a node indicating where to start the |
---|
27 | evaluation. |
---|
28 | |
---|
29 | Crossing a Mount Point During Path Evaluation |
---|
30 | ============================================= |
---|
31 | |
---|
32 | If the filesystem supports the mount command, the evaluate routines must handle |
---|
33 | crossing the mountpoint. The evaluate routine should evaluate the name upto |
---|
34 | the first directory node where the new filesystem is mounted. The filesystem |
---|
35 | may process terminator characters prior to calling the evaluate routine for the |
---|
36 | new filesystem. A pointer to the portion of the name which has not been |
---|
37 | evaluated along with the root node of the new file system (gotten from the |
---|
38 | mount table entry) is passed to the correct mounted filesystem evaluate |
---|
39 | routine. |
---|
40 | |
---|
41 | The rtems_filesystem_location_info_t Structure |
---|
42 | ============================================== |
---|
43 | |
---|
44 | The ``rtems_filesystem_location_info_t`` structure contains all information |
---|
45 | necessary for identification of a node. |
---|
46 | |
---|
47 | The generic rtems filesystem code defines two global |
---|
48 | rtems_filesystem_location_info_t structures, the``rtems_filesystem_root`` and |
---|
49 | the ``rtems_filesystem_current``. Both are initially defined to be the root |
---|
50 | node of the base filesystem. Once the chdir command is correctly used the |
---|
51 | ``rtems_filesystem_current`` is set to the location specified by the command. |
---|
52 | |
---|
53 | The filesystem generic code peeks at the first character in the name to be |
---|
54 | evaluated. If this character is a valid seperator, |
---|
55 | the``rtems_filesystem_root`` is used as the node to start the evaluation with. |
---|
56 | Otherwise, the ``rtems_filesystem_current`` node is used as the node to start |
---|
57 | evaluating with. Therefore, a valid rtems_filesystem_location_info_t is given |
---|
58 | to the evaluate routine to start evaluation with. The evaluate routines are |
---|
59 | then responsible for making any changes necessary to this structure to |
---|
60 | correspond to the name being parsed. |
---|
61 | |
---|
62 | .. code-block:: c |
---|
63 | |
---|
64 | struct rtems_filesystem_location_info_tt { |
---|
65 | void *node_access; |
---|
66 | rtems_filesystem_file_handlers_r *handlers; |
---|
67 | rtems_filesystem_operations_table *ops; |
---|
68 | rtems_filesystem_mount_table_entry_t *mt_entry; |
---|
69 | }; |
---|
70 | |
---|
71 | *node_access* |
---|
72 | This element is filesystem specific. A filesystem can define and store any |
---|
73 | information necessary to identify a node at this location. This element is |
---|
74 | normally filled in by the filesystem's evaluate routine. For the |
---|
75 | filesystem's root node, the filesystem's initilization routine should fill |
---|
76 | this in, and it should remain valid until the instance of the filesystem is |
---|
77 | unmounted. |
---|
78 | |
---|
79 | *handlers* |
---|
80 | This element is defined as a set of routines that may change within a given |
---|
81 | filesystem based upon node type. For example a directory and a memory file |
---|
82 | may have to completely different read routines. This element is set to an |
---|
83 | initialization state defined by the mount table, and may be set to the |
---|
84 | desired state by the evaluation routines. |
---|
85 | |
---|
86 | *ops* |
---|
87 | This element is defined as a set of routines that remain static for the |
---|
88 | filesystem. This element identifies entry points into the filesystem to |
---|
89 | the generic code. |
---|
90 | |
---|
91 | *mt_entry* |
---|
92 | This element identifies the mount table entry for this instance of the |
---|
93 | filesystem. |
---|