The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 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 | #ifndef _FILE_SYNC_SERVICE_H_ |
| 18 | #define _FILE_SYNC_SERVICE_H_ |
| 19 | |
Elliott Hughes | c5a12b2 | 2015-04-21 10:17:07 -0700 | [diff] [blame] | 20 | #include <string> |
| 21 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 22 | #define MKID(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 23 | |
| 24 | #define ID_STAT MKID('S','T','A','T') |
| 25 | #define ID_LIST MKID('L','I','S','T') |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 26 | #define ID_SEND MKID('S','E','N','D') |
| 27 | #define ID_RECV MKID('R','E','C','V') |
| 28 | #define ID_DENT MKID('D','E','N','T') |
| 29 | #define ID_DONE MKID('D','O','N','E') |
| 30 | #define ID_DATA MKID('D','A','T','A') |
| 31 | #define ID_OKAY MKID('O','K','A','Y') |
| 32 | #define ID_FAIL MKID('F','A','I','L') |
| 33 | #define ID_QUIT MKID('Q','U','I','T') |
| 34 | |
Elliott Hughes | b628cb1 | 2015-08-03 10:38:08 -0700 | [diff] [blame] | 35 | struct SyncRequest { |
| 36 | uint32_t id; // ID_STAT, et cetera. |
| 37 | uint32_t path_length; // <= 1024 |
| 38 | // Followed by 'path_length' bytes of path (not NUL-terminated). |
| 39 | } __attribute__((packed)) ; |
| 40 | |
Elliott Hughes | fe7ff81 | 2015-04-17 09:47:42 -0700 | [diff] [blame] | 41 | union syncmsg { |
Elliott Hughes | b628cb1 | 2015-08-03 10:38:08 -0700 | [diff] [blame] | 42 | struct __attribute__((packed)) { |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 43 | unsigned id; |
| 44 | unsigned mode; |
| 45 | unsigned size; |
| 46 | unsigned time; |
| 47 | } stat; |
Elliott Hughes | b628cb1 | 2015-08-03 10:38:08 -0700 | [diff] [blame] | 48 | struct __attribute__((packed)) { |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 49 | unsigned id; |
| 50 | unsigned mode; |
| 51 | unsigned size; |
| 52 | unsigned time; |
| 53 | unsigned namelen; |
| 54 | } dent; |
Elliott Hughes | b628cb1 | 2015-08-03 10:38:08 -0700 | [diff] [blame] | 55 | struct __attribute__((packed)) { |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 56 | unsigned id; |
| 57 | unsigned size; |
| 58 | } data; |
Elliott Hughes | b628cb1 | 2015-08-03 10:38:08 -0700 | [diff] [blame] | 59 | struct __attribute__((packed)) { |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 60 | unsigned id; |
| 61 | unsigned msglen; |
Mark Lindner | 9f9d145 | 2014-03-11 17:55:59 -0700 | [diff] [blame] | 62 | } status; |
Elliott Hughes | b628cb1 | 2015-08-03 10:38:08 -0700 | [diff] [blame] | 63 | }; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 64 | |
Elliott Hughes | b628cb1 | 2015-08-03 10:38:08 -0700 | [diff] [blame] | 65 | void file_sync_service(int fd, void* cookie); |
| 66 | bool do_sync_ls(const char* path); |
| 67 | bool do_sync_push(const char* lpath, const char* rpath, bool show_progress); |
| 68 | bool do_sync_sync(const std::string& lpath, const std::string& rpath, bool list_only); |
| 69 | bool do_sync_pull(const char* rpath, const char* lpath, bool show_progress, int copy_attrs); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 70 | |
| 71 | #define SYNC_DATA_MAX (64*1024) |
| 72 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 73 | #endif |