San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 17 | #define ATRACE_TAG ATRACE_TAG_PACKAGE_MANAGER |
| 18 | |
Jeff Sharkey | 9f18fe7 | 2015-04-01 23:32:18 -0700 | [diff] [blame] | 19 | #include "NetlinkManager.h" |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 20 | #include "VoldNativeService.h" |
Paul Crowley | e2ee152 | 2017-09-26 14:05:26 -0700 | [diff] [blame] | 21 | #include "VoldUtil.h" |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 22 | #include "VolumeManager.h" |
Jeff Sharkey | 9f18fe7 | 2015-04-01 23:32:18 -0700 | [diff] [blame] | 23 | #include "cryptfs.h" |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 24 | #include "model/Disk.h" |
Jeff Sharkey | 9f18fe7 | 2015-04-01 23:32:18 -0700 | [diff] [blame] | 25 | #include "sehandle.h" |
| 26 | |
Elliott Hughes | 7e128fb | 2015-12-04 15:50:53 -0800 | [diff] [blame] | 27 | #include <android-base/logging.h> |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 28 | #include <android-base/properties.h> |
Elliott Hughes | 7e128fb | 2015-12-04 15:50:53 -0800 | [diff] [blame] | 29 | #include <android-base/stringprintf.h> |
Jeff Sharkey | 9f18fe7 | 2015-04-01 23:32:18 -0700 | [diff] [blame] | 30 | #include <cutils/klog.h> |
Yifan Hong | 024a124 | 2018-08-10 13:50:46 -0700 | [diff] [blame] | 31 | #include <hidl/HidlTransportSupport.h> |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 32 | #include <utils/Trace.h> |
Jeff Sharkey | 9f18fe7 | 2015-04-01 23:32:18 -0700 | [diff] [blame] | 33 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 34 | #include <dirent.h> |
| 35 | #include <errno.h> |
| 36 | #include <fcntl.h> |
| 37 | #include <fs_mgr.h> |
| 38 | #include <getopt.h> |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 39 | #include <stdio.h> |
| 40 | #include <stdlib.h> |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 41 | #include <string.h> |
San Mehat | 3578c41 | 2009-10-12 14:51:52 -0700 | [diff] [blame] | 42 | #include <sys/stat.h> |
| 43 | #include <sys/types.h> |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 44 | |
Jeff Sharkey | 53d5d7c | 2018-01-08 10:43:00 -0700 | [diff] [blame] | 45 | static int process_config(VolumeManager* vm, bool* has_adoptable, bool* has_quota, |
| 46 | bool* has_reserved); |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 47 | static void coldboot(const char* path); |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 48 | static void parse_args(int argc, char** argv); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 49 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 50 | struct selabel_handle* sehandle; |
Stephen Smalley | 684e662 | 2014-09-30 10:29:24 -0400 | [diff] [blame] | 51 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 52 | using android::base::StringPrintf; |
Tom Cherry | 4c5bde2 | 2019-01-29 14:34:01 -0800 | [diff] [blame] | 53 | using android::fs_mgr::ReadDefaultFstab; |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 54 | |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 55 | int main(int argc, char** argv) { |
Paul Crowley | 0fd2626 | 2018-01-30 09:48:19 -0800 | [diff] [blame] | 56 | atrace_set_tracing_enabled(false); |
Sudheer Shanka | 40ab674 | 2018-09-18 13:07:45 -0700 | [diff] [blame] | 57 | setenv("ANDROID_LOG_TAGS", "*:d", 1); // Do not submit with verbose logs enabled |
Jeff Sharkey | 5bad378 | 2015-04-18 16:15:10 -0700 | [diff] [blame] | 58 | android::base::InitLogging(argv, android::base::LogdLogger(android::base::SYSTEM)); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 59 | |
Paul Crowley | 0fd2626 | 2018-01-30 09:48:19 -0800 | [diff] [blame] | 60 | LOG(INFO) << "Vold 3.0 (the awakening) firing up"; |
| 61 | |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 62 | ATRACE_BEGIN("main"); |
| 63 | |
Sudheer Shanka | 4b6ca4e | 2018-09-21 10:54:54 -0700 | [diff] [blame] | 64 | LOG(DEBUG) << "Detected support for:" |
| 65 | << (android::vold::IsFilesystemSupported("ext4") ? " ext4" : "") |
| 66 | << (android::vold::IsFilesystemSupported("f2fs") ? " f2fs" : "") |
| 67 | << (android::vold::IsFilesystemSupported("vfat") ? " vfat" : ""); |
Jeff Sharkey | d0640f6 | 2015-05-21 22:35:42 -0700 | [diff] [blame] | 68 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 69 | VolumeManager* vm; |
| 70 | NetlinkManager* nm; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 71 | |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 72 | parse_args(argc, argv); |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 73 | |
Stephen Smalley | 684e662 | 2014-09-30 10:29:24 -0400 | [diff] [blame] | 74 | sehandle = selinux_android_file_context_handle(); |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 75 | if (sehandle) { |
Stephen Smalley | 684e662 | 2014-09-30 10:29:24 -0400 | [diff] [blame] | 76 | selinux_android_set_sehandle(sehandle); |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 77 | } |
Stephen Smalley | 684e662 | 2014-09-30 10:29:24 -0400 | [diff] [blame] | 78 | |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 79 | mkdir("/dev/block/vold", 0755); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 80 | |
Ken Sumrall | b9738ea | 2013-03-19 19:42:30 -0700 | [diff] [blame] | 81 | /* For when cryptfs checks and mounts an encrypted filesystem */ |
| 82 | klog_set_level(6); |
| 83 | |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 84 | /* Create our singleton managers */ |
| 85 | if (!(vm = VolumeManager::Instance())) { |
Jeff Sharkey | 9f18fe7 | 2015-04-01 23:32:18 -0700 | [diff] [blame] | 86 | LOG(ERROR) << "Unable to create VolumeManager"; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 87 | exit(1); |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 88 | } |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 89 | |
| 90 | if (!(nm = NetlinkManager::Instance())) { |
Jeff Sharkey | 9f18fe7 | 2015-04-01 23:32:18 -0700 | [diff] [blame] | 91 | LOG(ERROR) << "Unable to create NetlinkManager"; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 92 | exit(1); |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 93 | } |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 94 | |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 95 | if (android::base::GetBoolProperty("vold.debug", false)) { |
Jeff Sharkey | b066787 | 2015-04-29 08:57:18 -0700 | [diff] [blame] | 96 | vm->setDebug(true); |
| 97 | } |
| 98 | |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 99 | if (vm->start()) { |
Jeff Sharkey | 9f18fe7 | 2015-04-01 23:32:18 -0700 | [diff] [blame] | 100 | PLOG(ERROR) << "Unable to start VolumeManager"; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 101 | exit(1); |
| 102 | } |
| 103 | |
Dimitry Ivanov | c976e73 | 2017-01-19 12:48:27 -0800 | [diff] [blame] | 104 | bool has_adoptable; |
Jeff Sharkey | 95a92f9 | 2017-07-17 13:57:18 -0600 | [diff] [blame] | 105 | bool has_quota; |
Jeff Sharkey | 53d5d7c | 2018-01-08 10:43:00 -0700 | [diff] [blame] | 106 | bool has_reserved; |
Dimitry Ivanov | c976e73 | 2017-01-19 12:48:27 -0800 | [diff] [blame] | 107 | |
Jeff Sharkey | 53d5d7c | 2018-01-08 10:43:00 -0700 | [diff] [blame] | 108 | if (process_config(vm, &has_adoptable, &has_quota, &has_reserved)) { |
Jeff Sharkey | 9f18fe7 | 2015-04-01 23:32:18 -0700 | [diff] [blame] | 109 | PLOG(ERROR) << "Error reading configuration... continuing anyways"; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Yifan Hong | 024a124 | 2018-08-10 13:50:46 -0700 | [diff] [blame] | 112 | android::hardware::configureRpcThreadpool(1, false /* callerWillJoin */); |
| 113 | |
Paul Crowley | 3188805 | 2017-09-27 10:56:54 -0700 | [diff] [blame] | 114 | ATRACE_BEGIN("VoldNativeService::start"); |
| 115 | if (android::vold::VoldNativeService::start() != android::OK) { |
| 116 | LOG(ERROR) << "Unable to start VoldNativeService"; |
| 117 | exit(1); |
| 118 | } |
| 119 | ATRACE_END(); |
| 120 | |
Paul Crowley | 0fd2626 | 2018-01-30 09:48:19 -0800 | [diff] [blame] | 121 | LOG(DEBUG) << "VoldNativeService::start() completed OK"; |
| 122 | |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 123 | ATRACE_BEGIN("NetlinkManager::start"); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 124 | if (nm->start()) { |
Jeff Sharkey | 9f18fe7 | 2015-04-01 23:32:18 -0700 | [diff] [blame] | 125 | PLOG(ERROR) << "Unable to start NetlinkManager"; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 126 | exit(1); |
| 127 | } |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 128 | ATRACE_END(); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 129 | |
Dimitry Ivanov | c976e73 | 2017-01-19 12:48:27 -0800 | [diff] [blame] | 130 | // This call should go after listeners are started to avoid |
| 131 | // a deadlock between vold and init (see b/34278978 for details) |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 132 | android::base::SetProperty("vold.has_adoptable", has_adoptable ? "1" : "0"); |
| 133 | android::base::SetProperty("vold.has_quota", has_quota ? "1" : "0"); |
Jeff Sharkey | 53d5d7c | 2018-01-08 10:43:00 -0700 | [diff] [blame] | 134 | android::base::SetProperty("vold.has_reserved", has_reserved ? "1" : "0"); |
Dimitry Ivanov | c976e73 | 2017-01-19 12:48:27 -0800 | [diff] [blame] | 135 | |
Wei Wang | 2edbe28 | 2017-03-06 17:27:05 -0800 | [diff] [blame] | 136 | // Do coldboot here so it won't block booting, |
| 137 | // also the cold boot is needed in case we have flash drive |
| 138 | // connected before Vold launched |
| 139 | coldboot("/sys/block"); |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 140 | |
| 141 | ATRACE_END(); |
| 142 | |
Jeff Sharkey | 93396c1 | 2017-10-18 16:52:48 -0600 | [diff] [blame] | 143 | android::IPCThreadState::self()->joinThreadPool(); |
| 144 | LOG(INFO) << "vold shutting down"; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 145 | |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 146 | exit(0); |
| 147 | } |
| 148 | |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 149 | static void parse_args(int argc, char** argv) { |
| 150 | static struct option opts[] = { |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 151 | {"blkid_context", required_argument, 0, 'b'}, |
| 152 | {"blkid_untrusted_context", required_argument, 0, 'B'}, |
| 153 | {"fsck_context", required_argument, 0, 'f'}, |
| 154 | {"fsck_untrusted_context", required_argument, 0, 'F'}, |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 155 | }; |
| 156 | |
| 157 | int c; |
| 158 | while ((c = getopt_long(argc, argv, "", opts, nullptr)) != -1) { |
| 159 | switch (c) { |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 160 | // clang-format off |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 161 | case 'b': android::vold::sBlkidContext = optarg; break; |
| 162 | case 'B': android::vold::sBlkidUntrustedContext = optarg; break; |
| 163 | case 'f': android::vold::sFsckContext = optarg; break; |
| 164 | case 'F': android::vold::sFsckUntrustedContext = optarg; break; |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 165 | // clang-format on |
Jeff Sharkey | 95c87cc | 2015-04-01 11:54:32 -0700 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
| 169 | CHECK(android::vold::sBlkidContext != nullptr); |
| 170 | CHECK(android::vold::sBlkidUntrustedContext != nullptr); |
| 171 | CHECK(android::vold::sFsckContext != nullptr); |
| 172 | CHECK(android::vold::sFsckUntrustedContext != nullptr); |
| 173 | } |
| 174 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 175 | static void do_coldboot(DIR* d, int lvl) { |
| 176 | struct dirent* de; |
Wei Wang | 2edbe28 | 2017-03-06 17:27:05 -0800 | [diff] [blame] | 177 | int dfd, fd; |
| 178 | |
| 179 | dfd = dirfd(d); |
| 180 | |
| 181 | fd = openat(dfd, "uevent", O_WRONLY | O_CLOEXEC); |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 182 | if (fd >= 0) { |
Wei Wang | 2edbe28 | 2017-03-06 17:27:05 -0800 | [diff] [blame] | 183 | write(fd, "add\n", 4); |
| 184 | close(fd); |
| 185 | } |
| 186 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 187 | while ((de = readdir(d))) { |
| 188 | DIR* d2; |
Wei Wang | 2edbe28 | 2017-03-06 17:27:05 -0800 | [diff] [blame] | 189 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 190 | if (de->d_name[0] == '.') continue; |
Wei Wang | 2edbe28 | 2017-03-06 17:27:05 -0800 | [diff] [blame] | 191 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 192 | if (de->d_type != DT_DIR && lvl > 0) continue; |
Wei Wang | 2edbe28 | 2017-03-06 17:27:05 -0800 | [diff] [blame] | 193 | |
Jeff Sharkey | fd3dc3c | 2017-03-27 10:49:21 -0600 | [diff] [blame] | 194 | fd = openat(dfd, de->d_name, O_RDONLY | O_DIRECTORY | O_CLOEXEC); |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 195 | if (fd < 0) continue; |
Wei Wang | 2edbe28 | 2017-03-06 17:27:05 -0800 | [diff] [blame] | 196 | |
| 197 | d2 = fdopendir(fd); |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 198 | if (d2 == 0) |
Wei Wang | 2edbe28 | 2017-03-06 17:27:05 -0800 | [diff] [blame] | 199 | close(fd); |
| 200 | else { |
| 201 | do_coldboot(d2, lvl + 1); |
| 202 | closedir(d2); |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 207 | static void coldboot(const char* path) { |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 208 | ATRACE_NAME("coldboot"); |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 209 | DIR* d = opendir(path); |
| 210 | if (d) { |
Wei Wang | 2edbe28 | 2017-03-06 17:27:05 -0800 | [diff] [blame] | 211 | do_coldboot(d, 0); |
| 212 | closedir(d); |
| 213 | } |
| 214 | } |
| 215 | |
Jeff Sharkey | 53d5d7c | 2018-01-08 10:43:00 -0700 | [diff] [blame] | 216 | static int process_config(VolumeManager* vm, bool* has_adoptable, bool* has_quota, |
| 217 | bool* has_reserved) { |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 218 | ATRACE_NAME("process_config"); |
| 219 | |
Tom Cherry | 4c5bde2 | 2019-01-29 14:34:01 -0800 | [diff] [blame] | 220 | if (!ReadDefaultFstab(&fstab_default)) { |
Bowgo Tsai | e8fb6c3 | 2017-03-09 23:11:33 +0800 | [diff] [blame] | 221 | PLOG(ERROR) << "Failed to open default fstab"; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 222 | return -1; |
| 223 | } |
| 224 | |
Ken Sumrall | 56ad03c | 2013-02-13 13:00:19 -0800 | [diff] [blame] | 225 | /* Loop through entries looking for ones that vold manages */ |
Dimitry Ivanov | c976e73 | 2017-01-19 12:48:27 -0800 | [diff] [blame] | 226 | *has_adoptable = false; |
Jeff Sharkey | 95a92f9 | 2017-07-17 13:57:18 -0600 | [diff] [blame] | 227 | *has_quota = false; |
Jeff Sharkey | 53d5d7c | 2018-01-08 10:43:00 -0700 | [diff] [blame] | 228 | *has_reserved = false; |
David Anderson | 0d71c4b | 2019-02-05 17:32:05 -0800 | [diff] [blame] | 229 | for (auto& entry : fstab_default) { |
Tom Cherry | 4c5bde2 | 2019-01-29 14:34:01 -0800 | [diff] [blame] | 230 | if (entry.fs_mgr_flags.quota) { |
Jeff Sharkey | 95a92f9 | 2017-07-17 13:57:18 -0600 | [diff] [blame] | 231 | *has_quota = true; |
| 232 | } |
Tom Cherry | 4c5bde2 | 2019-01-29 14:34:01 -0800 | [diff] [blame] | 233 | if (entry.reserved_size > 0) { |
Jeff Sharkey | 53d5d7c | 2018-01-08 10:43:00 -0700 | [diff] [blame] | 234 | *has_reserved = true; |
| 235 | } |
Jeff Sharkey | 95a92f9 | 2017-07-17 13:57:18 -0600 | [diff] [blame] | 236 | |
David Anderson | 0d71c4b | 2019-02-05 17:32:05 -0800 | [diff] [blame] | 237 | /* Make sure logical partitions have an updated blk_device. */ |
| 238 | if (entry.fs_mgr_flags.logical && !fs_mgr_update_logical_partition(&entry)) { |
| 239 | PLOG(FATAL) << "could not find logical partition " << entry.blk_device; |
| 240 | } |
| 241 | |
Tom Cherry | 4c5bde2 | 2019-01-29 14:34:01 -0800 | [diff] [blame] | 242 | if (entry.fs_mgr_flags.vold_managed) { |
| 243 | if (entry.fs_mgr_flags.nonremovable) { |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 244 | LOG(WARNING) << "nonremovable no longer supported; ignoring volume"; |
| 245 | continue; |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 246 | } |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 247 | |
Tom Cherry | 4c5bde2 | 2019-01-29 14:34:01 -0800 | [diff] [blame] | 248 | std::string sysPattern(entry.blk_device); |
| 249 | std::string nickname(entry.label); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 250 | int flags = 0; |
| 251 | |
Tom Cherry | 4c5bde2 | 2019-01-29 14:34:01 -0800 | [diff] [blame] | 252 | if (entry.is_encryptable()) { |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 253 | flags |= android::vold::Disk::Flags::kAdoptable; |
Dimitry Ivanov | c976e73 | 2017-01-19 12:48:27 -0800 | [diff] [blame] | 254 | *has_adoptable = true; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 255 | } |
Tom Cherry | 4c5bde2 | 2019-01-29 14:34:01 -0800 | [diff] [blame] | 256 | if (entry.fs_mgr_flags.no_emulated_sd || |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 257 | android::base::GetBoolProperty("vold.debug.default_primary", false)) { |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 258 | flags |= android::vold::Disk::Flags::kDefaultPrimary; |
Jeff Sharkey | ba6ae8d | 2013-07-15 18:14:25 -0700 | [diff] [blame] | 259 | } |
Ken Sumrall | 29d8da8 | 2011-05-18 17:20:07 -0700 | [diff] [blame] | 260 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 261 | vm->addDiskSource(std::shared_ptr<VolumeManager::DiskSource>( |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 262 | new VolumeManager::DiskSource(sysPattern, nickname, flags))); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 263 | } |
| 264 | } |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 265 | return 0; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 266 | } |