From 49327806062652db999f3f0a7f360edb3047791a Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Mon, 26 Nov 2018 14:59:09 -0800 Subject: SYSTEM_ROOT -> get_system_root Add a get_system_root() function in roots.cpp which returns / or /system based on fstab. This factors out the 'if' check from recovery.cpp and fsck_unshare_blocks.cpp. Test: boot recovery, mount system Bug: 118634720 Change-Id: If4947cba3a3f08dbe695fd2b50a9354cd302ee03 --- roots.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'roots.cpp') diff --git a/roots.cpp b/roots.cpp index dc347848a..e68cb20bc 100644 --- a/roots.cpp +++ b/roots.cpp @@ -44,6 +44,7 @@ static struct fstab* fstab = nullptr; static bool did_map_logical_partitions = false; +static constexpr const char* SYSTEM_ROOT = "/system"; extern struct selabel_handle* sehandle; @@ -412,3 +413,11 @@ int setup_install_mounts() { bool logical_partitions_mapped() { return did_map_logical_partitions; } + +std::string get_system_root() { + if (volume_for_mount_point(SYSTEM_ROOT) == nullptr) { + return "/"; + } else { + return SYSTEM_ROOT; + } +} -- cgit v1.2.3