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