PHASE PROTOCOL VERSION 1.1 2024-06-25 The following is a general-purpose read/write protocol for data storage systems in Second Life. It originated in Nanite Systems ARES 0.4.4. Importantly, it is opaque enough to handle almost any underlying storage system, from read-only notecard access to a full-access web server. Data sizes can be specified in either bytes or pages. A page is notionally 1024 bytes, but can be incomplete (known as a "ragged" page.) This size fits in a single SL channel message, and in a single line of a notecard. Except where otherwise specified, each control message consists of the format: ... Where is an arbitrary string (typically a UUID) generated by the OS for each interaction, is one of: system-to-storage: connect disconnect stat read write append delete close storage-to-system: version reset access stat ready deleted new update denied and the s are -specific. The main control channel is 1608011905, or "phase" in character ordinals (with "a" = 01). Side channels are sometimes created for sending data, in both directions. READING CHANNELS For efficiency, whenever the system wants to read a file from the storage device, it opens a listener and passes the channel number to the storage device, asking the storage device to send data there. This is called a reading channel. Messages sent on the reading channel are unadorned, and it is entirely up to the system to close the channel when it is no longer required. This allows data to be read in chunks of up to 1024 bytes (or one notecard line) without splitting. If reading from the given filename is not possible, the storage device may reject the request by sending "stat none" (meaning that the file is not in a readable format, or does not exist) or "denied" (meaning that the system does not have adequate permissions.) WRITING CHANNELS Whenever the system wants to write to a file, it informs the storage device (with a "write" or "append" message), which includes a channel number as one of its arguments. The storage device then opens a listener on that channel number and announces that it is prepared to receive text with the "ready" message. All text received from the system should then be written by the storage device to the indicated file. The system will announce it is done sending data by sending a "close" message. If writing to the given filename is not possible, the storage device may reject the request by sending "stat none" (meaning that the file could not be created/accessed) or "denied" (meaning that the system does not have adequate permissions.) DIRECTORY FORMAT The phase directory format is simply a list of filenames, separated by 0x0a ('\n'). This is the same as the obsolete wf0 and wf1 formats. MESSAGES connect system -> storage where is one of: ro rd rw Initiates a connection with the specified access level. The storage device should respond with an "access" command (below), and store the host UUID and granted level of permission for future reference. The modes are defined as "read only" (ro), "read and delete" (rd), or "full access" (rw). At this point, the storage device should also check through all existing connections and confirm that the hosts involved still exist (that is, llGetOwnerKey(id) != id). Failing that, delete those connections and close any writing channels (described earlier) associated with them. However, if is NULL_KEY, the system is simply pinging and does not want to alter the state of any existing connections. A storage device that wants to be seen by the inquiring party (e.g. for public use) should respond with a "version" message; otherwise, no response is required. version