blob: c048617c20725c3819b9e1a82e0e220f31170cf8 [file] [log] [blame]
Jed Estepff6df892015-12-15 16:04:53 -08001/*
2 * Copyright (C) 2015 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/*
18 * Read configuration files in the OTA package to determine which files, if any, will trigger errors.
19 *
20 * OTA packages can be modified to trigger errors by adding a top-level
21 * directory called .libotafault, which may optionally contain up to three
22 * files called READ, WRITE, and FSYNC. Each one of these optional files
23 * contains the name of a single file on the device disk which will cause
24 * an IO error on the first call of the appropriate I/O action to that file.
25 *
26 * Example:
27 * ota.zip
28 * <normal package contents>
29 * .libotafault
30 * WRITE
31 *
32 * If the contents of the file WRITE were /system/build.prop, the first write
33 * action to /system/build.prop would fail with EIO. Note that READ and
34 * FSYNC files are absent, so these actions will not cause an error.
35 */
36
37#ifndef _UPDATER_OTA_IO_CFG_H_
38#define _UPDATER_OTA_IO_CFG_H_
39
40#include <string>
41
42#include <stdbool.h>
43
Tianjie Xu8cf5c8f2016-09-08 20:10:11 -070044#include <ziparchive/zip_archive.h>
Jed Estepff6df892015-12-15 16:04:53 -080045
46#define OTAIO_BASE_DIR ".libotafault"
47#define OTAIO_READ "READ"
48#define OTAIO_WRITE "WRITE"
49#define OTAIO_FSYNC "FSYNC"
50#define OTAIO_CACHE "CACHE"
51
52/*
53 * Initialize libotafault by providing a reference to the OTA package.
54 */
Tianjie Xu8cf5c8f2016-09-08 20:10:11 -070055void ota_io_init(ZipArchiveHandle zip);
Jed Estepff6df892015-12-15 16:04:53 -080056
57/*
58 * Return true if a config file is present for the given IO type.
59 */
60bool should_fault_inject(const char* io_type);
61
62/*
63 * Return true if an EIO should occur on the next hit to /cache/saved.file
64 * instead of the next hit to the specified file.
65 */
66bool should_hit_cache();
67
68/*
69 * Return the name of the file that should cause an error for the
70 * given IO type.
71 */
72std::string fault_fname(const char* io_type);
73
74#endif