blob: e0320fb7d266b734d67d6e4282df116c0942d623 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001/*
2 * Copyright (C) 2008 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 _APPLYPATCH_H
18#define _APPLYPATCH_H
19
20#include "mincrypt/sha.h"
21
22typedef struct _Patch {
23 uint8_t sha1[SHA_DIGEST_SIZE];
24 const char* patch_filename;
25} Patch;
26
27typedef struct _FileContents {
28 uint8_t sha1[SHA_DIGEST_SIZE];
29 unsigned char* data;
30 size_t size;
31 struct stat st;
32} FileContents;
33
34// When there isn't enough room on the target filesystem to hold the
35// patched version of the file, we copy the original here and delete
36// it to free up space. If the expected source file doesn't exist, or
37// is corrupted, we look to see if this file contains the bits we want
38// and use it as the source instead.
39#define CACHE_TEMP_SOURCE "/cache/saved.file"
40
Doug Zongker5da317e2009-06-02 13:38:17 -070041// When writing to an MTD partition, we first put the output in this
42// temp file, then copy it to the partition once the patching is
43// finished (and the target sha1 verified).
44#define MTD_TARGET_TEMP_FILE "/tmp/mtd-temp"
45
The Android Open Source Project88b60792009-03-03 19:28:42 -080046// applypatch.c
47size_t FreeSpaceForFile(const char* filename);
48
49// bsdiff.c
50void ShowBSDiffLicense();
51int ApplyBSDiffPatch(const unsigned char* old_data, ssize_t old_size,
Doug Zongker02d444b2009-05-27 18:24:03 -070052 const char* patch_filename, ssize_t offset,
53 FILE* output, SHA_CTX* ctx);
54int ApplyBSDiffPatchMem(const unsigned char* old_data, ssize_t old_size,
55 const char* patch_filename, ssize_t patch_offset,
56 unsigned char** new_data, ssize_t* new_size);
57
58// imgpatch.c
59int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
The Android Open Source Project88b60792009-03-03 19:28:42 -080060 const char* patch_filename,
61 FILE* output, SHA_CTX* ctx);
62
63// freecache.c
64int MakeFreeSpaceOnCache(size_t bytes_needed);
65
66#endif