paul@183 | 1 | = Components = |
paul@142 | 2 | |
paul@142 | 3 | Access to files is provided by a number of programs acting as components. For |
paul@183 | 4 | convenience, the component-level operations are wrapped up in a |
paul@183 | 5 | [[ClientLibrary|client library]] that aims to provide simpler, more familiar |
paul@183 | 6 | mechanisms for opening, reading, writing, and closing files, together with |
paul@183 | 7 | various other operations. |
paul@142 | 8 | |
paul@142 | 9 | <<TableOfContents(2,3)>> |
paul@142 | 10 | |
paul@183 | 11 | Components are accessed via interfaces defined using the interface description |
paul@183 | 12 | language supported by the ``idl4re`` tool. Interface operations in this |
paul@183 | 13 | document are described using excerpts from the appropriate interface |
paul@183 | 14 | descriptions. |
paul@183 | 15 | |
paul@183 | 16 | ######## A graph showing the interactions between components |
paul@183 | 17 | |
paul@183 | 18 | {{{#!graphviz |
paul@183 | 19 | #format svg |
paul@183 | 20 | #transform notugly |
paul@183 | 21 | digraph components { |
paul@183 | 22 | node [fontsize="12.0",fontname="sans-serif",shape=box]; |
paul@183 | 23 | edge [fontsize="12.0",fontname="sans-serif"]; |
paul@183 | 24 | rankdir=LR; |
paul@183 | 25 | |
paul@183 | 26 | subgraph { |
paul@183 | 27 | node [label="Client",style=solid,color="#000000",fontcolor="#000000"]; |
paul@183 | 28 | rank=min; |
paul@183 | 29 | |
paul@183 | 30 | Client1; Client3; Client5; |
paul@183 | 31 | |
paul@183 | 32 | subgraph { |
paul@183 | 33 | node [label="Client",color="#999999",fontcolor="#999999"]; |
paul@183 | 34 | Client2; Client4; Client6; |
paul@183 | 35 | } |
paul@183 | 36 | } |
paul@183 | 37 | |
paul@183 | 38 | subgraph { |
paul@183 | 39 | rank=same; |
paul@183 | 40 | Filesystem; |
paul@142 | 41 | |
paul@183 | 42 | subgraph { |
paul@183 | 43 | node [label="Opener\n(user)"]; |
paul@183 | 44 | Opener1; Opener2; |
paul@183 | 45 | } |
paul@183 | 46 | |
paul@183 | 47 | subgraph { |
paul@183 | 48 | node [label="OpenerContext"]; |
paul@183 | 49 | OpenerContext1; OpenerContext2; |
paul@183 | 50 | } |
paul@183 | 51 | |
paul@183 | 52 | MappedFile; |
paul@183 | 53 | } |
paul@183 | 54 | |
paul@183 | 55 | Client1 -> Client2 -> Client3 -> Client4 -> Client5 -> Client6 [arrowhead=none,style=invisible]; |
paul@183 | 56 | Opener1 -> Opener2 [arrowhead=none,style=invisible]; |
paul@183 | 57 | OpenerContext1 -> OpenerContext2 [arrowhead=none,style=invisible]; |
paul@142 | 58 | |
paul@183 | 59 | Client1 -> Filesystem [label="open_for_user(user)"]; |
paul@183 | 60 | Filesystem -> Opener1; |
paul@183 | 61 | Opener1 -> Client2 [style=dashed]; |
paul@183 | 62 | |
paul@183 | 63 | Client3 -> Opener2 [label="context()"]; |
paul@183 | 64 | Opener2 -> OpenerContext1; |
paul@183 | 65 | OpenerContext1 -> Client4 [style=dashed]; |
paul@183 | 66 | |
paul@183 | 67 | Client5 -> OpenerContext2 [label="open(flags, ...)"]; |
paul@183 | 68 | OpenerContext2 -> MappedFile; |
paul@183 | 69 | MappedFile -> Client6 [style=dashed]; |
paul@183 | 70 | } |
paul@183 | 71 | }}} |
paul@183 | 72 | |
paul@183 | 73 | ######## |
paul@183 | 74 | |
paul@183 | 75 | == Filesystems == |
paul@142 | 76 | |
paul@144 | 77 | Filesystems implement the `Filesystem` interface which provides the |
paul@144 | 78 | `open_for_user` operation: |
paul@144 | 79 | |
paul@144 | 80 | {{{ |
paul@172 | 81 | open_for_user(in user_t user, out cap opener) |
paul@144 | 82 | }}} |
paul@144 | 83 | |
paul@183 | 84 | The operation yields a file opener appropriate for the given [[Users|user]] |
paul@183 | 85 | credentials. |
paul@144 | 86 | |
paul@183 | 87 | == File Openers == |
paul@144 | 88 | |
paul@144 | 89 | File openers implement the `Opener` interface which provides the `context` |
paul@142 | 90 | operation: |
paul@142 | 91 | |
paul@142 | 92 | {{{ |
paul@142 | 93 | context(out cap context) |
paul@142 | 94 | }}} |
paul@142 | 95 | |
paul@142 | 96 | Each client program, task or thread obtains its own context because it will |
paul@142 | 97 | need its own dedicated channel for communication with the filesystem. |
paul@142 | 98 | |
paul@183 | 99 | == Opener Contexts == |
paul@142 | 100 | |
paul@183 | 101 | An opener context acts as a dataspace, meaning that it can be attached to a |
paul@183 | 102 | task using a region manager and provide a buffer via a region of mapped memory |
paul@183 | 103 | that the task can write to. In the case of a context, the task will write a |
paul@183 | 104 | filesystem path indicating the file to be opened. |
paul@142 | 105 | |
paul@142 | 106 | Each context allows a client program to request access to individual files via |
paul@142 | 107 | operations provided by the `OpenerContext` interface, of which the most |
paul@142 | 108 | pertinent is the `open` operation: |
paul@142 | 109 | |
paul@142 | 110 | {{{ |
paul@172 | 111 | open(in flags_t flags, out offset_t size, out cap file, |
paul@172 | 112 | out object_flags_t object_flags) |
paul@142 | 113 | }}} |
paul@142 | 114 | |
paul@142 | 115 | Using the path information written to the context's memory region, the `open` |
paul@172 | 116 | operation will obtain a reference to a file-like object whose characteristics |
paul@172 | 117 | are described by the accompanying `object_flags`, these helping the client to |
paul@172 | 118 | distinguish between files that support arbitrary memory mapping operations and |
paul@172 | 119 | pipes that mandate sequential region-by-region access. |
paul@172 | 120 | |
paul@172 | 121 | Alongside regular files, directories may also be opened. Reading from them |
paul@172 | 122 | yields a listing of directory entries. |
paul@142 | 123 | |
paul@183 | 124 | == Files == |
paul@142 | 125 | |
paul@142 | 126 | Files themselves act as dataspaces, meaning that they can be attached to a |
paul@142 | 127 | task using a region manager and provide their content via a region of mapped |
paul@142 | 128 | memory. Files implement the `MappedFile` interface. |
paul@142 | 129 | |
paul@142 | 130 | Control over the region of the file provided via mapped memory occurs |
paul@142 | 131 | using the `mmap` operation: |
paul@142 | 132 | |
paul@142 | 133 | {{{ |
paul@142 | 134 | mmap(in offset_t position, in offset_t length, |
paul@142 | 135 | out offset_t start_pos, out offset_t end_pos, |
paul@142 | 136 | out offset_t size) |
paul@142 | 137 | }}} |
paul@142 | 138 | |
paul@142 | 139 | Files also implement the more general `File` interface that provides the |
paul@142 | 140 | `resize` operation: |
paul@142 | 141 | |
paul@142 | 142 | {{{ |
paul@142 | 143 | resize(inout offset_t size) |
paul@142 | 144 | }}} |
paul@142 | 145 | |
paul@142 | 146 | This allows the portion of the memory region dedicated to the file's contents |
paul@142 | 147 | to be extended. |
paul@142 | 148 | |
paul@183 | 149 | == Directories == |
paul@172 | 150 | |
paul@172 | 151 | Directories are also meant to be accessed like files, meaning that it should |
paul@172 | 152 | be possible to attach them to a task using a region manager and access the |
paul@172 | 153 | provided content, this being a listing of directory entries, via the mapped |
paul@172 | 154 | region. |
paul@172 | 155 | |
paul@172 | 156 | However, unlike files which may support arbitrary mapping of their contents, |
paul@172 | 157 | the provided content may be supplied by a pipe endpoint, thereby not |
paul@172 | 158 | supporting precisely the same navigation mechanisms as those supported by |
paul@172 | 159 | files. |
paul@172 | 160 | |
paul@183 | 161 | '''Note''' that directories may well be redefined to support multiple |
paul@183 | 162 | operations, one of which supporting the file-like access described above. |
paul@183 | 163 | |
paul@183 | 164 | == Pipe Openers == |
paul@172 | 165 | |
paul@172 | 166 | Distinct from filesystems but potentially used by them, pipe openers provide a |
paul@172 | 167 | means of obtaining pipes, which are channels that support unidirectional |
paul@172 | 168 | communication via shared memory. |
paul@172 | 169 | |
paul@172 | 170 | Pipe openers implement the `PipeOpener` interface and support the following |
paul@172 | 171 | operation: |
paul@172 | 172 | |
paul@172 | 173 | {{{ |
paul@172 | 174 | pipe(in offset_t size, out cap reader, out cap writer) |
paul@172 | 175 | }}} |
paul@172 | 176 | |
paul@172 | 177 | The size is indicated to request pipe regions long enough for the needs of the |
paul@172 | 178 | communicating parties, with both reader and writer endpoint capabilities being |
paul@172 | 179 | returned. Such capabilities may be propagated to the eventual parties, these |
paul@172 | 180 | typically being separate tasks. |
paul@172 | 181 | |
paul@183 | 182 | == Pipes == |
paul@172 | 183 | |
paul@172 | 184 | Although not generally obtained from filesystems, pipes may be involved in |
paul@172 | 185 | providing content from some filesystem objects such as directories. However, |
paul@172 | 186 | they are also obtained directly from an appropriate pipe server providing pipe |
paul@172 | 187 | opening facilities. |
paul@172 | 188 | |
paul@172 | 189 | Pipes expose single regions of shared memory to their endpoints, with the |
paul@172 | 190 | writing endpoint populating one region while the reading endpoint accesses the |
paul@172 | 191 | other. The reading endpoint may advance to the region being written, and this |
paul@172 | 192 | will free up a new region for the writer when it has filled its region. When |
paul@172 | 193 | the writer itself advances, it permits the reader to consume all data in the |
paul@172 | 194 | fully populated region. Naturally, the reader may not advance ahead of the |
paul@172 | 195 | writer. |
paul@172 | 196 | |
paul@172 | 197 | Pipes implement the `Pipe` interface and a number of operations to support |
paul@172 | 198 | this interaction mechanism. |
paul@172 | 199 | |
paul@172 | 200 | The details of an endpoint's current region can be queried using the following |
paul@172 | 201 | operation: |
paul@172 | 202 | |
paul@172 | 203 | {{{ |
paul@172 | 204 | current_region(out offset_t populated_size, out offset_t size) |
paul@172 | 205 | }}} |
paul@172 | 206 | |
paul@172 | 207 | This provides details of the populated size (or amount of written data) in a |
paul@172 | 208 | region along with the size of the region. |
paul@172 | 209 | |
paul@172 | 210 | Navigation to the next available region of the pipe is performed using the |
paul@172 | 211 | following operation: |
paul@172 | 212 | |
paul@172 | 213 | {{{ |
paul@172 | 214 | next_region(inout offset_t populated_size, out offset_t size) |
paul@172 | 215 | }}} |
paul@172 | 216 | |
paul@172 | 217 | Here, the populated size may be specified by the writer so that the reader may |
paul@172 | 218 | query the current region's properties using the appropriate operation. |
paul@172 | 219 | |
paul@172 | 220 | The status of the pipe can be queried using the `closed` operation: |
paul@172 | 221 | |
paul@172 | 222 | {{{ |
paul@172 | 223 | closed(out int closed) |
paul@172 | 224 | }}} |
paul@172 | 225 | |
paul@172 | 226 | This indicates through a boolean-equivalent parameter whether one or both |
paul@172 | 227 | endpoints have been closed. |