1 /* 2 * Copyright (C) 2018 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 <string> 20 21 #include <fs_mgr.h> 22 23 namespace android { 24 namespace fs_mgr { 25 26 // Finds the volume specified by the given path. fs_mgr_get_entry_for_mount_point() does exact match 27 // only, so it attempts the prefixes recursively (e.g. "/cache/recovery/last_log", 28 // "/cache/recovery", "/cache", "/" for a given path of "/cache/recovery/last_log") and returns the 29 // first match or nullptr. 30 FstabEntry* GetEntryForPath(Fstab* fstab, const std::string& path); 31 32 std::vector<FstabEntry*> GetEntriesForPath(Fstab* fstab, const std::string& path); 33 34 // Make sure that the volume 'path' is on is mounted. 35 // * If 'mount_point' is nullptr, use mount point in fstab. Caller can call 36 // fs_mgr_ensure_path_unmounted() with the same 'path' argument to unmount. 37 // * If 'mount_point' is not nullptr, the mount point is overridden. Caller can 38 // call umount(mount_point) to unmount. 39 // Returns true on success (volume is mounted). 40 bool EnsurePathMounted(Fstab* fstab, const std::string& path, const std::string& mount_point = ""); 41 42 // Make sure that the volume 'path' is on is unmounted. Returns true on 43 // success (volume is unmounted). 44 bool EnsurePathUnmounted(Fstab* fstab, const std::string& path); 45 46 // Return "/system" if it is in default fstab, otherwise "/". 47 std::string GetSystemRoot(); 48 49 // Return true iff logical partitions are mapped when partitions are mounted via ensure_path_mounted 50 // functions. 51 bool LogicalPartitionsMapped(); 52 53 } // namespace fs_mgr 54 } // namespace android 55