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 // Make sure that the volume 'path' is on is mounted. 33 // * If 'mount_point' is nullptr, use mount point in fstab. Caller can call 34 // fs_mgr_ensure_path_unmounted() with the same 'path' argument to unmount. 35 // * If 'mount_point' is not nullptr, the mount point is overridden. Caller can 36 // call umount(mount_point) to unmount. 37 // Returns true on success (volume is mounted). 38 bool EnsurePathMounted(Fstab* fstab, const std::string& path, const std::string& mount_point = ""); 39 40 // Make sure that the volume 'path' is on is unmounted. Returns true on 41 // success (volume is unmounted). 42 bool EnsurePathUnmounted(Fstab* fstab, const std::string& path); 43 44 // Return "/system" if it is in default fstab, otherwise "/". 45 std::string GetSystemRoot(); 46 47 // Return true iff logical partitions are mapped when partitions are mounted via ensure_path_mounted 48 // functions. 49 bool LogicalPartitionsMapped(); 50 51 } // namespace fs_mgr 52 } // namespace android 53