| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 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 | #include "mount_namespace.h" | 
|  | 18 |  | 
|  | 19 | #include <sys/mount.h> | 
|  | 20 |  | 
|  | 21 | #include <string> | 
|  | 22 | #include <vector> | 
|  | 23 |  | 
| Jiyong Park | 8502ed3 | 2019-02-25 22:18:37 +0900 | [diff] [blame] | 24 | #include <ApexProperties.sysprop.h> | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 25 | #include <android-base/file.h> | 
|  | 26 | #include <android-base/logging.h> | 
|  | 27 | #include <android-base/properties.h> | 
| Jooyung Han | 5bb9d21 | 2019-11-25 13:50:44 +0900 | [diff] [blame] | 28 | #include <android-base/result.h> | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 29 | #include <android-base/unique_fd.h> | 
| Jiyong Park | 648ae3a | 2019-12-08 00:25:15 +0900 | [diff] [blame] | 30 | #include <apex_manifest.pb.h> | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 31 |  | 
|  | 32 | #include "util.h" | 
|  | 33 |  | 
|  | 34 | namespace android { | 
|  | 35 | namespace init { | 
|  | 36 | namespace { | 
|  | 37 |  | 
| Martijn Coenen | c70c066 | 2020-01-10 15:42:15 +0100 | [diff] [blame] | 38 | static bool BindMount(const std::string& source, const std::string& mount_point, | 
|  | 39 | bool recursive = false) { | 
|  | 40 | unsigned long mountflags = MS_BIND; | 
|  | 41 | if (recursive) { | 
|  | 42 | mountflags |= MS_REC; | 
|  | 43 | } | 
|  | 44 | if (mount(source.c_str(), mount_point.c_str(), nullptr, mountflags, nullptr) == -1) { | 
|  | 45 | PLOG(ERROR) << "Failed to bind mount " << source; | 
|  | 46 | return false; | 
|  | 47 | } | 
|  | 48 | return true; | 
|  | 49 | } | 
|  | 50 |  | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 51 | static bool MakeShared(const std::string& mount_point, bool recursive = false) { | 
|  | 52 | unsigned long mountflags = MS_SHARED; | 
|  | 53 | if (recursive) { | 
|  | 54 | mountflags |= MS_REC; | 
|  | 55 | } | 
|  | 56 | if (mount(nullptr, mount_point.c_str(), nullptr, mountflags, nullptr) == -1) { | 
|  | 57 | PLOG(ERROR) << "Failed to change propagation type to shared"; | 
|  | 58 | return false; | 
|  | 59 | } | 
|  | 60 | return true; | 
|  | 61 | } | 
|  | 62 |  | 
| Martijn Coenen | c70c066 | 2020-01-10 15:42:15 +0100 | [diff] [blame] | 63 | static bool MakeSlave(const std::string& mount_point, bool recursive = false) { | 
|  | 64 | unsigned long mountflags = MS_SLAVE; | 
|  | 65 | if (recursive) { | 
|  | 66 | mountflags |= MS_REC; | 
|  | 67 | } | 
|  | 68 | if (mount(nullptr, mount_point.c_str(), nullptr, mountflags, nullptr) == -1) { | 
|  | 69 | PLOG(ERROR) << "Failed to change propagation type to slave"; | 
|  | 70 | return false; | 
|  | 71 | } | 
|  | 72 | return true; | 
|  | 73 | } | 
|  | 74 |  | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 75 | static bool MakePrivate(const std::string& mount_point, bool recursive = false) { | 
|  | 76 | unsigned long mountflags = MS_PRIVATE; | 
|  | 77 | if (recursive) { | 
|  | 78 | mountflags |= MS_REC; | 
|  | 79 | } | 
|  | 80 | if (mount(nullptr, mount_point.c_str(), nullptr, mountflags, nullptr) == -1) { | 
|  | 81 | PLOG(ERROR) << "Failed to change propagation type to private"; | 
|  | 82 | return false; | 
|  | 83 | } | 
|  | 84 | return true; | 
|  | 85 | } | 
|  | 86 |  | 
|  | 87 | static int OpenMountNamespace() { | 
|  | 88 | int fd = open("/proc/self/ns/mnt", O_RDONLY | O_CLOEXEC); | 
|  | 89 | if (fd < 0) { | 
|  | 90 | PLOG(ERROR) << "Cannot open fd for current mount namespace"; | 
|  | 91 | } | 
|  | 92 | return fd; | 
|  | 93 | } | 
|  | 94 |  | 
|  | 95 | static std::string GetMountNamespaceId() { | 
|  | 96 | std::string ret; | 
|  | 97 | if (!android::base::Readlink("/proc/self/ns/mnt", &ret)) { | 
|  | 98 | PLOG(ERROR) << "Failed to read namespace ID"; | 
|  | 99 | return ""; | 
|  | 100 | } | 
|  | 101 | return ret; | 
|  | 102 | } | 
|  | 103 |  | 
| Jiyong Park | 8502ed3 | 2019-02-25 22:18:37 +0900 | [diff] [blame] | 104 | static bool IsApexUpdatable() { | 
|  | 105 | static bool updatable = android::sysprop::ApexProperties::updatable().value_or(false); | 
|  | 106 | return updatable; | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 107 | } | 
|  | 108 |  | 
| Jooyung Han | 5bb9d21 | 2019-11-25 13:50:44 +0900 | [diff] [blame] | 109 | static Result<void> MountDir(const std::string& path, const std::string& mount_path) { | 
| Satoshi Niwa | 1eb300d | 2020-01-20 18:00:49 +0900 | [diff] [blame] | 110 | if (int ret = mkdir(mount_path.c_str(), 0755); ret != 0 && errno != EEXIST) { | 
| Jooyung Han | 5bb9d21 | 2019-11-25 13:50:44 +0900 | [diff] [blame] | 111 | return ErrnoError() << "Could not create mount point " << mount_path; | 
|  | 112 | } | 
|  | 113 | if (mount(path.c_str(), mount_path.c_str(), nullptr, MS_BIND, nullptr) != 0) { | 
|  | 114 | return ErrnoError() << "Could not bind mount " << path << " to " << mount_path; | 
|  | 115 | } | 
|  | 116 | return {}; | 
|  | 117 | } | 
|  | 118 |  | 
| Jiyong Park | 648ae3a | 2019-12-08 00:25:15 +0900 | [diff] [blame] | 119 | static Result<std::string> GetApexName(const std::string& apex_dir) { | 
|  | 120 | const std::string manifest_path = apex_dir + "/apex_manifest.pb"; | 
|  | 121 | std::string content; | 
|  | 122 | if (!android::base::ReadFileToString(manifest_path, &content)) { | 
|  | 123 | return Error() << "Failed to read manifest file: " << manifest_path; | 
|  | 124 | } | 
|  | 125 | apex::proto::ApexManifest manifest; | 
|  | 126 | if (!manifest.ParseFromString(content)) { | 
|  | 127 | return Error() << "Can't parse manifest file: " << manifest_path; | 
|  | 128 | } | 
|  | 129 | return manifest.name(); | 
|  | 130 | } | 
|  | 131 |  | 
| Jooyung Han | 5bb9d21 | 2019-11-25 13:50:44 +0900 | [diff] [blame] | 132 | static Result<void> ActivateFlattenedApexesFrom(const std::string& from_dir, | 
|  | 133 | const std::string& to_dir) { | 
|  | 134 | std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(from_dir.c_str()), closedir); | 
|  | 135 | if (!dir) { | 
|  | 136 | return {}; | 
|  | 137 | } | 
|  | 138 | dirent* entry; | 
|  | 139 | while ((entry = readdir(dir.get())) != nullptr) { | 
|  | 140 | if (entry->d_name[0] == '.') continue; | 
|  | 141 | if (entry->d_type == DT_DIR) { | 
|  | 142 | const std::string apex_path = from_dir + "/" + entry->d_name; | 
| Jiyong Park | 648ae3a | 2019-12-08 00:25:15 +0900 | [diff] [blame] | 143 | const auto apex_name = GetApexName(apex_path); | 
| Bernie Innocenti | cecebbb | 2020-02-06 03:49:33 +0900 | [diff] [blame] | 144 | if (!apex_name.ok()) { | 
| Jiyong Park | 648ae3a | 2019-12-08 00:25:15 +0900 | [diff] [blame] | 145 | LOG(ERROR) << apex_path << " is not an APEX directory: " << apex_name.error(); | 
|  | 146 | continue; | 
|  | 147 | } | 
|  | 148 | const std::string mount_path = to_dir + "/" + (*apex_name); | 
| Bernie Innocenti | cecebbb | 2020-02-06 03:49:33 +0900 | [diff] [blame] | 149 | if (auto result = MountDir(apex_path, mount_path); !result.ok()) { | 
| Jooyung Han | 5bb9d21 | 2019-11-25 13:50:44 +0900 | [diff] [blame] | 150 | return result; | 
|  | 151 | } | 
|  | 152 | } | 
|  | 153 | } | 
|  | 154 | return {}; | 
|  | 155 | } | 
|  | 156 |  | 
| Jiyong Park | d7f7c20 | 2019-05-10 21:12:15 +0900 | [diff] [blame] | 157 | static bool ActivateFlattenedApexesIfPossible() { | 
|  | 158 | if (IsRecoveryMode() || IsApexUpdatable()) { | 
|  | 159 | return true; | 
|  | 160 | } | 
|  | 161 |  | 
| Jooyung Han | 5bb9d21 | 2019-11-25 13:50:44 +0900 | [diff] [blame] | 162 | const std::string kApexTop = "/apex"; | 
|  | 163 | const std::vector<std::string> kBuiltinDirsForApexes = { | 
|  | 164 | "/system/apex", | 
|  | 165 | "/system_ext/apex", | 
|  | 166 | "/product/apex", | 
|  | 167 | "/vendor/apex", | 
|  | 168 | }; | 
| Jiyong Park | d7f7c20 | 2019-05-10 21:12:15 +0900 | [diff] [blame] | 169 |  | 
| Jooyung Han | 5bb9d21 | 2019-11-25 13:50:44 +0900 | [diff] [blame] | 170 | for (const auto& dir : kBuiltinDirsForApexes) { | 
| Bernie Innocenti | cecebbb | 2020-02-06 03:49:33 +0900 | [diff] [blame] | 171 | if (auto result = ActivateFlattenedApexesFrom(dir, kApexTop); !result.ok()) { | 
| Jooyung Han | 5bb9d21 | 2019-11-25 13:50:44 +0900 | [diff] [blame] | 172 | LOG(ERROR) << result.error(); | 
|  | 173 | return false; | 
|  | 174 | } | 
|  | 175 | } | 
| Jiyong Park | 648ae3a | 2019-12-08 00:25:15 +0900 | [diff] [blame] | 176 | return true; | 
| Jiyong Park | d7f7c20 | 2019-05-10 21:12:15 +0900 | [diff] [blame] | 177 | } | 
|  | 178 |  | 
| Kiyoung Kim | e4d3f21 | 2019-12-16 14:31:04 +0900 | [diff] [blame] | 179 | static Result<void> MountLinkerConfigForDefaultNamespace() { | 
|  | 180 | // No need to mount linkerconfig for default mount namespace if the path does not exist (which | 
|  | 181 | // would mean it is already mounted) | 
|  | 182 | if (access("/linkerconfig/default", 0) != 0) { | 
|  | 183 | return {}; | 
|  | 184 | } | 
|  | 185 |  | 
|  | 186 | if (mount("/linkerconfig/default", "/linkerconfig", nullptr, MS_BIND | MS_REC, nullptr) != 0) { | 
|  | 187 | return ErrnoError() << "Failed to mount linker configuration for default mount namespace."; | 
|  | 188 | } | 
|  | 189 |  | 
|  | 190 | return {}; | 
|  | 191 | } | 
|  | 192 |  | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 193 | static android::base::unique_fd bootstrap_ns_fd; | 
|  | 194 | static android::base::unique_fd default_ns_fd; | 
|  | 195 |  | 
|  | 196 | static std::string bootstrap_ns_id; | 
|  | 197 | static std::string default_ns_id; | 
|  | 198 |  | 
|  | 199 | }  // namespace | 
|  | 200 |  | 
|  | 201 | bool SetupMountNamespaces() { | 
|  | 202 | // Set the propagation type of / as shared so that any mounting event (e.g. | 
|  | 203 | // /data) is by default visible to all processes. When private mounting is | 
|  | 204 | // needed for /foo/bar, then we will make /foo/bar as a mount point (by | 
|  | 205 | // bind-mounting by to itself) and set the propagation type of the mount | 
|  | 206 | // point to private. | 
|  | 207 | if (!MakeShared("/", true /*recursive*/)) return false; | 
|  | 208 |  | 
| Jiyong Park | 7b4801a | 2019-02-25 16:41:38 +0900 | [diff] [blame] | 209 | // /apex is a private mountpoint to give different sets of APEXes for | 
| Jiyong Park | dcbaf9f | 2019-02-22 22:15:25 +0900 | [diff] [blame] | 210 | // the bootstrap and default mount namespaces. The processes running with | 
|  | 211 | // the bootstrap namespace get APEXes from the read-only partition. | 
|  | 212 | if (!(MakePrivate("/apex"))) return false; | 
|  | 213 |  | 
| Kiyoung Kim | 99df54b | 2019-11-22 16:14:10 +0900 | [diff] [blame] | 214 | // /linkerconfig is a private mountpoint to give a different linker configuration | 
|  | 215 | // based on the mount namespace. Subdirectory will be bind-mounted based on current mount | 
|  | 216 | // namespace | 
|  | 217 | if (!(MakePrivate("/linkerconfig"))) return false; | 
|  | 218 |  | 
| Martijn Coenen | c70c066 | 2020-01-10 15:42:15 +0100 | [diff] [blame] | 219 | // The two mount namespaces present challenges for scoped storage, because | 
|  | 220 | // vold, which is responsible for most of the mounting, lives in the | 
|  | 221 | // bootstrap mount namespace, whereas most other daemons and all apps live | 
|  | 222 | // in the default namespace.  Scoped storage has a need for a | 
|  | 223 | // /mnt/installer view that is a slave bind mount of /mnt/user - in other | 
|  | 224 | // words, all mounts under /mnt/user should automatically show up under | 
|  | 225 | // /mnt/installer. However, additional mounts done under /mnt/installer | 
|  | 226 | // should not propagate back to /mnt/user. In a single mount namespace | 
|  | 227 | // this is easy to achieve, by simply marking the /mnt/installer a slave | 
|  | 228 | // bind mount. Unfortunately, if /mnt/installer is only created and | 
|  | 229 | // bind mounted after the two namespaces are created below, we end up | 
|  | 230 | // with the following situation: | 
|  | 231 | // /mnt/user and /mnt/installer share the same peer group in both the | 
|  | 232 | // bootstrap and default namespaces. Marking /mnt/installer slave in either | 
|  | 233 | // namespace means that it won't propagate events to the /mnt/installer in | 
|  | 234 | // the other namespace, which is still something we require - vold is the | 
|  | 235 | // one doing the mounting under /mnt/installer, and those mounts should | 
|  | 236 | // show up in the default namespace as well. | 
|  | 237 | // | 
|  | 238 | // The simplest solution is to do the bind mount before the two namespaces | 
|  | 239 | // are created: the effect is that in both namespaces, /mnt/installer is a | 
|  | 240 | // slave to the /mnt/user mount, and at the same time /mnt/installer in the | 
|  | 241 | // bootstrap namespace shares a peer group with /mnt/installer in the | 
|  | 242 | // default namespace. | 
| Ricky Wai | a4c163d | 2020-04-21 12:16:43 +0100 | [diff] [blame] | 243 | // /mnt/androidwritable is similar to /mnt/installer but serves for | 
|  | 244 | // MOUNT_EXTERNAL_ANDROID_WRITABLE apps. | 
| Martijn Coenen | c70c066 | 2020-01-10 15:42:15 +0100 | [diff] [blame] | 245 | if (!mkdir_recursive("/mnt/user", 0755)) return false; | 
|  | 246 | if (!mkdir_recursive("/mnt/installer", 0755)) return false; | 
| Ricky Wai | a4c163d | 2020-04-21 12:16:43 +0100 | [diff] [blame] | 247 | if (!mkdir_recursive("/mnt/androidwritable", 0755)) return false; | 
| Martijn Coenen | c70c066 | 2020-01-10 15:42:15 +0100 | [diff] [blame] | 248 | if (!(BindMount("/mnt/user", "/mnt/installer", true))) return false; | 
| Ricky Wai | a4c163d | 2020-04-21 12:16:43 +0100 | [diff] [blame] | 249 | if (!(BindMount("/mnt/user", "/mnt/androidwritable", true))) return false; | 
|  | 250 | // First, make /mnt/installer and /mnt/androidwritable a slave bind mount | 
| Martijn Coenen | c70c066 | 2020-01-10 15:42:15 +0100 | [diff] [blame] | 251 | if (!(MakeSlave("/mnt/installer"))) return false; | 
| Ricky Wai | a4c163d | 2020-04-21 12:16:43 +0100 | [diff] [blame] | 252 | if (!(MakeSlave("/mnt/androidwritable"))) return false; | 
| Martijn Coenen | c70c066 | 2020-01-10 15:42:15 +0100 | [diff] [blame] | 253 | // Then, make it shared again - effectively creating a new peer group, that | 
|  | 254 | // will be inherited by new mount namespaces. | 
|  | 255 | if (!(MakeShared("/mnt/installer"))) return false; | 
| Ricky Wai | a4c163d | 2020-04-21 12:16:43 +0100 | [diff] [blame] | 256 | if (!(MakeShared("/mnt/androidwritable"))) return false; | 
| Martijn Coenen | c70c066 | 2020-01-10 15:42:15 +0100 | [diff] [blame] | 257 |  | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 258 | bootstrap_ns_fd.reset(OpenMountNamespace()); | 
|  | 259 | bootstrap_ns_id = GetMountNamespaceId(); | 
|  | 260 |  | 
| Jiyong Park | 7b4801a | 2019-02-25 16:41:38 +0900 | [diff] [blame] | 261 | // When APEXes are updatable (e.g. not-flattened), we create separate mount | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 262 | // namespaces for processes that are started before and after the APEX is | 
| Jiyong Park | 7b4801a | 2019-02-25 16:41:38 +0900 | [diff] [blame] | 263 | // activated by apexd. In the namespace for pre-apexd processes, small | 
|  | 264 | // number of essential APEXes (e.g. com.android.runtime) are activated. | 
|  | 265 | // In the namespace for post-apexd processes, all APEXes are activated. | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 266 | bool success = true; | 
| Jiyong Park | 8502ed3 | 2019-02-25 22:18:37 +0900 | [diff] [blame] | 267 | if (IsApexUpdatable() && !IsRecoveryMode()) { | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 268 | // Creating a new namespace by cloning, saving, and switching back to | 
|  | 269 | // the original namespace. | 
|  | 270 | if (unshare(CLONE_NEWNS) == -1) { | 
|  | 271 | PLOG(ERROR) << "Cannot create mount namespace"; | 
|  | 272 | return false; | 
|  | 273 | } | 
|  | 274 | default_ns_fd.reset(OpenMountNamespace()); | 
|  | 275 | default_ns_id = GetMountNamespaceId(); | 
|  | 276 |  | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 277 | if (setns(bootstrap_ns_fd.get(), CLONE_NEWNS) == -1) { | 
|  | 278 | PLOG(ERROR) << "Cannot switch back to bootstrap mount namespace"; | 
|  | 279 | return false; | 
|  | 280 | } | 
|  | 281 | } else { | 
|  | 282 | // Otherwise, default == bootstrap | 
|  | 283 | default_ns_fd.reset(OpenMountNamespace()); | 
|  | 284 | default_ns_id = GetMountNamespaceId(); | 
|  | 285 | } | 
|  | 286 |  | 
| Jiyong Park | d7f7c20 | 2019-05-10 21:12:15 +0900 | [diff] [blame] | 287 | success &= ActivateFlattenedApexesIfPossible(); | 
|  | 288 |  | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 289 | LOG(INFO) << "SetupMountNamespaces done"; | 
|  | 290 | return success; | 
|  | 291 | } | 
|  | 292 |  | 
|  | 293 | bool SwitchToDefaultMountNamespace() { | 
|  | 294 | if (IsRecoveryMode()) { | 
|  | 295 | // we don't have multiple namespaces in recovery mode | 
|  | 296 | return true; | 
|  | 297 | } | 
|  | 298 | if (default_ns_id != GetMountNamespaceId()) { | 
|  | 299 | if (setns(default_ns_fd.get(), CLONE_NEWNS) == -1) { | 
|  | 300 | PLOG(ERROR) << "Failed to switch back to the default mount namespace."; | 
|  | 301 | return false; | 
|  | 302 | } | 
| Kiyoung Kim | e4d3f21 | 2019-12-16 14:31:04 +0900 | [diff] [blame] | 303 |  | 
| Bernie Innocenti | cecebbb | 2020-02-06 03:49:33 +0900 | [diff] [blame] | 304 | if (auto result = MountLinkerConfigForDefaultNamespace(); !result.ok()) { | 
| Kiyoung Kim | e4d3f21 | 2019-12-16 14:31:04 +0900 | [diff] [blame] | 305 | LOG(ERROR) << result.error(); | 
|  | 306 | return false; | 
|  | 307 | } | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 308 | } | 
|  | 309 |  | 
| Jiyong Park | dcbaf9f | 2019-02-22 22:15:25 +0900 | [diff] [blame] | 310 | LOG(INFO) << "Switched to default mount namespace"; | 
|  | 311 | return true; | 
|  | 312 | } | 
|  | 313 |  | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 314 | bool SwitchToBootstrapMountNamespaceIfNeeded() { | 
|  | 315 | if (IsRecoveryMode()) { | 
|  | 316 | // we don't have multiple namespaces in recovery mode | 
|  | 317 | return true; | 
|  | 318 | } | 
|  | 319 | if (bootstrap_ns_id != GetMountNamespaceId() && bootstrap_ns_fd.get() != -1 && | 
| Jiyong Park | 8502ed3 | 2019-02-25 22:18:37 +0900 | [diff] [blame] | 320 | IsApexUpdatable()) { | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 321 | if (setns(bootstrap_ns_fd.get(), CLONE_NEWNS) == -1) { | 
|  | 322 | PLOG(ERROR) << "Failed to switch to bootstrap mount namespace."; | 
|  | 323 | return false; | 
|  | 324 | } | 
| Jiyong Park | 6866041 | 2019-01-16 23:00:59 +0900 | [diff] [blame] | 325 | } | 
|  | 326 | return true; | 
|  | 327 | } | 
|  | 328 |  | 
|  | 329 | }  // namespace init | 
|  | 330 | }  // namespace android |