1 /* 2 * Copyright (C) 2019 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 #pragma once 18 19 #include <stdint.h> 20 21 #include <string> 22 23 #include <libfiemap/split_fiemap_writer.h> 24 25 namespace android { 26 namespace fiemap { 27 28 // Given a file that will be created, determine the maximum size its containing 29 // filesystem allows. Note this is a theoretical maximum size; free space is 30 // ignored entirely. 31 FiemapStatus DetermineMaximumFileSize(const std::string& file_path, uint64_t* result); 32 33 // Given a SplitFiemap, this returns a device path that will work during first- 34 // stage init (i.e., its path can be found by InitRequiredDevices). 35 std::string GetDevicePathForFile(android::fiemap::SplitFiemap* file); 36 37 // Combine two path components into a single path. 38 std::string JoinPaths(const std::string& dir, const std::string& file); 39 40 // Given a file within an F2FS filesystem, return whether or not the filesystem 41 // supports the "pin_file" feature, which requires pinning before fallocation. 42 bool F2fsPinBeforeAllocate(int file_fd, bool* supported); 43 44 // Given a major/minor device number, return its canonical name such that 45 // /dev/block/<name> resolves to the device. 46 bool BlockDeviceToName(uint32_t major, uint32_t minor, std::string* bdev_name); 47 48 // This is the same as F2fsPinBeforeAllocate, however, it will return true 49 // (and supported = true) for non-f2fs filesystems. It is intended to be used 50 // in conjunction with ImageManager to reject image requests for reliable use 51 // cases (such as snapshots or adb remount). 52 bool FilesystemHasReliablePinning(const std::string& file, bool* supported); 53 54 // Crude implementation to check if |child| is a subdir of |parent|. 55 // Assume both are absolute paths. 56 bool IsSubdir(const std::string& child, const std::string& parent); 57 58 } // namespace fiemap 59 } // namespace android 60