blob: 4445a76174a1abb54b4c3026f3fcfec9b6970a13 [file] [log] [blame]
Jim Kayef7e359e2017-11-30 10:57:14 -08001This file tries to document file-related requests a client can make
Samuel Carlsson39ddc352014-03-20 11:44:09 +01002to the ADB server of an adbd daemon. See the OVERVIEW.TXT document
3to understand what's going on here. See the SERVICES.TXT to learn more
4about the other requests that are possible.
5
6SYNC SERVICES:
7
8
9Requesting the sync service ("sync:") using the protocol as described in
10SERVICES.TXT sets the connection in sync mode. This mode is a binary mode that
Jim Kayef7e359e2017-11-30 10:57:14 -080011differs from the regular adb protocol. The connection stays in sync mode until
Samuel Carlsson39ddc352014-03-20 11:44:09 +010012explicitly terminated (see below).
13
14After the initial "sync:" command is sent the server must respond with either
Jim Kayef7e359e2017-11-30 10:57:14 -080015"OKAY" or "FAIL" as per usual.
Samuel Carlsson39ddc352014-03-20 11:44:09 +010016
17In sync mode both the server and the client will frequently use eight-byte
Jim Kayef7e359e2017-11-30 10:57:14 -080018packets to communicate. In this document these are called sync requests and sync
19responses. The first four bytes are an id that specifies the sync request. It is
20represented by four utf-8 characters. The last four bytes are a Little-Endian
Samuel Carlsson39ddc352014-03-20 11:44:09 +010021integer, with various uses. This number will be called "length" below. In fact
22all binary integers are Little-Endian in the sync mode. Sync mode is
23implicitly exited after each sync request, and normal adb communication
24follows as described in SERVICES.TXT.
25
26The following sync requests are accepted:
27LIST - List the files in a folder
Elliott Hughesb628cb12015-08-03 10:38:08 -070028RECV - Retrieve a file from device
Samuel Carlsson39ddc352014-03-20 11:44:09 +010029SEND - Send a file to device
Samuel Carlsson39ddc352014-03-20 11:44:09 +010030STAT - Stat a file
Samuel Carlsson39ddc352014-03-20 11:44:09 +010031
Jim Kayef7e359e2017-11-30 10:57:14 -080032All of the sync requests above must be followed by "length": the number of
33bytes containing a utf-8 string with a remote filename.
Samuel Carlsson39ddc352014-03-20 11:44:09 +010034
35LIST:
36Lists files in the directory specified by the remote filename. The server will
37respond with zero or more directory entries or "dents".
38
39The directory entries will be returned in the following form
Elliott Hughesb628cb12015-08-03 10:38:08 -0700401. A four-byte sync response id "DENT"
Samuel Carlsson39ddc352014-03-20 11:44:09 +0100412. A four-byte integer representing file mode.
423. A four-byte integer representing file size.
434. A four-byte integer representing last modified time.
445. A four-byte integer representing file name length.
456. length number of bytes containing an utf-8 string representing the file
46 name.
47
Jim Kayef7e359e2017-11-30 10:57:14 -080048When a sync response "DONE" is received the listing is done.
Samuel Carlsson39ddc352014-03-20 11:44:09 +010049
50SEND:
51The remote file name is split into two parts separated by the last
52comma (","). The first part is the actual path, while the second is a decimal
53encoded file mode containing the permissions of the file on device.
54
55Note that some file types will be deleted before the copying starts, and if
56the transfer fails. Some file types will not be deleted, which allows
57 adb push disk_image /some_block_device
58to work.
59
Elliott Hughesb628cb12015-08-03 10:38:08 -070060After this the actual file is sent in chunks. Each chunk has the following
Samuel Carlsson39ddc352014-03-20 11:44:09 +010061format.
62A sync request with id "DATA" and length equal to the chunk size. After
63follows chunk size number of bytes. This is repeated until the file is
Elliott Hughesb628cb12015-08-03 10:38:08 -070064transferred. Each chunk must not be larger than 64k.
Samuel Carlsson39ddc352014-03-20 11:44:09 +010065
Elliott Hughesb628cb12015-08-03 10:38:08 -070066When the file is transferred a sync request "DONE" is sent, where length is set
Samuel Carlsson39ddc352014-03-20 11:44:09 +010067to the last modified time for the file. The server responds to this last
Jim Kayef7e359e2017-11-30 10:57:14 -080068request (but not to chunk requests) with an "OKAY" sync response (length can
Samuel Carlsson39ddc352014-03-20 11:44:09 +010069be ignored).
70
71
72RECV:
73Retrieves a file from device to a local file. The remote path is the path to
74the file that will be returned. Just as for the SEND sync request the file
75received is split up into chunks. The sync response id is "DATA" and length is
Jim Kayef7e359e2017-11-30 10:57:14 -080076the chunk size. After follows chunk size number of bytes. This is repeated
77until the file is transferred. Each chunk will not be larger than 64k.
Samuel Carlsson39ddc352014-03-20 11:44:09 +010078
Elliott Hughesb628cb12015-08-03 10:38:08 -070079When the file is transferred a sync response "DONE" is retrieved where the
Samuel Carlsson39ddc352014-03-20 11:44:09 +010080length can be ignored.