Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 17 | #include "sehandle.h" |
| 18 | #include "Utils.h" |
| 19 | #include "Process.h" |
Keun-young Park | 375ac25 | 2017-08-02 17:45:48 -0700 | [diff] [blame] | 20 | #include "VolumeManager.h" |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 21 | |
Elliott Hughes | 7e128fb | 2015-12-04 15:50:53 -0800 | [diff] [blame] | 22 | #include <android-base/file.h> |
| 23 | #include <android-base/logging.h> |
Tom Cherry | d6127ef | 2017-06-15 17:13:56 -0700 | [diff] [blame] | 24 | #include <android-base/properties.h> |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 25 | #include <android-base/strings.h> |
Elliott Hughes | 7e128fb | 2015-12-04 15:50:53 -0800 | [diff] [blame] | 26 | #include <android-base/stringprintf.h> |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 27 | #include <cutils/fs.h> |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 28 | #include <logwrap/logwrap.h> |
Tom Cherry | d6127ef | 2017-06-15 17:13:56 -0700 | [diff] [blame] | 29 | #include <private/android_filesystem_config.h> |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 30 | |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 31 | #include <mutex> |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 32 | #include <dirent.h> |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 33 | #include <fcntl.h> |
| 34 | #include <linux/fs.h> |
| 35 | #include <stdlib.h> |
| 36 | #include <sys/mount.h> |
| 37 | #include <sys/types.h> |
| 38 | #include <sys/stat.h> |
Elliott Hughes | 0e08e84 | 2017-05-18 09:08:24 -0700 | [diff] [blame] | 39 | #include <sys/sysmacros.h> |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 40 | #include <sys/wait.h> |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 41 | #include <sys/statvfs.h> |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 42 | |
| 43 | #ifndef UMOUNT_NOFOLLOW |
| 44 | #define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */ |
| 45 | #endif |
| 46 | |
Jeff Sharkey | d0640f6 | 2015-05-21 22:35:42 -0700 | [diff] [blame] | 47 | using android::base::ReadFileToString; |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 48 | using android::base::StringPrintf; |
| 49 | |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 50 | namespace android { |
| 51 | namespace vold { |
| 52 | |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 53 | security_context_t sBlkidContext = nullptr; |
| 54 | security_context_t sBlkidUntrustedContext = nullptr; |
| 55 | security_context_t sFsckContext = nullptr; |
| 56 | security_context_t sFsckUntrustedContext = nullptr; |
| 57 | |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 58 | static const char* kBlkidPath = "/system/bin/blkid"; |
Jeff Sharkey | bc40cc8 | 2015-06-18 14:25:08 -0700 | [diff] [blame] | 59 | static const char* kKeyPath = "/data/misc/vold"; |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 60 | |
Jeff Sharkey | d0640f6 | 2015-05-21 22:35:42 -0700 | [diff] [blame] | 61 | static const char* kProcFilesystems = "/proc/filesystems"; |
| 62 | |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 63 | status_t CreateDeviceNode(const std::string& path, dev_t dev) { |
| 64 | const char* cpath = path.c_str(); |
| 65 | status_t res = 0; |
| 66 | |
| 67 | char* secontext = nullptr; |
| 68 | if (sehandle) { |
| 69 | if (!selabel_lookup(sehandle, &secontext, cpath, S_IFBLK)) { |
| 70 | setfscreatecon(secontext); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | mode_t mode = 0660 | S_IFBLK; |
| 75 | if (mknod(cpath, mode, dev) < 0) { |
| 76 | if (errno != EEXIST) { |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 77 | PLOG(ERROR) << "Failed to create device node for " << major(dev) |
| 78 | << ":" << minor(dev) << " at " << path; |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 79 | res = -errno; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | if (secontext) { |
| 84 | setfscreatecon(nullptr); |
| 85 | freecon(secontext); |
| 86 | } |
| 87 | |
| 88 | return res; |
| 89 | } |
| 90 | |
| 91 | status_t DestroyDeviceNode(const std::string& path) { |
| 92 | const char* cpath = path.c_str(); |
| 93 | if (TEMP_FAILURE_RETRY(unlink(cpath))) { |
| 94 | return -errno; |
| 95 | } else { |
| 96 | return OK; |
| 97 | } |
| 98 | } |
| 99 | |
Jeff Sharkey | f0121c5 | 2015-04-06 14:08:45 -0700 | [diff] [blame] | 100 | status_t PrepareDir(const std::string& path, mode_t mode, uid_t uid, gid_t gid) { |
| 101 | const char* cpath = path.c_str(); |
| 102 | |
| 103 | char* secontext = nullptr; |
| 104 | if (sehandle) { |
| 105 | if (!selabel_lookup(sehandle, &secontext, cpath, S_IFDIR)) { |
| 106 | setfscreatecon(secontext); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | int res = fs_prepare_dir(cpath, mode, uid, gid); |
| 111 | |
| 112 | if (secontext) { |
| 113 | setfscreatecon(nullptr); |
| 114 | freecon(secontext); |
| 115 | } |
| 116 | |
| 117 | if (res == 0) { |
| 118 | return OK; |
| 119 | } else { |
| 120 | return -errno; |
| 121 | } |
| 122 | } |
| 123 | |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 124 | status_t ForceUnmount(const std::string& path) { |
| 125 | const char* cpath = path.c_str(); |
| 126 | if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) { |
| 127 | return OK; |
| 128 | } |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 129 | // Apps might still be handling eject request, so wait before |
| 130 | // we start sending signals |
Keun-young Park | 375ac25 | 2017-08-02 17:45:48 -0700 | [diff] [blame] | 131 | if (!VolumeManager::shutting_down) sleep(5); |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 132 | |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 133 | KillProcessesWithOpenFiles(path, SIGINT); |
Keun-young Park | 375ac25 | 2017-08-02 17:45:48 -0700 | [diff] [blame] | 134 | if (!VolumeManager::shutting_down) sleep(5); |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 135 | if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) { |
| 136 | return OK; |
| 137 | } |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 138 | |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 139 | KillProcessesWithOpenFiles(path, SIGTERM); |
Keun-young Park | 375ac25 | 2017-08-02 17:45:48 -0700 | [diff] [blame] | 140 | if (!VolumeManager::shutting_down) sleep(5); |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 141 | if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) { |
| 142 | return OK; |
| 143 | } |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 144 | |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 145 | KillProcessesWithOpenFiles(path, SIGKILL); |
Keun-young Park | 375ac25 | 2017-08-02 17:45:48 -0700 | [diff] [blame] | 146 | if (!VolumeManager::shutting_down) sleep(5); |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 147 | if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) { |
| 148 | return OK; |
| 149 | } |
Jeff Sharkey | f0121c5 | 2015-04-06 14:08:45 -0700 | [diff] [blame] | 150 | |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 151 | return -errno; |
| 152 | } |
| 153 | |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 154 | status_t KillProcessesUsingPath(const std::string& path) { |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 155 | if (KillProcessesWithOpenFiles(path, SIGINT) == 0) { |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 156 | return OK; |
| 157 | } |
Keun-young Park | 375ac25 | 2017-08-02 17:45:48 -0700 | [diff] [blame] | 158 | if (!VolumeManager::shutting_down) sleep(5); |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 159 | |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 160 | if (KillProcessesWithOpenFiles(path, SIGTERM) == 0) { |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 161 | return OK; |
| 162 | } |
Keun-young Park | 375ac25 | 2017-08-02 17:45:48 -0700 | [diff] [blame] | 163 | if (!VolumeManager::shutting_down) sleep(5); |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 164 | |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 165 | if (KillProcessesWithOpenFiles(path, SIGKILL) == 0) { |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 166 | return OK; |
| 167 | } |
Keun-young Park | 375ac25 | 2017-08-02 17:45:48 -0700 | [diff] [blame] | 168 | if (!VolumeManager::shutting_down) sleep(5); |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 169 | |
| 170 | // Send SIGKILL a second time to determine if we've |
| 171 | // actually killed everyone with open files |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 172 | if (KillProcessesWithOpenFiles(path, SIGKILL) == 0) { |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 173 | return OK; |
| 174 | } |
| 175 | PLOG(ERROR) << "Failed to kill processes using " << path; |
| 176 | return -EBUSY; |
| 177 | } |
| 178 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 179 | status_t BindMount(const std::string& source, const std::string& target) { |
| 180 | if (::mount(source.c_str(), target.c_str(), "", MS_BIND, NULL)) { |
| 181 | PLOG(ERROR) << "Failed to bind mount " << source << " to " << target; |
| 182 | return -errno; |
| 183 | } |
| 184 | return OK; |
| 185 | } |
| 186 | |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 187 | bool FindValue(const std::string& raw, const std::string& key, std::string* value) { |
| 188 | auto qual = key + "=\""; |
| 189 | auto start = raw.find(qual); |
| 190 | if (start > 0 && raw[start - 1] != ' ') { |
| 191 | start = raw.find(qual, start + 1); |
| 192 | } |
| 193 | |
| 194 | if (start == std::string::npos) return false; |
| 195 | start += qual.length(); |
| 196 | |
| 197 | auto end = raw.find("\"", start); |
| 198 | if (end == std::string::npos) return false; |
| 199 | |
| 200 | *value = raw.substr(start, end - start); |
| 201 | return true; |
| 202 | } |
| 203 | |
| 204 | static status_t readMetadata(const std::string& path, std::string* fsType, |
| 205 | std::string* fsUuid, std::string* fsLabel, bool untrusted) { |
| 206 | fsType->clear(); |
| 207 | fsUuid->clear(); |
| 208 | fsLabel->clear(); |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 209 | |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 210 | std::vector<std::string> cmd; |
| 211 | cmd.push_back(kBlkidPath); |
| 212 | cmd.push_back("-c"); |
| 213 | cmd.push_back("/dev/null"); |
Jeff Sharkey | eddf9bd | 2015-08-12 16:04:35 -0700 | [diff] [blame] | 214 | cmd.push_back("-s"); |
| 215 | cmd.push_back("TYPE"); |
| 216 | cmd.push_back("-s"); |
| 217 | cmd.push_back("UUID"); |
| 218 | cmd.push_back("-s"); |
| 219 | cmd.push_back("LABEL"); |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 220 | cmd.push_back(path); |
| 221 | |
| 222 | std::vector<std::string> output; |
| 223 | status_t res = ForkExecvp(cmd, output, untrusted ? sBlkidUntrustedContext : sBlkidContext); |
| 224 | if (res != OK) { |
| 225 | LOG(WARNING) << "blkid failed to identify " << path; |
| 226 | return res; |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Chih-Hung Hsieh | 11a2ce8 | 2016-07-27 14:11:02 -0700 | [diff] [blame] | 229 | for (const auto& line : output) { |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 230 | // Extract values from blkid output, if defined |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 231 | FindValue(line, "TYPE", fsType); |
| 232 | FindValue(line, "UUID", fsUuid); |
| 233 | FindValue(line, "LABEL", fsLabel); |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 234 | } |
| 235 | |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 236 | return OK; |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 239 | status_t ReadMetadata(const std::string& path, std::string* fsType, |
| 240 | std::string* fsUuid, std::string* fsLabel) { |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 241 | return readMetadata(path, fsType, fsUuid, fsLabel, false); |
| 242 | } |
| 243 | |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 244 | status_t ReadMetadataUntrusted(const std::string& path, std::string* fsType, |
| 245 | std::string* fsUuid, std::string* fsLabel) { |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 246 | return readMetadata(path, fsType, fsUuid, fsLabel, true); |
| 247 | } |
| 248 | |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 249 | status_t ForkExecvp(const std::vector<std::string>& args) { |
| 250 | return ForkExecvp(args, nullptr); |
| 251 | } |
| 252 | |
| 253 | status_t ForkExecvp(const std::vector<std::string>& args, security_context_t context) { |
| 254 | size_t argc = args.size(); |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 255 | char** argv = (char**) calloc(argc, sizeof(char*)); |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 256 | for (size_t i = 0; i < argc; i++) { |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 257 | argv[i] = (char*) args[i].c_str(); |
| 258 | if (i == 0) { |
| 259 | LOG(VERBOSE) << args[i]; |
| 260 | } else { |
| 261 | LOG(VERBOSE) << " " << args[i]; |
| 262 | } |
| 263 | } |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 264 | |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 265 | if (setexeccon(context)) { |
| 266 | LOG(ERROR) << "Failed to setexeccon"; |
| 267 | abort(); |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 268 | } |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 269 | status_t res = android_fork_execvp(argc, argv, NULL, false, true); |
| 270 | if (setexeccon(nullptr)) { |
| 271 | LOG(ERROR) << "Failed to setexeccon"; |
| 272 | abort(); |
| 273 | } |
| 274 | |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 275 | free(argv); |
| 276 | return res; |
| 277 | } |
| 278 | |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 279 | status_t ForkExecvp(const std::vector<std::string>& args, |
| 280 | std::vector<std::string>& output) { |
| 281 | return ForkExecvp(args, output, nullptr); |
| 282 | } |
| 283 | |
| 284 | status_t ForkExecvp(const std::vector<std::string>& args, |
| 285 | std::vector<std::string>& output, security_context_t context) { |
| 286 | std::string cmd; |
| 287 | for (size_t i = 0; i < args.size(); i++) { |
| 288 | cmd += args[i] + " "; |
| 289 | if (i == 0) { |
| 290 | LOG(VERBOSE) << args[i]; |
| 291 | } else { |
| 292 | LOG(VERBOSE) << " " << args[i]; |
| 293 | } |
| 294 | } |
| 295 | output.clear(); |
| 296 | |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 297 | if (setexeccon(context)) { |
| 298 | LOG(ERROR) << "Failed to setexeccon"; |
| 299 | abort(); |
| 300 | } |
Jeff Sharkey | 32ebb73 | 2017-03-27 16:18:50 -0600 | [diff] [blame] | 301 | FILE* fp = popen(cmd.c_str(), "r"); // NOLINT |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 302 | if (setexeccon(nullptr)) { |
| 303 | LOG(ERROR) << "Failed to setexeccon"; |
| 304 | abort(); |
Jeff Sharkey | ce6a913 | 2015-04-08 21:07:21 -0700 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | if (!fp) { |
| 308 | PLOG(ERROR) << "Failed to popen " << cmd; |
| 309 | return -errno; |
| 310 | } |
| 311 | char line[1024]; |
| 312 | while (fgets(line, sizeof(line), fp) != nullptr) { |
| 313 | LOG(VERBOSE) << line; |
| 314 | output.push_back(std::string(line)); |
| 315 | } |
| 316 | if (pclose(fp) != 0) { |
| 317 | PLOG(ERROR) << "Failed to pclose " << cmd; |
| 318 | return -errno; |
| 319 | } |
| 320 | |
| 321 | return OK; |
| 322 | } |
| 323 | |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 324 | pid_t ForkExecvpAsync(const std::vector<std::string>& args) { |
| 325 | size_t argc = args.size(); |
| 326 | char** argv = (char**) calloc(argc + 1, sizeof(char*)); |
| 327 | for (size_t i = 0; i < argc; i++) { |
| 328 | argv[i] = (char*) args[i].c_str(); |
| 329 | if (i == 0) { |
| 330 | LOG(VERBOSE) << args[i]; |
| 331 | } else { |
| 332 | LOG(VERBOSE) << " " << args[i]; |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | pid_t pid = fork(); |
| 337 | if (pid == 0) { |
| 338 | close(STDIN_FILENO); |
| 339 | close(STDOUT_FILENO); |
| 340 | close(STDERR_FILENO); |
| 341 | |
| 342 | if (execvp(argv[0], argv)) { |
| 343 | PLOG(ERROR) << "Failed to exec"; |
| 344 | } |
| 345 | |
| 346 | _exit(1); |
| 347 | } |
| 348 | |
| 349 | if (pid == -1) { |
| 350 | PLOG(ERROR) << "Failed to exec"; |
| 351 | } |
| 352 | |
| 353 | free(argv); |
| 354 | return pid; |
| 355 | } |
| 356 | |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 357 | status_t ReadRandomBytes(size_t bytes, std::string& out) { |
Pavel Grafov | e2e2d30 | 2017-08-01 17:15:53 +0100 | [diff] [blame] | 358 | out.resize(bytes); |
| 359 | return ReadRandomBytes(bytes, &out[0]); |
| 360 | } |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 361 | |
Pavel Grafov | e2e2d30 | 2017-08-01 17:15:53 +0100 | [diff] [blame] | 362 | status_t ReadRandomBytes(size_t bytes, char* buf) { |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 363 | int fd = TEMP_FAILURE_RETRY(open("/dev/urandom", O_RDONLY | O_CLOEXEC | O_NOFOLLOW)); |
| 364 | if (fd == -1) { |
| 365 | return -errno; |
| 366 | } |
| 367 | |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 368 | size_t n; |
Pavel Grafov | e2e2d30 | 2017-08-01 17:15:53 +0100 | [diff] [blame] | 369 | while ((n = TEMP_FAILURE_RETRY(read(fd, &buf[0], bytes))) > 0) { |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 370 | bytes -= n; |
Pavel Grafov | e2e2d30 | 2017-08-01 17:15:53 +0100 | [diff] [blame] | 371 | buf += n; |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 372 | } |
Elliott Hughes | a623108 | 2015-05-15 18:34:24 -0700 | [diff] [blame] | 373 | close(fd); |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 374 | |
| 375 | if (bytes == 0) { |
| 376 | return OK; |
| 377 | } else { |
| 378 | return -EIO; |
| 379 | } |
| 380 | } |
| 381 | |
Jeff Sharkey | 46bb69f | 2017-06-21 13:52:23 -0600 | [diff] [blame] | 382 | status_t GenerateRandomUuid(std::string& out) { |
| 383 | status_t res = ReadRandomBytes(16, out); |
| 384 | if (res == OK) { |
| 385 | out[6] &= 0x0f; /* clear version */ |
| 386 | out[6] |= 0x40; /* set to version 4 */ |
| 387 | out[8] &= 0x3f; /* clear variant */ |
| 388 | out[8] |= 0x80; /* set to IETF variant */ |
| 389 | } |
| 390 | return res; |
| 391 | } |
| 392 | |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 393 | status_t HexToStr(const std::string& hex, std::string& str) { |
| 394 | str.clear(); |
| 395 | bool even = true; |
| 396 | char cur = 0; |
| 397 | for (size_t i = 0; i < hex.size(); i++) { |
| 398 | int val = 0; |
| 399 | switch (hex[i]) { |
| 400 | case ' ': case '-': case ':': continue; |
| 401 | case 'f': case 'F': val = 15; break; |
| 402 | case 'e': case 'E': val = 14; break; |
| 403 | case 'd': case 'D': val = 13; break; |
| 404 | case 'c': case 'C': val = 12; break; |
| 405 | case 'b': case 'B': val = 11; break; |
| 406 | case 'a': case 'A': val = 10; break; |
| 407 | case '9': val = 9; break; |
| 408 | case '8': val = 8; break; |
| 409 | case '7': val = 7; break; |
| 410 | case '6': val = 6; break; |
| 411 | case '5': val = 5; break; |
| 412 | case '4': val = 4; break; |
| 413 | case '3': val = 3; break; |
| 414 | case '2': val = 2; break; |
| 415 | case '1': val = 1; break; |
| 416 | case '0': val = 0; break; |
| 417 | default: return -EINVAL; |
| 418 | } |
| 419 | |
| 420 | if (even) { |
| 421 | cur = val << 4; |
| 422 | } else { |
| 423 | cur += val; |
| 424 | str.push_back(cur); |
| 425 | cur = 0; |
| 426 | } |
| 427 | even = !even; |
| 428 | } |
| 429 | return even ? OK : -EINVAL; |
| 430 | } |
| 431 | |
| 432 | static const char* kLookup = "0123456789abcdef"; |
| 433 | |
| 434 | status_t StrToHex(const std::string& str, std::string& hex) { |
| 435 | hex.clear(); |
| 436 | for (size_t i = 0; i < str.size(); i++) { |
Jeff Sharkey | ef36975 | 2015-04-29 15:57:48 -0700 | [diff] [blame] | 437 | hex.push_back(kLookup[(str[i] & 0xF0) >> 4]); |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 438 | hex.push_back(kLookup[str[i] & 0x0F]); |
| 439 | } |
| 440 | return OK; |
| 441 | } |
| 442 | |
Pavel Grafov | e2e2d30 | 2017-08-01 17:15:53 +0100 | [diff] [blame] | 443 | status_t StrToHex(const KeyBuffer& str, KeyBuffer& hex) { |
| 444 | hex.clear(); |
| 445 | for (size_t i = 0; i < str.size(); i++) { |
| 446 | hex.push_back(kLookup[(str.data()[i] & 0xF0) >> 4]); |
| 447 | hex.push_back(kLookup[str.data()[i] & 0x0F]); |
| 448 | } |
| 449 | return OK; |
| 450 | } |
| 451 | |
Jeff Sharkey | bc40cc8 | 2015-06-18 14:25:08 -0700 | [diff] [blame] | 452 | status_t NormalizeHex(const std::string& in, std::string& out) { |
| 453 | std::string tmp; |
| 454 | if (HexToStr(in, tmp)) { |
| 455 | return -EINVAL; |
| 456 | } |
| 457 | return StrToHex(tmp, out); |
| 458 | } |
| 459 | |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 460 | uint64_t GetFreeBytes(const std::string& path) { |
| 461 | struct statvfs sb; |
| 462 | if (statvfs(path.c_str(), &sb) == 0) { |
Jeff Sharkey | a0220a5 | 2017-04-03 17:11:45 -0600 | [diff] [blame] | 463 | return (uint64_t) sb.f_bavail * sb.f_frsize; |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 464 | } else { |
| 465 | return -1; |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | // TODO: borrowed from frameworks/native/libs/diskusage/ which should |
| 470 | // eventually be migrated into system/ |
| 471 | static int64_t stat_size(struct stat *s) { |
| 472 | int64_t blksize = s->st_blksize; |
| 473 | // count actual blocks used instead of nominal file size |
| 474 | int64_t size = s->st_blocks * 512; |
| 475 | |
| 476 | if (blksize) { |
| 477 | /* round up to filesystem block size */ |
| 478 | size = (size + blksize - 1) & (~(blksize - 1)); |
| 479 | } |
| 480 | |
| 481 | return size; |
| 482 | } |
| 483 | |
| 484 | // TODO: borrowed from frameworks/native/libs/diskusage/ which should |
| 485 | // eventually be migrated into system/ |
| 486 | int64_t calculate_dir_size(int dfd) { |
| 487 | int64_t size = 0; |
| 488 | struct stat s; |
| 489 | DIR *d; |
| 490 | struct dirent *de; |
| 491 | |
| 492 | d = fdopendir(dfd); |
| 493 | if (d == NULL) { |
| 494 | close(dfd); |
| 495 | return 0; |
| 496 | } |
| 497 | |
| 498 | while ((de = readdir(d))) { |
| 499 | const char *name = de->d_name; |
| 500 | if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) { |
| 501 | size += stat_size(&s); |
| 502 | } |
| 503 | if (de->d_type == DT_DIR) { |
| 504 | int subfd; |
| 505 | |
| 506 | /* always skip "." and ".." */ |
| 507 | if (name[0] == '.') { |
| 508 | if (name[1] == 0) |
| 509 | continue; |
| 510 | if ((name[1] == '.') && (name[2] == 0)) |
| 511 | continue; |
| 512 | } |
| 513 | |
Jeff Sharkey | fd3dc3c | 2017-03-27 10:49:21 -0600 | [diff] [blame] | 514 | subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY | O_CLOEXEC); |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 515 | if (subfd >= 0) { |
| 516 | size += calculate_dir_size(subfd); |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | closedir(d); |
| 521 | return size; |
| 522 | } |
| 523 | |
| 524 | uint64_t GetTreeBytes(const std::string& path) { |
Jeff Sharkey | fd3dc3c | 2017-03-27 10:49:21 -0600 | [diff] [blame] | 525 | int dirfd = open(path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC); |
Jeff Sharkey | 1d6fbcc | 2015-04-24 16:00:03 -0700 | [diff] [blame] | 526 | if (dirfd < 0) { |
| 527 | PLOG(WARNING) << "Failed to open " << path; |
| 528 | return -1; |
| 529 | } else { |
| 530 | uint64_t res = calculate_dir_size(dirfd); |
| 531 | close(dirfd); |
| 532 | return res; |
| 533 | } |
| 534 | } |
| 535 | |
Jeff Sharkey | d0640f6 | 2015-05-21 22:35:42 -0700 | [diff] [blame] | 536 | bool IsFilesystemSupported(const std::string& fsType) { |
| 537 | std::string supported; |
| 538 | if (!ReadFileToString(kProcFilesystems, &supported)) { |
| 539 | PLOG(ERROR) << "Failed to read supported filesystems"; |
| 540 | return false; |
| 541 | } |
| 542 | return supported.find(fsType + "\n") != std::string::npos; |
| 543 | } |
| 544 | |
| 545 | status_t WipeBlockDevice(const std::string& path) { |
| 546 | status_t res = -1; |
| 547 | const char* c_path = path.c_str(); |
| 548 | unsigned long nr_sec = 0; |
| 549 | unsigned long long range[2]; |
| 550 | |
| 551 | int fd = TEMP_FAILURE_RETRY(open(c_path, O_RDWR | O_CLOEXEC)); |
| 552 | if (fd == -1) { |
| 553 | PLOG(ERROR) << "Failed to open " << path; |
| 554 | goto done; |
| 555 | } |
| 556 | |
caozhiyuan | 9102b0b | 2015-10-29 16:39:00 +0800 | [diff] [blame] | 557 | if ((ioctl(fd, BLKGETSIZE, &nr_sec)) == -1) { |
Jeff Sharkey | d0640f6 | 2015-05-21 22:35:42 -0700 | [diff] [blame] | 558 | PLOG(ERROR) << "Failed to determine size of " << path; |
| 559 | goto done; |
| 560 | } |
| 561 | |
| 562 | range[0] = 0; |
| 563 | range[1] = (unsigned long long) nr_sec * 512; |
| 564 | |
| 565 | LOG(INFO) << "About to discard " << range[1] << " on " << path; |
| 566 | if (ioctl(fd, BLKDISCARD, &range) == 0) { |
| 567 | LOG(INFO) << "Discard success on " << path; |
| 568 | res = 0; |
| 569 | } else { |
| 570 | PLOG(ERROR) << "Discard failure on " << path; |
| 571 | } |
| 572 | |
| 573 | done: |
| 574 | close(fd); |
| 575 | return res; |
| 576 | } |
| 577 | |
Jeff Sharkey | d2c96e7 | 2015-11-08 17:56:23 -0800 | [diff] [blame] | 578 | static bool isValidFilename(const std::string& name) { |
| 579 | if (name.empty() || (name == ".") || (name == "..") |
| 580 | || (name.find('/') != std::string::npos)) { |
| 581 | return false; |
| 582 | } else { |
| 583 | return true; |
| 584 | } |
| 585 | } |
| 586 | |
Jeff Sharkey | bc40cc8 | 2015-06-18 14:25:08 -0700 | [diff] [blame] | 587 | std::string BuildKeyPath(const std::string& partGuid) { |
| 588 | return StringPrintf("%s/expand_%s.key", kKeyPath, partGuid.c_str()); |
| 589 | } |
| 590 | |
Jeff Sharkey | be70c9a | 2016-04-14 20:45:16 -0600 | [diff] [blame] | 591 | std::string BuildDataSystemLegacyPath(userid_t userId) { |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 592 | return StringPrintf("%s/system/users/%u", BuildDataPath("").c_str(), userId); |
Jeff Sharkey | be70c9a | 2016-04-14 20:45:16 -0600 | [diff] [blame] | 593 | } |
| 594 | |
Jeff Sharkey | d2c96e7 | 2015-11-08 17:56:23 -0800 | [diff] [blame] | 595 | std::string BuildDataSystemCePath(userid_t userId) { |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 596 | return StringPrintf("%s/system_ce/%u", BuildDataPath("").c_str(), userId); |
Jeff Sharkey | 47695b2 | 2016-02-01 17:02:29 -0700 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | std::string BuildDataSystemDePath(userid_t userId) { |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 600 | return StringPrintf("%s/system_de/%u", BuildDataPath("").c_str(), userId); |
Jeff Sharkey | 47695b2 | 2016-02-01 17:02:29 -0700 | [diff] [blame] | 601 | } |
| 602 | |
Jeff Sharkey | be70c9a | 2016-04-14 20:45:16 -0600 | [diff] [blame] | 603 | std::string BuildDataMiscLegacyPath(userid_t userId) { |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 604 | return StringPrintf("%s/misc/user/%u", BuildDataPath("").c_str(), userId); |
Jeff Sharkey | be70c9a | 2016-04-14 20:45:16 -0600 | [diff] [blame] | 605 | } |
| 606 | |
Jeff Sharkey | 47695b2 | 2016-02-01 17:02:29 -0700 | [diff] [blame] | 607 | std::string BuildDataMiscCePath(userid_t userId) { |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 608 | return StringPrintf("%s/misc_ce/%u", BuildDataPath("").c_str(), userId); |
Jeff Sharkey | 47695b2 | 2016-02-01 17:02:29 -0700 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | std::string BuildDataMiscDePath(userid_t userId) { |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 612 | return StringPrintf("%s/misc_de/%u", BuildDataPath("").c_str(), userId); |
Jeff Sharkey | d2c96e7 | 2015-11-08 17:56:23 -0800 | [diff] [blame] | 613 | } |
| 614 | |
Calin Juravle | 79f55a4 | 2016-02-17 20:14:46 +0000 | [diff] [blame] | 615 | // Keep in sync with installd (frameworks/native/cmds/installd/utils.h) |
| 616 | std::string BuildDataProfilesDePath(userid_t userId) { |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 617 | return StringPrintf("%s/misc/profiles/cur/%u", BuildDataPath("").c_str(), userId); |
Calin Juravle | 79f55a4 | 2016-02-17 20:14:46 +0000 | [diff] [blame] | 618 | } |
| 619 | |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 620 | std::string BuildDataPath(const std::string& volumeUuid) { |
Jeff Sharkey | d2c96e7 | 2015-11-08 17:56:23 -0800 | [diff] [blame] | 621 | // TODO: unify with installd path generation logic |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 622 | if (volumeUuid.empty()) { |
Jeff Sharkey | d2c96e7 | 2015-11-08 17:56:23 -0800 | [diff] [blame] | 623 | return "/data"; |
| 624 | } else { |
| 625 | CHECK(isValidFilename(volumeUuid)); |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 626 | return StringPrintf("/mnt/expand/%s", volumeUuid.c_str()); |
Jeff Sharkey | d2c96e7 | 2015-11-08 17:56:23 -0800 | [diff] [blame] | 627 | } |
| 628 | } |
| 629 | |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 630 | std::string BuildDataMediaCePath(const std::string& volumeUuid, userid_t userId) { |
Jeff Sharkey | fc505c3 | 2015-12-07 17:27:01 -0700 | [diff] [blame] | 631 | // TODO: unify with installd path generation logic |
| 632 | std::string data(BuildDataPath(volumeUuid)); |
| 633 | return StringPrintf("%s/media/%u", data.c_str(), userId); |
| 634 | } |
| 635 | |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 636 | std::string BuildDataUserCePath(const std::string& volumeUuid, userid_t userId) { |
Jeff Sharkey | d2c96e7 | 2015-11-08 17:56:23 -0800 | [diff] [blame] | 637 | // TODO: unify with installd path generation logic |
| 638 | std::string data(BuildDataPath(volumeUuid)); |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 639 | if (volumeUuid.empty() && userId == 0) { |
cjbao | eb50114 | 2017-04-12 00:09:00 +0800 | [diff] [blame] | 640 | std::string legacy = StringPrintf("%s/data", data.c_str()); |
| 641 | struct stat sb; |
| 642 | if (lstat(legacy.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) { |
| 643 | /* /data/data is dir, return /data/data for legacy system */ |
| 644 | return legacy; |
Jeff Sharkey | d2c96e7 | 2015-11-08 17:56:23 -0800 | [diff] [blame] | 645 | } |
Jeff Sharkey | d2c96e7 | 2015-11-08 17:56:23 -0800 | [diff] [blame] | 646 | } |
cjbao | eb50114 | 2017-04-12 00:09:00 +0800 | [diff] [blame] | 647 | return StringPrintf("%s/user/%u", data.c_str(), userId); |
Jeff Sharkey | d2c96e7 | 2015-11-08 17:56:23 -0800 | [diff] [blame] | 648 | } |
| 649 | |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 650 | std::string BuildDataUserDePath(const std::string& volumeUuid, userid_t userId) { |
Jeff Sharkey | d2c96e7 | 2015-11-08 17:56:23 -0800 | [diff] [blame] | 651 | // TODO: unify with installd path generation logic |
| 652 | std::string data(BuildDataPath(volumeUuid)); |
| 653 | return StringPrintf("%s/user_de/%u", data.c_str(), userId); |
| 654 | } |
| 655 | |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 656 | dev_t GetDevice(const std::string& path) { |
| 657 | struct stat sb; |
| 658 | if (stat(path.c_str(), &sb)) { |
| 659 | PLOG(WARNING) << "Failed to stat " << path; |
| 660 | return 0; |
| 661 | } else { |
| 662 | return sb.st_dev; |
| 663 | } |
| 664 | } |
| 665 | |
Jeff Sharkey | d24aeda | 2016-07-15 16:20:22 -0600 | [diff] [blame] | 666 | status_t RestoreconRecursive(const std::string& path) { |
| 667 | LOG(VERBOSE) << "Starting restorecon of " << path; |
| 668 | |
Tom Cherry | d6127ef | 2017-06-15 17:13:56 -0700 | [diff] [blame] | 669 | static constexpr const char* kRestoreconString = "selinux.restorecon_recursive"; |
Jeff Sharkey | d24aeda | 2016-07-15 16:20:22 -0600 | [diff] [blame] | 670 | |
Tom Cherry | d6127ef | 2017-06-15 17:13:56 -0700 | [diff] [blame] | 671 | android::base::SetProperty(kRestoreconString, ""); |
| 672 | android::base::SetProperty(kRestoreconString, path); |
| 673 | |
| 674 | android::base::WaitForProperty(kRestoreconString, path); |
Jeff Sharkey | d24aeda | 2016-07-15 16:20:22 -0600 | [diff] [blame] | 675 | |
| 676 | LOG(VERBOSE) << "Finished restorecon of " << path; |
| 677 | return OK; |
| 678 | } |
| 679 | |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 680 | bool Readlinkat(int dirfd, const std::string& path, std::string* result) { |
| 681 | // Shamelessly borrowed from android::base::Readlink() |
| 682 | result->clear(); |
| 683 | |
| 684 | // Most Linux file systems (ext2 and ext4, say) limit symbolic links to |
| 685 | // 4095 bytes. Since we'll copy out into the string anyway, it doesn't |
| 686 | // waste memory to just start there. We add 1 so that we can recognize |
| 687 | // whether it actually fit (rather than being truncated to 4095). |
| 688 | std::vector<char> buf(4095 + 1); |
| 689 | while (true) { |
| 690 | ssize_t size = readlinkat(dirfd, path.c_str(), &buf[0], buf.size()); |
| 691 | // Unrecoverable error? |
| 692 | if (size == -1) |
| 693 | return false; |
| 694 | // It fit! (If size == buf.size(), it may have been truncated.) |
| 695 | if (static_cast<size_t>(size) < buf.size()) { |
| 696 | result->assign(&buf[0], size); |
| 697 | return true; |
| 698 | } |
| 699 | // Double our buffer and try again. |
| 700 | buf.resize(buf.size() * 2); |
Daichi Hirono | 10d3488 | 2016-01-29 14:33:51 +0900 | [diff] [blame] | 701 | } |
| 702 | } |
| 703 | |
Yu Ning | 942d4e8 | 2016-01-08 17:36:47 +0800 | [diff] [blame] | 704 | bool IsRunningInEmulator() { |
Tom Cherry | d6127ef | 2017-06-15 17:13:56 -0700 | [diff] [blame] | 705 | return android::base::GetBoolProperty("ro.kernel.qemu", false); |
Yu Ning | 942d4e8 | 2016-01-08 17:36:47 +0800 | [diff] [blame] | 706 | } |
| 707 | |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 708 | } // namespace vold |
| 709 | } // namespace android |