The entry module_files
The module file service: it stores a module file that a web server gives in the store module_files of its principal, and lists the files of that store with the hash of their bytes. A developer then adds a module to a machine that runs, with no disk from the tool .
What it is for. The root service starts a disk process from the store module_files when the hash of its bytes is the hash that the principal names. This service puts a file in that store from the network, and gives the hash to type. It starts nothing: the root service checks the bytes at the start, so this service carries them as the storage service does, and does not choose what runs.
Start: connect("module_files") in the console starts it, as the storage service starts. Then:
module_files.receive("visitor", "/visitor") the hash of the file that came
module_files.list() the files, with their hashes
start_from_disk("visitor", "<the hash>")
Grants, as the root service gives them:
- Store: its private store. The root service names a private store by the name of its module, so the store of this module is the store
module_filesof its principal. - Network: a client grant of TCP to one web server, 10.0.2.100 port 80: the address that QEMU gives to a server of the host.
- Serve: the two exports for the console.
The root service also gives the number of its principal in its context (disk_process.SERVICE_VALUE_PRINCIPAL): a caller of another principal is refused.
What a reader sees. No window. The log has "module_files: serves the store module_files of principal 0, ...", one line for each file that it stores, and one line for each row of a list.
The design:.
See: Module contract: A module from a disk, Processes from a disk: How the file reaches the disk in the repository
module_files module with an entry
- Hash
05540016c61393480a24d5dfe15d185569841b9d61cacbacea0eeae597dbc562- Size
135168 bytes- Exports
2- Imports
0- Imported by
0- License
- MIT
The module file service: it stores a module file that a web server gives in the store module_files of its principal, and lists the files of that store with the hash of their bytes
| Fact | Value |
|---|---|
| Kind | Modules with an entry |
| Source | src/modules/system/module_files |
| Boot image | yes: in the boot image, 135168 bytes in this build |
| Build settings | none: the defaults of the source |
| Imports | none |
| Imported by | none |
Neighbours
It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.
Exports
| Export | What it does |
|---|---|
receive(nickname: Text, path: Text) -> Text | fetches a module file from the web server of the grant, and stores it in the store module_files under a nickname |
list() -> Table(Module_File_Row) | gives one row for each module file of the store module_files: its name, its bytes, and the BLAKE3 hash of its bytes |
entry() | The entry of module_files: it opens its service, its store and its endpoint, then serves the calls of the console and the timers of TCP until the machine stops |
receive
receive(nickname: , path: ) ->
receive fetches a module file from the web server of the grant, and stores it in the store module_files under a nickname.
The service sends GET path to the web server, takes a body of 1 to 4 MiB with a Content-Length, writes it as the object nickname of the root tree of the store module_files of its principal in one commit, then gives the 64 hexadecimal digits of the BLAKE3 hash of the bytes that came. The hash is the one to type in start_from_disk: the root service checks the bytes against it at the start, so a file with other bytes never runs under it. A file of the same nickname is replaced, and the store keeps the one before as a version.
- nickname: the name of the entry, 1 to 23 bytes, with no zero byte and no
/; notmodule_filesand notgrant_table. - path: the path of the request, 1 to 200 bytes that start with
/, with no space and no control byte. - result: the 64 hexadecimal digits of the hash.
The caller must act for the principal of the store (Acts_For_Principal). The call ends 30 seconds after it starts, the deadline of a load. The result is 64, or a negative number with an error record:
No_Grant(-1): the caller does not act for the principal of the store.Empty,Too_Long,Bad_ByteorReserved(-2): the nickname.Empty,Too_LongorBad_Byte(-3): the path; forBad_Byte, the record holds the place of the byte.No_Answer,FullorRefused(-4): the connection to the web server, or the deadline.Refused,Malformed,Too_LongorToo_Small(-5): the answer: a status that is not 200 (the record holds it), no Content-Length of 1 to 4 MiB, or a body that ends early.Refused(-6): the service has no store, or the storage service refused the file.
Example: module_files.receive("visitor", "/visitor").
nickname:path:
- When it fails
- a negative result, and the error record
src/modules/system/module_files/main.odin:407
list
list() -> ()
list gives one row for each module file of the store module_files: its name, its bytes, and the BLAKE3 hash of its bytes.
The service reads the bytes of each object again and computes the hash: the hash that the storage service keeps for an entry differs from the hash of the bytes when the object has a hole. The object grant_table, the disk grant table of the principal, is no module file and has no row; nor has the debug object of a module file, an object named by the 64 hexadecimal digits of the hash of its module. An object over 4 MiB, the limit of a module file, or whose bytes did not come, has a row with no hash. The log has one line for each row.
- result: a table of
Module_File_Rowrows; the call fills at most its length.
The caller must act for the principal of the store (Acts_For_Principal). The result is the count of the rows, or a negative number with an error record:
No_Grant(-1): the caller does not act for the principal of the store.Refused(-6): the service has no store, or the storage service refused the listing.
Example: module_files.list().
- none
()- When it fails
- a negative result, and the error record
src/modules/system/module_files/main.odin:520
entry
entry()
The entry of module_files: it opens its service, its store and its endpoint, then serves the calls of the console and the timers of TCP until the machine stops.
- 1. takes its random generator; with no seed it stops with
Failed; - 2. opens its service ring and its store, and makes the memory of one file; a missing part stops it with a line of the log;
- 3. asks the network service for its grant; a grant that is not a client grant of TCP stops it;
- 4. writes "module_files: serves the store module_files of principal N: ...".
- Form
- The entry of the module: one parameter, an address, fixed by the contract.
src/modules/system/module_files/main.odin:593
Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).
What the root service gives it
| What | Value | As the root service says |
|---|---|---|
| Grants | The module file service: its private store is the store module_files of its principal, as a private store has the name of its process, with the limit with which this service reads it and the tool writes it, so no grant differs from the limit on the disk; a client grant of TCP to one web server, 10.0.2.100 port 80; and its exports for the console. It starts nothing: this service checks the hash of each file that a principal starts. It starts when a principal connects to it. See: Module contract: A module from a disk | |
| Other terms of its start grant set | store_blocks = disk_process.STORE_BLOCKS_LIMIT, on_demand = true | |
| Budget that it asks for |
| The memory of one file of 4 MiB (1024 pages), the buffers of the 4 connections (96 pages), and its tables. |
The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).
Text wire form
A wire form of the module contract: one word of a call. The address of a slice record {address, count} of UTF-8 bytes.
Error_Record record of a module
A record of the module module_files: 56 bytes, aligned on 8 bytes, 0 bytes of padding.
kindi6408 bytesuniti6488 bytesoperationi64168 bytesargumenti64248 bytesvaluei64328 byteslimiti64408 bytesfoundi64488 bytes
Table wire form
A wire form of the module contract: one word of a call. Records of one description that follow each other (a table).
Module_File_Row record of a module
A record of the module module_files: 144 bytes, aligned on 8 bytes, 0 bytes of padding.
nameText(64)064 bytesbytesi64648 byteshashText(72)7272 bytes
Error_Record struct
A struct of the package errors: 56 bytes, aligned on 8 bytes, 0 bytes of padding. The error record: what a call that failed says about why, as seven integers.
kindi6408 bytesuniti6488 bytesoperationi64168 bytesargumenti64248 bytesvaluei64328 byteslimiti64408 bytesfoundi64488 bytes
start_from_disk procedure of the package console
start_from_disk :: proc "contextless" (arguments: []Value) -> Value
start_from_disk asks the root service to start a disk process, and waits.
Module_File_Row type of the package module_files
Module_File_Row :: struct {...}
One row of module_files.list().
list procedure of the package module_files
list :: proc "c" (result: ^[]Module_File_Row, error: ^errors.) -> i64
list gives one row for each module file of the store module_files: its name, its bytes, and the BLAKE3 hash of its bytes.
