Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions filesync_protocol.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ Message Format:
directory or symlink.
The command here is referred to as 'id' in the code and the 4-letter codes
are prefixed by ID_, eg ID_STAT.
The command IDs are the little endian hexadecimal representations of the
4-letter command codes.


STAT:
request:
u32 command = 'STAT' == 0x53544154
u32 command = 'STAT' == 0x54415453
u32 size = len(filename) < 1024
u8 data[size] = filename (no null)

Expand All @@ -24,58 +27,58 @@ Message Format:

LIST:
request:
u32 command = 'LIST' == 0x4C495354
u32 command = 'LIST' == 0x5453494C
u32 size = len(path) < 1024
u8 data[size] = path (no null)

response:
for each filename in listing of path:
struct stat st = lstat(filename)
u32 command = 'DENT' == 0x44454E54
u32 command = 'DENT' == 0x544E4544
u32 mode = st.st_mode
u32 size = st.st_size
u32 time = st.st_mtime
u32 namelen = len(filename)
u8 data[namelen] = filename

done (device -> host):
u32 command = 'DONE' == 0x444F4E45
u32 command = 'DONE' == 0x454E4F44
u32[4] = 0

SEND:
struct stat st = lstat(filename)
request:
fileinfo = sprintf(',%d', st.st_mode)
u32 command = 'SEND' == 0x53454E44
u32 command = 'SEND' == 0x444E4553
u32 size = len(filename) + len(fileinfo) < 1024
u8 data[size] = filename + fileinfo

repeated data command (host -> device):
u32 command = 'DATA' == 0x44415441
u32 command = 'DATA' == 0x41544144
u32 size < (64 * 1024)
u8 data[size] = file contents

finish command (host -> device):
u32 command = 'DONE' == 0x444F4E45
u32 command = 'DONE' == 0x454E4F44
u32 timestamp = st.st_mtime

response (device -> host):
u32 command = 'OKAY' == 0x4F4B4159 or 'FAIL' == 0x4641494C
u32 command = 'OKAY' == 0x59414BF4 or 'FAIL' == 0x4C494146
u32 size = 0 if 'OKAY' else len(fail_message)
u8 data[] = fail_message

RECV:
request:
u32 command = 'RECV' == 0x52454356
u32 command = 'RECV' == 0x56434552
u32 size = len(filename)
u8 data[size] = filename

repeated data response (device -> host):
u32 command = 'DATA' == 0x44415441
u32 command = 'DATA' == 0x41544144
u32 size < (64 * 1024)
u8 data[size] = file contents

finish response (device -> host):
u32 command = 'DONE' == 0x444F4E45
u32 command = 'DONE' == 0x454E4F44
u32 size = 0