blob: 38565a0d019f843b4a8a53c33fb1254a56e891d0 [file] [log] [blame]
Doug Zongker18a78e02014-07-10 07:31:46 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
Tom Marshall5b4a9d82018-12-17 15:57:44 -08003 * Copyright (C) 2019 The LineageOS Project
Doug Zongker18a78e02014-07-10 07:31:46 -07004 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef __FUSE_SIDELOAD_H
19#define __FUSE_SIDELOAD_H
20
Tao Bao91a7aa42017-05-01 15:57:38 -070021#include <functional>
22
23// Define the filenames created by the sideload FUSE filesystem.
24static constexpr const char* FUSE_SIDELOAD_HOST_MOUNTPOINT = "/sideload";
25static constexpr const char* FUSE_SIDELOAD_HOST_FILENAME = "package.zip";
26static constexpr const char* FUSE_SIDELOAD_HOST_PATHNAME = "/sideload/package.zip";
Doug Zongker18a78e02014-07-10 07:31:46 -070027
28struct provider_vtab {
Tao Bao91a7aa42017-05-01 15:57:38 -070029 // read a block
30 std::function<int(uint32_t block, uint8_t* buffer, uint32_t fetch_size)> read_block;
Doug Zongker18a78e02014-07-10 07:31:46 -070031
Tao Bao91a7aa42017-05-01 15:57:38 -070032 // close down
33 std::function<void(void)> close;
Doug Zongker18a78e02014-07-10 07:31:46 -070034};
35
Tao Bao91a7aa42017-05-01 15:57:38 -070036int run_fuse_sideload(const provider_vtab& vtab, uint64_t file_size, uint32_t block_size,
37 const char* mount_point = FUSE_SIDELOAD_HOST_MOUNTPOINT);
Doug Zongker18a78e02014-07-10 07:31:46 -070038
Doug Zongker18a78e02014-07-10 07:31:46 -070039#endif