1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #define MKID(a, b, c, d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) 20 21 #define ID_LSTAT_V1 MKID('S', 'T', 'A', 'T') 22 #define ID_STAT_V2 MKID('S', 'T', 'A', '2') 23 #define ID_LSTAT_V2 MKID('L', 'S', 'T', '2') 24 #define ID_LIST MKID('L', 'I', 'S', 'T') 25 #define ID_SEND MKID('S', 'E', 'N', 'D') 26 #define ID_RECV MKID('R', 'E', 'C', 'V') 27 #define ID_DENT MKID('D', 'E', 'N', 'T') 28 #define ID_DONE MKID('D', 'O', 'N', 'E') 29 #define ID_DATA MKID('D', 'A', 'T', 'A') 30 #define ID_OKAY MKID('O', 'K', 'A', 'Y') 31 #define ID_FAIL MKID('F', 'A', 'I', 'L') 32 #define ID_QUIT MKID('Q', 'U', 'I', 'T') 33 34 struct SyncRequest { 35 uint32_t id; // ID_STAT, et cetera. 36 uint32_t path_length; // <= 1024 37 // Followed by 'path_length' bytes of path (not NUL-terminated). 38 } __attribute__((packed)); 39 40 union syncmsg { 41 struct __attribute__((packed)) { 42 uint32_t id; 43 uint32_t mode; 44 uint32_t size; 45 uint32_t time; 46 } stat_v1; 47 struct __attribute__((packed)) { 48 uint32_t id; 49 uint32_t error; 50 uint64_t dev; 51 uint64_t ino; 52 uint32_t mode; 53 uint32_t nlink; 54 uint32_t uid; 55 uint32_t gid; 56 uint64_t size; 57 int64_t atime; 58 int64_t mtime; 59 int64_t ctime; 60 } stat_v2; 61 struct __attribute__((packed)) { 62 uint32_t id; 63 uint32_t mode; 64 uint32_t size; 65 uint32_t time; 66 uint32_t namelen; 67 } dent; 68 struct __attribute__((packed)) { 69 uint32_t id; 70 uint32_t size; 71 } data; 72 struct __attribute__((packed)) { 73 uint32_t id; 74 uint32_t msglen; 75 } status; 76 }; 77 78 #define SYNC_DATA_MAX (64 * 1024) 79