Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
Tom Marshall | 5b4a9d8 | 2018-12-17 15:57:44 -0800 | [diff] [blame] | 3 | * Copyright (C) 2019 The LineageOS Project |
Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 4 | * |
| 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 Bao | 91a7aa4 | 2017-05-01 15:57:38 -0700 | [diff] [blame] | 21 | #include <functional> |
| 22 | |
| 23 | // Define the filenames created by the sideload FUSE filesystem. |
| 24 | static constexpr const char* FUSE_SIDELOAD_HOST_MOUNTPOINT = "/sideload"; |
| 25 | static constexpr const char* FUSE_SIDELOAD_HOST_FILENAME = "package.zip"; |
| 26 | static constexpr const char* FUSE_SIDELOAD_HOST_PATHNAME = "/sideload/package.zip"; |
Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 27 | |
| 28 | struct provider_vtab { |
Tao Bao | 91a7aa4 | 2017-05-01 15:57:38 -0700 | [diff] [blame] | 29 | // read a block |
| 30 | std::function<int(uint32_t block, uint8_t* buffer, uint32_t fetch_size)> read_block; |
Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 31 | |
Tao Bao | 91a7aa4 | 2017-05-01 15:57:38 -0700 | [diff] [blame] | 32 | // close down |
| 33 | std::function<void(void)> close; |
Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 34 | }; |
| 35 | |
Tao Bao | 91a7aa4 | 2017-05-01 15:57:38 -0700 | [diff] [blame] | 36 | int 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 Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 38 | |
Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 39 | #endif |