adb: extract syncmsg structs.
Make it so that we can get the sizeof a member of syncmsg without having
an instance of syncmsg or doing something awful along the lines of
sizeof(reinterpret_cast<syncmsg*>(nullptr)->status).
Bug: http://b/150827486
Test: m adb adbd
Change-Id: I4830e7f90033c7706ff52cdd8d13e9cf40c73628
(cherry picked from commit eddae9292860d053988f791ae1a1498e38d5edee)
diff --git a/adb/file_sync_protocol.h b/adb/file_sync_protocol.h
index 508c138..87ede0c 100644
--- a/adb/file_sync_protocol.h
+++ b/adb/file_sync_protocol.h
@@ -41,57 +41,69 @@
// Followed by 'path_length' bytes of path (not NUL-terminated).
} __attribute__((packed));
+struct __attribute__((packed)) sync_stat_v1 {
+ uint32_t id;
+ uint32_t mode;
+ uint32_t size;
+ uint32_t mtime;
+};
+
+struct __attribute__((packed)) sync_stat_v2 {
+ uint32_t id;
+ uint32_t error;
+ uint64_t dev;
+ uint64_t ino;
+ uint32_t mode;
+ uint32_t nlink;
+ uint32_t uid;
+ uint32_t gid;
+ uint64_t size;
+ int64_t atime;
+ int64_t mtime;
+ int64_t ctime;
+};
+
+struct __attribute__((packed)) sync_dent_v1 {
+ uint32_t id;
+ uint32_t mode;
+ uint32_t size;
+ uint32_t mtime;
+ uint32_t namelen;
+}; // followed by `namelen` bytes of the name.
+
+struct __attribute__((packed)) sync_dent_v2 {
+ uint32_t id;
+ uint32_t error;
+ uint64_t dev;
+ uint64_t ino;
+ uint32_t mode;
+ uint32_t nlink;
+ uint32_t uid;
+ uint32_t gid;
+ uint64_t size;
+ int64_t atime;
+ int64_t mtime;
+ int64_t ctime;
+ uint32_t namelen;
+}; // followed by `namelen` bytes of the name.
+
+struct __attribute__((packed)) sync_data {
+ uint32_t id;
+ uint32_t size;
+}; // followed by `size` bytes of data.
+
+struct __attribute__((packed)) sync_status {
+ uint32_t id;
+ uint32_t msglen;
+}; // followed by `msglen` bytes of error message, if id == ID_FAIL.
+
union syncmsg {
- struct __attribute__((packed)) {
- uint32_t id;
- uint32_t mode;
- uint32_t size;
- uint32_t mtime;
- } stat_v1;
- struct __attribute__((packed)) {
- uint32_t id;
- uint32_t error;
- uint64_t dev;
- uint64_t ino;
- uint32_t mode;
- uint32_t nlink;
- uint32_t uid;
- uint32_t gid;
- uint64_t size;
- int64_t atime;
- int64_t mtime;
- int64_t ctime;
- } stat_v2;
- struct __attribute__((packed)) {
- uint32_t id;
- uint32_t mode;
- uint32_t size;
- uint32_t mtime;
- uint32_t namelen;
- } dent_v1; // followed by `namelen` bytes of the name.
- struct __attribute__((packed)) {
- uint32_t id;
- uint32_t error;
- uint64_t dev;
- uint64_t ino;
- uint32_t mode;
- uint32_t nlink;
- uint32_t uid;
- uint32_t gid;
- uint64_t size;
- int64_t atime;
- int64_t mtime;
- int64_t ctime;
- uint32_t namelen;
- } dent_v2; // followed by `namelen` bytes of the name.
- struct __attribute__((packed)) {
- uint32_t id;
- uint32_t size;
- } data; // followed by `size` bytes of data.
- struct __attribute__((packed)) {
- uint32_t id;
- uint32_t msglen;
- } status; // followed by `msglen` bytes of error message, if id == ID_FAIL.
+ sync_stat_v1 stat_v1;
+ sync_stat_v2 stat_v2;
+ sync_dent_v1 dent_v1;
+ sync_dent_v2 dent_v2;
+ sync_data data;
+ sync_status status;
};
#define SYNC_DATA_MAX (64 * 1024)