blob: 86efd0eabe3bec4006f4227485ed7d54e416c01f [file] [log] [blame]
Tom Marshallc575fc42015-11-16 13:48:28 -08001/*
2 * Copyright (C) 2019 The LineageOS 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#include <utils/String8.h>
18
19#include <lib/libtar.h>
20#include <zlib.h>
21
22extern "C" {
23#include <openssl/md5.h>
24#include <openssl/sha.h>
25#ifndef MD5_DIGEST_STRING_LENGTH
26#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
27#endif
28#ifndef SHA_DIGEST_STRING_LENGTH
29#define SHA_DIGEST_STRING_LENGTH (SHA_DIGEST_LENGTH * 2 + 1)
30#endif
31}
32
33#define HASH_MAX_LENGTH SHA_DIGEST_LENGTH
34#define HASH_MAX_STRING_LENGTH SHA_DIGEST_STRING_LENGTH
35
36#define PROP_LINE_LEN (PROPERTY_KEY_MAX + 1 + PROPERTY_VALUE_MAX + 1 + 1)
37
38extern int adb_ifd;
39extern int adb_ofd;
40extern TAR* tar;
41extern gzFile gzf;
42
43extern char* hash_name;
44extern size_t hash_datalen;
45extern SHA_CTX sha_ctx;
46extern MD5_CTX md5_ctx;
47
48struct partspec {
49 char* name;
50 char* path;
51 Volume* vol;
52 uint64_t size;
53 uint64_t used;
54 uint64_t off;
55};
56#define MAX_PART 8
57
58extern void logmsg(const char* fmt, ...);
59
60extern int part_add(const char* name);
61extern partspec* part_get(int i);
62extern partspec* part_find(const char* name);
63extern void part_set(partspec* part);
64
65extern int update_progress(uint64_t off);
66
67extern int create_tar(int fd, const char* compress, const char* mode);
68
69extern int do_backup(int argc, char** argv);
70extern int do_restore(int argc, char** argv);