blob: 04c43cfcdcdb7a1957a0f4a899ea0ab84ada7274 [file] [log] [blame]
Jeff Sharkeydeb24052015-03-02 21:01:40 -08001/*
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 Sharkeydeb24052015-03-02 21:01:40 -080017#include "Disk.h"
18#include "PublicVolume.h"
Jeff Sharkey9c484982015-03-31 10:35:33 -070019#include "PrivateVolume.h"
Jeff Sharkeydeb24052015-03-02 21:01:40 -080020#include "Utils.h"
21#include "VolumeBase.h"
Jeff Sharkey36801cc2015-03-13 16:09:20 -070022#include "VolumeManager.h"
23#include "ResponseCode.h"
Jeff Sharkeydeb24052015-03-02 21:01:40 -080024
Dan Albertae9e8902015-03-16 10:35:17 -070025#include <base/file.h>
26#include <base/stringprintf.h>
Jeff Sharkey36801cc2015-03-13 16:09:20 -070027#include <base/logging.h>
Jeff Sharkeydeb24052015-03-02 21:01:40 -080028#include <diskconfig/diskconfig.h>
Jeff Sharkeydeb24052015-03-02 21:01:40 -080029
Jeff Sharkey9c484982015-03-31 10:35:33 -070030#include <vector>
Jeff Sharkeydeb24052015-03-02 21:01:40 -080031#include <fcntl.h>
Jeff Sharkey38cfc022015-03-30 21:22:07 -070032#include <inttypes.h>
Jeff Sharkeydeb24052015-03-02 21:01:40 -080033#include <stdio.h>
34#include <stdlib.h>
35#include <sys/types.h>
36#include <sys/stat.h>
37#include <sys/mount.h>
38
Dan Albertae9e8902015-03-16 10:35:17 -070039using android::base::ReadFileToString;
Jeff Sharkey9c484982015-03-31 10:35:33 -070040using android::base::WriteStringToFile;
Dan Albertae9e8902015-03-16 10:35:17 -070041using android::base::StringPrintf;
42
Jeff Sharkeydeb24052015-03-02 21:01:40 -080043namespace android {
44namespace vold {
45
46static const char* kSgdiskPath = "/system/bin/sgdisk";
47static const char* kSgdiskToken = " \t\n";
48
49static const char* kSysfsMmcMaxMinors = "/sys/module/mmcblk/parameters/perdev_minors";
50
51static const unsigned int kMajorBlockScsi = 8;
52static const unsigned int kMajorBlockMmc = 179;
53
54static const char* kGptBasicData = "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7";
55static const char* kGptAndroidMeta = "19A710A2-B3CA-11E4-B026-10604B889DCF";
Jeff Sharkeyce6a9132015-04-08 21:07:21 -070056static const char* kGptAndroidExpand = "193D1EA4-B3CA-11E4-B075-10604B889DCF";
Jeff Sharkeydeb24052015-03-02 21:01:40 -080057
Jeff Sharkey9c484982015-03-31 10:35:33 -070058static const char* kKeyPath = "/data/misc/vold";
59
Jeff Sharkeydeb24052015-03-02 21:01:40 -080060enum class Table {
61 kUnknown,
62 kMbr,
63 kGpt,
64};
65
Jeff Sharkeyce6a9132015-04-08 21:07:21 -070066Disk::Disk(const std::string& eventPath, dev_t device,
67 const std::string& nickname, int flags) :
68 mDevice(device), mSize(-1), mNickname(nickname), mFlags(flags), mCreated(
69 false), mJustPartitioned(false) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -070070 mId = StringPrintf("disk:%u,%u", major(device), minor(device));
71 mEventPath = eventPath;
Jeff Sharkeydeb24052015-03-02 21:01:40 -080072 mSysPath = StringPrintf("/sys/%s", eventPath.c_str());
Jeff Sharkey36801cc2015-03-13 16:09:20 -070073 mDevPath = StringPrintf("/dev/block/vold/%s", mId.c_str());
Jeff Sharkeydeb24052015-03-02 21:01:40 -080074 CreateDeviceNode(mDevPath, mDevice);
75}
76
77Disk::~Disk() {
Jeff Sharkey36801cc2015-03-13 16:09:20 -070078 CHECK(!mCreated);
Jeff Sharkeydeb24052015-03-02 21:01:40 -080079 DestroyDeviceNode(mDevPath);
80}
81
82std::shared_ptr<VolumeBase> Disk::findVolume(const std::string& id) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -070083 for (auto vol : mVolumes) {
84 if (vol->getId() == id) {
85 return vol;
86 }
87 auto stackedVol = vol->findVolume(id);
88 if (stackedVol != nullptr) {
89 return stackedVol;
Jeff Sharkeydeb24052015-03-02 21:01:40 -080090 }
91 }
92 return nullptr;
93}
94
Jeff Sharkey36801cc2015-03-13 16:09:20 -070095status_t Disk::create() {
96 CHECK(!mCreated);
97 mCreated = true;
Jeff Sharkeyce6a9132015-04-08 21:07:21 -070098 notifyEvent(ResponseCode::DiskCreated, StringPrintf("%d", mFlags));
Jeff Sharkey36801cc2015-03-13 16:09:20 -070099 readMetadata();
100 readPartitions();
101 return OK;
102}
103
104status_t Disk::destroy() {
105 CHECK(mCreated);
106 destroyAllVolumes();
107 mCreated = false;
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700108 notifyEvent(ResponseCode::DiskDestroyed);
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700109 return OK;
110}
111
Jeff Sharkey9c484982015-03-31 10:35:33 -0700112static std::string BuildKeyPath(const std::string& partGuid) {
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700113 return StringPrintf("%s/expand_%s.key", kKeyPath, partGuid.c_str());
Jeff Sharkey9c484982015-03-31 10:35:33 -0700114}
115
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700116void Disk::createPublicVolume(dev_t device) {
Jeff Sharkey9c484982015-03-31 10:35:33 -0700117 auto vol = std::shared_ptr<VolumeBase>(new PublicVolume(device));
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700118 if (mJustPartitioned) {
119 LOG(DEBUG) << "Device just partitioned; silently formatting";
120 vol->setSilent(true);
121 vol->create();
122 vol->format();
123 vol->destroy();
124 vol->setSilent(false);
125 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700126
Jeff Sharkey9c484982015-03-31 10:35:33 -0700127 mVolumes.push_back(vol);
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700128 vol->create();
129 notifyEvent(ResponseCode::DiskVolumeCreated, vol->getId());
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700130}
131
Jeff Sharkey9c484982015-03-31 10:35:33 -0700132void Disk::createPrivateVolume(dev_t device, const std::string& partGuid) {
133 std::string tmp;
134 std::string normalizedGuid;
135 if (HexToStr(partGuid, tmp)) {
136 LOG(WARNING) << "Invalid GUID " << partGuid;
137 return;
138 }
139 StrToHex(tmp, normalizedGuid);
140
141 std::string keyRaw;
142 if (!ReadFileToString(BuildKeyPath(normalizedGuid), &keyRaw)) {
143 PLOG(ERROR) << "Failed to load key for GUID " << normalizedGuid;
144 return;
145 }
146
147 LOG(DEBUG) << "Found key for GUID " << normalizedGuid;
148
149 auto vol = std::shared_ptr<VolumeBase>(new PrivateVolume(device, keyRaw));
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700150 if (mJustPartitioned) {
151 LOG(DEBUG) << "Device just partitioned; silently formatting";
152 vol->setSilent(true);
153 vol->create();
154 vol->format();
155 vol->destroy();
156 vol->setSilent(false);
157 }
Jeff Sharkey9c484982015-03-31 10:35:33 -0700158
159 mVolumes.push_back(vol);
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700160 vol->create();
161 notifyEvent(ResponseCode::DiskVolumeCreated, vol->getId());
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700162}
163
164void Disk::destroyAllVolumes() {
165 for (auto vol : mVolumes) {
166 vol->destroy();
Jeff Sharkey502164d2015-04-14 16:45:18 -0700167 notifyEvent(ResponseCode::DiskVolumeDestroyed, vol->getId());
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700168 }
169 mVolumes.clear();
170}
171
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800172status_t Disk::readMetadata() {
173 mSize = -1;
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700174 mLabel.clear();
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800175
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700176 int fd = open(mDevPath.c_str(), O_RDONLY | O_CLOEXEC);
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700177 if (fd != -1) {
178 if (ioctl(fd, BLKGETSIZE64, &mSize)) {
179 mSize = -1;
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800180 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700181 close(fd);
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800182 }
183
184 switch (major(mDevice)) {
185 case kMajorBlockScsi: {
186 std::string path(mSysPath + "/device/vendor");
187 std::string tmp;
188 if (!ReadFileToString(path, &tmp)) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700189 PLOG(WARNING) << "Failed to read vendor from " << path;
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800190 return -errno;
191 }
192 mLabel = tmp;
193 break;
194 }
195 case kMajorBlockMmc: {
196 std::string path(mSysPath + "/device/manfid");
197 std::string tmp;
198 if (!ReadFileToString(path, &tmp)) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700199 PLOG(WARNING) << "Failed to read manufacturer from " << path;
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800200 return -errno;
201 }
202 uint64_t manfid = strtoll(tmp.c_str(), nullptr, 16);
203 // Our goal here is to give the user a meaningful label, ideally
204 // matching whatever is silk-screened on the card. To reduce
205 // user confusion, this list doesn't contain white-label manfid.
206 switch (manfid) {
207 case 0x000003: mLabel = "SanDisk"; break;
208 case 0x00001b: mLabel = "Samsung"; break;
209 case 0x000028: mLabel = "Lexar"; break;
210 case 0x000074: mLabel = "Transcend"; break;
211 }
212 break;
213 }
214 default: {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700215 LOG(WARNING) << "Unsupported block major type" << major(mDevice);
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800216 return -ENOTSUP;
217 }
218 }
219
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700220 notifyEvent(ResponseCode::DiskSizeChanged, StringPrintf("%" PRId64, mSize));
221 notifyEvent(ResponseCode::DiskLabelChanged, mLabel);
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800222 return OK;
223}
224
225status_t Disk::readPartitions() {
226 int8_t maxMinors = getMaxMinors();
227 if (maxMinors < 0) {
228 return -ENOTSUP;
229 }
230
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700231 destroyAllVolumes();
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800232
233 // Parse partition table
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700234
235 std::vector<std::string> cmd;
236 cmd.push_back(kSgdiskPath);
237 cmd.push_back("--android-dump");
238 cmd.push_back(mDevPath);
239
240 std::vector<std::string> output;
241 status_t res = ForkExecvp(cmd, output);
242 if (res != OK) {
243 LOG(WARNING) << "sgdisk failed to scan " << mDevPath;
244 mJustPartitioned = false;
245 return res;
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800246 }
247
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800248 Table table = Table::kUnknown;
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700249 bool foundParts = false;
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700250 for (auto line : output) {
251 char* cline = (char*) line.c_str();
252 char* token = strtok(cline, kSgdiskToken);
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700253 if (token == nullptr) continue;
254
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800255 if (!strcmp(token, "DISK")) {
256 const char* type = strtok(nullptr, kSgdiskToken);
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800257 if (!strcmp(type, "mbr")) {
258 table = Table::kMbr;
259 } else if (!strcmp(type, "gpt")) {
260 table = Table::kGpt;
261 }
262 } else if (!strcmp(token, "PART")) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700263 foundParts = true;
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800264 int i = strtol(strtok(nullptr, kSgdiskToken), nullptr, 10);
265 if (i <= 0 || i > maxMinors) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700266 LOG(WARNING) << mId << " is ignoring partition " << i
267 << " beyond max supported devices";
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800268 continue;
269 }
270 dev_t partDevice = makedev(major(mDevice), minor(mDevice) + i);
271
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800272 if (table == Table::kMbr) {
273 const char* type = strtok(nullptr, kSgdiskToken);
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800274
275 switch (strtol(type, nullptr, 16)) {
276 case 0x06: // FAT16
277 case 0x0b: // W95 FAT32 (LBA)
278 case 0x0c: // W95 FAT32 (LBA)
279 case 0x0e: // W95 FAT16 (LBA)
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700280 createPublicVolume(partDevice);
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800281 break;
282 }
283 } else if (table == Table::kGpt) {
284 const char* typeGuid = strtok(nullptr, kSgdiskToken);
285 const char* partGuid = strtok(nullptr, kSgdiskToken);
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800286
287 if (!strcasecmp(typeGuid, kGptBasicData)) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700288 createPublicVolume(partDevice);
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700289 } else if (!strcasecmp(typeGuid, kGptAndroidExpand)) {
Jeff Sharkey9c484982015-03-31 10:35:33 -0700290 createPrivateVolume(partDevice, partGuid);
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800291 }
292 }
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800293 }
294 }
295
296 // Ugly last ditch effort, treat entire disk as partition
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700297 if (table == Table::kUnknown || !foundParts) {
298 LOG(WARNING) << mId << " has unknown partition table; trying entire device";
299 createPublicVolume(mDevice);
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800300 }
301
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700302 mJustPartitioned = false;
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800303 return OK;
304}
305
Jeff Sharkey9c484982015-03-31 10:35:33 -0700306status_t Disk::unmountAll() {
307 for (auto vol : mVolumes) {
308 vol->unmount();
309 }
310 return OK;
311}
312
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800313status_t Disk::partitionPublic() {
314 // TODO: improve this code
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700315 destroyAllVolumes();
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700316 mJustPartitioned = true;
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800317
318 struct disk_info dinfo;
319 memset(&dinfo, 0, sizeof(dinfo));
320
321 if (!(dinfo.part_lst = (struct part_info *) malloc(
322 MAX_NUM_PARTS * sizeof(struct part_info)))) {
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800323 return -1;
324 }
325
326 memset(dinfo.part_lst, 0, MAX_NUM_PARTS * sizeof(struct part_info));
327 dinfo.device = strdup(mDevPath.c_str());
328 dinfo.scheme = PART_SCHEME_MBR;
329 dinfo.sect_size = 512;
330 dinfo.skip_lba = 2048;
331 dinfo.num_lba = 0;
332 dinfo.num_parts = 1;
333
334 struct part_info *pinfo = &dinfo.part_lst[0];
335
336 pinfo->name = strdup("android_sdcard");
337 pinfo->flags |= PART_ACTIVE_FLAG;
338 pinfo->type = PC_PART_TYPE_FAT32;
339 pinfo->len_kb = -1;
340
341 int rc = apply_disk_config(&dinfo, 0);
342 if (rc) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700343 LOG(ERROR) << "Failed to apply disk configuration: " << rc;
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800344 goto out;
345 }
346
347out:
348 free(pinfo->name);
349 free(dinfo.device);
350 free(dinfo.part_lst);
351
352 return rc;
353}
354
355status_t Disk::partitionPrivate() {
Jeff Sharkey9c484982015-03-31 10:35:33 -0700356 return partitionMixed(0);
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800357}
358
359status_t Disk::partitionMixed(int8_t ratio) {
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700360 int res;
Jeff Sharkey9c484982015-03-31 10:35:33 -0700361
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700362 destroyAllVolumes();
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700363 mJustPartitioned = true;
Jeff Sharkey9c484982015-03-31 10:35:33 -0700364
365 // First nuke any existing partition table
366 std::vector<std::string> cmd;
367 cmd.push_back(kSgdiskPath);
368 cmd.push_back("--zap-all");
369 cmd.push_back(mDevPath);
370
Jeff Sharkeyffeb0072015-04-14 22:22:34 -0700371 // Zap sometimes returns an error when it actually succeeded, so
372 // just log as warning and keep rolling forward.
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700373 if ((res = ForkExecvp(cmd)) != 0) {
Jeff Sharkeyffeb0072015-04-14 22:22:34 -0700374 LOG(WARNING) << "Failed to zap; status " << res;
Jeff Sharkey9c484982015-03-31 10:35:33 -0700375 }
376
377 // We've had some success above, so generate both the private partition
378 // GUID and encryption key and persist them.
379 std::string partGuidRaw;
380 std::string keyRaw;
381 if (ReadRandomBytes(16, partGuidRaw) || ReadRandomBytes(16, keyRaw)) {
382 LOG(ERROR) << "Failed to generate GUID or key";
383 return -EIO;
384 }
385
386 std::string partGuid;
387 StrToHex(partGuidRaw, partGuid);
388
389 if (!WriteStringToFile(keyRaw, BuildKeyPath(partGuid))) {
390 LOG(ERROR) << "Failed to persist key";
391 return -EIO;
392 } else {
393 LOG(DEBUG) << "Persisted key for GUID " << partGuid;
394 }
395
396 // Now let's build the new GPT table. We heavily rely on sgdisk to
397 // force optimal alignment on the created partitions.
398 cmd.clear();
399 cmd.push_back(kSgdiskPath);
400
401 // If requested, create a public partition first. Mixed-mode partitioning
402 // like this is an experimental feature.
403 if (ratio > 0) {
404 if (ratio < 10 || ratio > 90) {
405 LOG(ERROR) << "Mixed partition ratio must be between 10-90%";
406 return -EINVAL;
407 }
408
409 uint64_t splitMb = ((mSize / 100) * ratio) / 1024 / 1024;
410 cmd.push_back(StringPrintf("--new=0:0:+%" PRId64 "M", splitMb));
411 cmd.push_back(StringPrintf("--typecode=0:%s", kGptBasicData));
412 cmd.push_back("--change-name=0:shared");
413 }
414
415 // Define a metadata partition which is designed for future use; there
416 // should only be one of these per physical device, even if there are
417 // multiple private volumes.
418 cmd.push_back("--new=0:0:+16M");
419 cmd.push_back(StringPrintf("--typecode=0:%s", kGptAndroidMeta));
420 cmd.push_back("--change-name=0:android_meta");
421
422 // Define a single private partition filling the rest of disk.
423 cmd.push_back("--new=0:0:-0");
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700424 cmd.push_back(StringPrintf("--typecode=0:%s", kGptAndroidExpand));
Jeff Sharkey9c484982015-03-31 10:35:33 -0700425 cmd.push_back(StringPrintf("--partition-guid=0:%s", partGuid.c_str()));
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700426 cmd.push_back("--change-name=0:android_expand");
Jeff Sharkey9c484982015-03-31 10:35:33 -0700427
428 cmd.push_back(mDevPath);
429
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700430 if ((res = ForkExecvp(cmd)) != 0) {
431 LOG(ERROR) << "Failed to partition; status " << res;
432 return res;
Jeff Sharkey9c484982015-03-31 10:35:33 -0700433 }
434
435 return OK;
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800436}
437
Jeff Sharkeyce6a9132015-04-08 21:07:21 -0700438void Disk::notifyEvent(int event) {
439 VolumeManager::Instance()->getBroadcaster()->sendBroadcast(event,
440 getId().c_str(), false);
441}
442
443void Disk::notifyEvent(int event, const std::string& value) {
444 VolumeManager::Instance()->getBroadcaster()->sendBroadcast(event,
445 StringPrintf("%s %s", getId().c_str(), value.c_str()).c_str(), false);
446}
447
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800448int Disk::getMaxMinors() {
449 // Figure out maximum partition devices supported
450 switch (major(mDevice)) {
451 case kMajorBlockScsi: {
452 // Per Documentation/devices.txt this is static
453 return 15;
454 }
455 case kMajorBlockMmc: {
456 // Per Documentation/devices.txt this is dynamic
457 std::string tmp;
458 if (!ReadFileToString(kSysfsMmcMaxMinors, &tmp)) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700459 LOG(ERROR) << "Failed to read max minors";
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800460 return -errno;
461 }
462 return atoi(tmp.c_str());
463 }
464 }
465
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700466 LOG(ERROR) << "Unsupported block major type " << major(mDevice);
Jeff Sharkeydeb24052015-03-02 21:01:40 -0800467 return -ENOTSUP;
468}
469
470} // namespace vold
471} // namespace android