file_sync_service.h revision d340d2f57dc0d414ea66b1b556caaf8c98b1e967
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 20#ifdef HAVE_BIG_ENDIAN 21static inline unsigned __swap_uint32(unsigned x) 22{ 23 return (((x) & 0xFF000000) >> 24) 24 | (((x) & 0x00FF0000) >> 8) 25 | (((x) & 0x0000FF00) << 8) 26 | (((x) & 0x000000FF) << 24); 27} 28#define htoll(x) __swap_uint32(x) 29#define ltohl(x) __swap_uint32(x) 30#define MKID(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24)) 31#else 32#define htoll(x) (x) 33#define ltohl(x) (x) 34#define MKID(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) 35#endif 36 37#define ID_STAT MKID('S','T','A','T') 38#define ID_LIST MKID('L','I','S','T') 39#define ID_ULNK MKID('U','L','N','K') 40#define ID_SEND MKID('S','E','N','D') 41#define ID_RECV MKID('R','E','C','V') 42#define ID_DENT MKID('D','E','N','T') 43#define ID_DONE MKID('D','O','N','E') 44#define ID_DATA MKID('D','A','T','A') 45#define ID_OKAY MKID('O','K','A','Y') 46#define ID_FAIL MKID('F','A','I','L') 47#define ID_QUIT MKID('Q','U','I','T') 48 49typedef union { 50 unsigned id; 51 struct { 52 unsigned id; 53 unsigned namelen; 54 } req; 55 struct { 56 unsigned id; 57 unsigned mode; 58 unsigned size; 59 unsigned time; 60 } stat; 61 struct { 62 unsigned id; 63 unsigned mode; 64 unsigned size; 65 unsigned time; 66 unsigned namelen; 67 } dent; 68 struct { 69 unsigned id; 70 unsigned size; 71 } data; 72 struct { 73 unsigned id; 74 unsigned msglen; 75 } status; 76} syncmsg; 77 78 79void file_sync_service(int fd, void *cookie); 80int do_sync_ls(const char *path); 81int do_sync_push(const char *lpath, const char *rpath, int verifyApk); 82int do_sync_sync(const char *lpath, const char *rpath, int listonly); 83int do_sync_pull(const char *rpath, const char *lpath); 84 85#define SYNC_DATA_MAX (64*1024) 86 87#endif 88