1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Permission is hereby granted, free of charge, to any person
5  * obtaining a copy of this software and associated documentation
6  * files (the "Software"), to deal in the Software without
7  * restriction, including without limitation the rights to use, copy,
8  * modify, merge, publish, distribute, sublicense, and/or sell copies
9  * of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
25 #ifndef AVB_OPS_USER_H_
26 #define AVB_OPS_USER_H_
27 
28 #include <libavb/libavb.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* Allocates an AvbOps instance suitable for use in Android userspace
35  * on the device. Returns NULL on OOM.
36  *
37  * The returned AvbOps has the following characteristics:
38  *
39  * - The read_from_partition(), write_to_partition(), and
40  *   get_size_of_partition() operations are implemented, however for
41  *   these operations to work the fstab file on the device must have a
42  *   /misc entry using a by-name device file scheme and the containing
43  *   by-name/ subdirectory must have files for other partitions.
44  *
45  * - The remaining operations are implemented and never fails and
46  *   return the following values:
47  *   - validate_vbmeta_public_key(): always returns |true|.
48  *   - read_rollback_index(): returns 0 for any roolback index.
49  *   - write_rollback_index(): no-op.
50  *   - read_is_device_unlocked(): always returns |true|.
51  *   - get_unique_guid_for_partition(): always returns the empty string.
52  *
53  * - The |ab_ops| member will point to a valid AvbABOps instance
54  *   implemented via libavb_ab/. This should only be used if the AVB
55  *   A/B stack is used on the device. This is what is used in
56  *   bootctrl.avb boot control implementation.
57  *
58  * Free with avb_ops_user_free().
59  */
60 AvbOps* avb_ops_user_new(void);
61 
62 /* Frees an AvbOps instance previously allocated with avb_ops_device_new(). */
63 void avb_ops_user_free(AvbOps* ops);
64 
65 #ifdef __cplusplus
66 }
67 #endif
68 
69 #endif /* AVB_OPS_USER_H_ */
70