Sortix cross-volatile manual
This manual documents Sortix cross-volatile. You can instead view this document in the latest official manual.
NAME
serial-transfer — files over serial deviceDESCRIPTION
You can transfer data using the serial line. The sf(1) program provides simple framing which is useful to conduct advanced transfers by combining with other tools such as tar(1).sf -o
will emit a start byte sequence, then read from stdin and encode a body, and finally emit an end sequence. sf -i
will read bytes until it finds a start sequence, then it will decode the body and emit it to stdout, and finally stop when it receives the end sequence. We can use this to do transfers over the serial connection.Virtual Machines
This method is useful when running inside a virtual machine and you wish to communicate with the host system. This is particularly useful if you connect the serial line to a unix socket. In Qemu, this is done with:-serial unix:/tmp/serial,server,nowait
Conventions
Let /dev/receiver mean the device on the receiving machine and let /dev/transmitter mean the device on the transmitting machine. This will be devices such as /dev/com1. If one end is the host of a virtual machine as described above, its device will be an unix socket such as /tmp/serial.Simple File Transfer
You can then transfer a file from this system to another. First run on the receiving machine:sf -i /dev/receiver > file.txt
sf -o /dev/transmitter < file.txt
Advanced File Transfer
You can transfer multiple files using tar(1). This also allows you to preserve file meta data such as permissions and modified time. First run on the receiving machine:sf -i /dev/receiver | tar -xv
tar -cv *.patch | sf -o /dev/transmitter
Network Connection
It is possible to use the sfnc(1) and sfncd(1) scripts to create a bidirectional communication channel using two serial ports, one for each direction. The scripts use a protocol where sfnc(1) sends a hostname, a port, and the body from stdin. Likewise the sfncd(1) script receives the two parameters and invokes nc(1) (or another program as specified).sfncd /dev/receive /dev/transmit
sfnc example.com 443 /dev/transmit /dev/receive