1 /*
2  * Copyright (C) 2016 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 #pragma once
17 
18 #include <stdint.h>
19 #include <trusty/interface/storage.h>
20 
21 /* Defined in watchdog.h */
22 struct watcher;
23 
24 /* Is used for managing alternate backing storage, generally will be a block device. */
25 struct storage_mapping_node {
26     struct storage_mapping_node* next;
27     const char* file_name;
28     const char* backing_storage;
29     int fd;
30 };
31 
32 int storage_file_delete(struct storage_msg* msg, const void* req, size_t req_len,
33                         struct watcher* watcher);
34 
35 int storage_file_open(struct storage_msg* msg, const void* req, size_t req_len,
36                       struct watcher* watcher);
37 
38 int storage_file_close(struct storage_msg* msg, const void* req, size_t req_len,
39                        struct watcher* watcher);
40 
41 int storage_file_write(struct storage_msg* msg, const void* req, size_t req_len,
42                        struct watcher* watcher);
43 
44 int storage_file_read(struct storage_msg* msg, const void* req, size_t req_len,
45                       struct watcher* watcher);
46 
47 int storage_file_get_size(struct storage_msg* msg, const void* req, size_t req_len,
48                           struct watcher* watcher);
49 
50 int storage_file_set_size(struct storage_msg* msg, const void* req, size_t req_len,
51                           struct watcher* watcher);
52 
53 int storage_file_get_max_size(struct storage_msg* msg, const void* req, size_t req_len,
54                               struct watcher* watcher);
55 
56 int storage_init(const char* dirname, struct storage_mapping_node* head,
57                  const char* max_file_size_from);
58 
59 int storage_sync_checkpoint(struct watcher* watcher);
60