blob: 9a064e7270cc851b19e0a5e778327321e6939eb7 [file] [log] [blame]
San Mehatf1b736b2009-10-10 17:22:08 -07001/*
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
17#include <stdio.h>
San Mehatfd7f5872009-10-12 11:32:47 -070018#include <stdlib.h>
San Mehatf1b736b2009-10-10 17:22:08 -070019#include <string.h>
San Mehatfd7f5872009-10-12 11:32:47 -070020#include <errno.h>
San Mehatf1b736b2009-10-10 17:22:08 -070021
San Mehata2677e42009-12-13 10:40:18 -080022#include <linux/kdev_t.h>
23
24#define LOG_TAG "DirectVolume"
San Mehatf1b736b2009-10-10 17:22:08 -070025
26#include <cutils/log.h>
San Mehatfd7f5872009-10-12 11:32:47 -070027#include <sysutils/NetlinkEvent.h>
San Mehatf1b736b2009-10-10 17:22:08 -070028
San Mehatae10b912009-10-12 14:57:05 -070029#include "DirectVolume.h"
San Mehata2677e42009-12-13 10:40:18 -080030#include "VolumeManager.h"
31#include "ResponseCode.h"
Ken Sumrall29d8da82011-05-18 17:20:07 -070032#include "cryptfs.h"
San Mehatf1b736b2009-10-10 17:22:08 -070033
San Mehata2677e42009-12-13 10:40:18 -080034// #define PARTITION_DEBUG
35
36DirectVolume::DirectVolume(VolumeManager *vm, const char *label,
37 const char *mount_point, int partIdx) :
38 Volume(vm, label, mount_point) {
San Mehatf1b736b2009-10-10 17:22:08 -070039 mPartIdx = partIdx;
San Mehata2677e42009-12-13 10:40:18 -080040
San Mehatf1b736b2009-10-10 17:22:08 -070041 mPaths = new PathCollection();
San Mehatdd9b8e92009-10-21 11:06:52 -070042 for (int i = 0; i < MAX_PARTITIONS; i++)
43 mPartMinors[i] = -1;
San Mehata2677e42009-12-13 10:40:18 -080044 mPendingPartMap = 0;
45 mDiskMajor = -1;
46 mDiskMinor = -1;
47 mDiskNumParts = 0;
48
49 setState(Volume::State_NoMedia);
San Mehatf1b736b2009-10-10 17:22:08 -070050}
51
San Mehatae10b912009-10-12 14:57:05 -070052DirectVolume::~DirectVolume() {
San Mehatf1b736b2009-10-10 17:22:08 -070053 PathCollection::iterator it;
54
55 for (it = mPaths->begin(); it != mPaths->end(); ++it)
56 free(*it);
57 delete mPaths;
58}
59
San Mehatae10b912009-10-12 14:57:05 -070060int DirectVolume::addPath(const char *path) {
San Mehatf1b736b2009-10-10 17:22:08 -070061 mPaths->push_back(strdup(path));
62 return 0;
63}
64
Ken Sumrall29d8da82011-05-18 17:20:07 -070065void DirectVolume::setFlags(int flags) {
66 mFlags = flags;
67}
68
San Mehata2677e42009-12-13 10:40:18 -080069dev_t DirectVolume::getDiskDevice() {
70 return MKDEV(mDiskMajor, mDiskMinor);
71}
72
Mike Lockwood2dfe2972010-09-17 18:50:51 -040073dev_t DirectVolume::getShareDevice() {
74 if (mPartIdx != -1) {
75 return MKDEV(mDiskMajor, mPartIdx);
76 } else {
77 return MKDEV(mDiskMajor, mDiskMinor);
78 }
79}
80
San Mehata2677e42009-12-13 10:40:18 -080081void DirectVolume::handleVolumeShared() {
82 setState(Volume::State_Shared);
83}
84
85void DirectVolume::handleVolumeUnshared() {
86 setState(Volume::State_Idle);
87}
88
San Mehatae10b912009-10-12 14:57:05 -070089int DirectVolume::handleBlockEvent(NetlinkEvent *evt) {
San Mehatfd7f5872009-10-12 11:32:47 -070090 const char *dp = evt->findParam("DEVPATH");
San Mehatf1b736b2009-10-10 17:22:08 -070091
San Mehatfd7f5872009-10-12 11:32:47 -070092 PathCollection::iterator it;
San Mehatf1b736b2009-10-10 17:22:08 -070093 for (it = mPaths->begin(); it != mPaths->end(); ++it) {
San Mehatf1b736b2009-10-10 17:22:08 -070094 if (!strncmp(dp, *it, strlen(*it))) {
San Mehatfd7f5872009-10-12 11:32:47 -070095 /* We can handle this disk */
96 int action = evt->getAction();
97 const char *devtype = evt->findParam("DEVTYPE");
98
San Mehata2677e42009-12-13 10:40:18 -080099 if (action == NetlinkEvent::NlActionAdd) {
100 int major = atoi(evt->findParam("MAJOR"));
101 int minor = atoi(evt->findParam("MINOR"));
102 char nodepath[255];
103
104 snprintf(nodepath,
105 sizeof(nodepath), "/dev/block/vold/%d:%d",
106 major, minor);
107 if (createDeviceNode(nodepath, major, minor)) {
San Mehat97ac40e2010-03-24 10:24:19 -0700108 SLOGE("Error making device node '%s' (%s)", nodepath,
San Mehata2677e42009-12-13 10:40:18 -0800109 strerror(errno));
110 }
111 if (!strcmp(devtype, "disk")) {
San Mehatfd7f5872009-10-12 11:32:47 -0700112 handleDiskAdded(dp, evt);
San Mehata2677e42009-12-13 10:40:18 -0800113 } else {
San Mehatfd7f5872009-10-12 11:32:47 -0700114 handlePartitionAdded(dp, evt);
San Mehata2677e42009-12-13 10:40:18 -0800115 }
Magnus Malmborn3dafc262011-01-19 12:26:52 +0100116 /* Send notification iff disk is ready (ie all partitions found) */
117 if (getState() == Volume::State_Idle) {
118 char msg[255];
119
120 snprintf(msg, sizeof(msg),
121 "Volume %s %s disk inserted (%d:%d)", getLabel(),
122 getMountpoint(), mDiskMajor, mDiskMinor);
123 mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeDiskInserted,
124 msg, false);
125 }
San Mehata2677e42009-12-13 10:40:18 -0800126 } else if (action == NetlinkEvent::NlActionRemove) {
127 if (!strcmp(devtype, "disk")) {
128 handleDiskRemoved(dp, evt);
129 } else {
San Mehatfd7f5872009-10-12 11:32:47 -0700130 handlePartitionRemoved(dp, evt);
San Mehata2677e42009-12-13 10:40:18 -0800131 }
132 } else if (action == NetlinkEvent::NlActionChange) {
133 if (!strcmp(devtype, "disk")) {
134 handleDiskChanged(dp, evt);
135 } else {
136 handlePartitionChanged(dp, evt);
137 }
138 } else {
San Mehat97ac40e2010-03-24 10:24:19 -0700139 SLOGW("Ignoring non add/remove/change event");
San Mehatf1b736b2009-10-10 17:22:08 -0700140 }
San Mehatfd7f5872009-10-12 11:32:47 -0700141
San Mehatf1b736b2009-10-10 17:22:08 -0700142 return 0;
143 }
144 }
145 errno = ENODEV;
146 return -1;
147}
San Mehatfd7f5872009-10-12 11:32:47 -0700148
San Mehatae10b912009-10-12 14:57:05 -0700149void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) {
Kenny Rootda62e7c2010-03-24 20:18:00 -0700150 mDiskMajor = atoi(evt->findParam("MAJOR"));
151 mDiskMinor = atoi(evt->findParam("MINOR"));
San Mehat7b8f2db2010-01-04 14:03:36 -0800152
153 const char *tmp = evt->findParam("NPARTS");
154 if (tmp) {
155 mDiskNumParts = atoi(tmp);
156 } else {
San Mehat97ac40e2010-03-24 10:24:19 -0700157 SLOGW("Kernel block uevent missing 'NPARTS'");
San Mehat7b8f2db2010-01-04 14:03:36 -0800158 mDiskNumParts = 1;
159 }
160
San Mehatfd7f5872009-10-12 11:32:47 -0700161 int partmask = 0;
162 int i;
San Mehat59abc3c2009-10-12 14:48:47 -0700163 for (i = 1; i <= mDiskNumParts; i++) {
San Mehatfd7f5872009-10-12 11:32:47 -0700164 partmask |= (1 << i);
165 }
166 mPendingPartMap = partmask;
167
168 if (mDiskNumParts == 0) {
San Mehata2677e42009-12-13 10:40:18 -0800169#ifdef PARTITION_DEBUG
San Mehat97ac40e2010-03-24 10:24:19 -0700170 SLOGD("Dv::diskIns - No partitions - good to go son!");
San Mehata2677e42009-12-13 10:40:18 -0800171#endif
San Mehatfd7f5872009-10-12 11:32:47 -0700172 setState(Volume::State_Idle);
173 } else {
San Mehata2677e42009-12-13 10:40:18 -0800174#ifdef PARTITION_DEBUG
San Mehat97ac40e2010-03-24 10:24:19 -0700175 SLOGD("Dv::diskIns - waiting for %d partitions (mask 0x%x)",
San Mehatfd7f5872009-10-12 11:32:47 -0700176 mDiskNumParts, mPendingPartMap);
San Mehata2677e42009-12-13 10:40:18 -0800177#endif
San Mehatfd7f5872009-10-12 11:32:47 -0700178 setState(Volume::State_Pending);
179 }
180}
181
San Mehatae10b912009-10-12 14:57:05 -0700182void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt) {
Kenny Rootda62e7c2010-03-24 20:18:00 -0700183 int major = atoi(evt->findParam("MAJOR"));
184 int minor = atoi(evt->findParam("MINOR"));
San Mehat7b8f2db2010-01-04 14:03:36 -0800185
186 int part_num;
187
188 const char *tmp = evt->findParam("PARTN");
189
190 if (tmp) {
191 part_num = atoi(tmp);
192 } else {
San Mehat97ac40e2010-03-24 10:24:19 -0700193 SLOGW("Kernel block uevent missing 'PARTN'");
San Mehat7b8f2db2010-01-04 14:03:36 -0800194 part_num = 1;
195 }
San Mehat59abc3c2009-10-12 14:48:47 -0700196
Nick Kralevichf3d3ce52011-04-18 11:16:13 -0700197 if (part_num > MAX_PARTITIONS || part_num < 1) {
Nick Kralevichcc8e96c2011-04-29 16:07:45 -0700198 SLOGE("Invalid 'PARTN' value");
199 return;
Nick Kralevichf3d3ce52011-04-18 11:16:13 -0700200 }
201
San Mehat2a5b8ce2010-03-10 12:48:57 -0800202 if (part_num > mDiskNumParts) {
203 mDiskNumParts = part_num;
204 }
205
San Mehatdd9b8e92009-10-21 11:06:52 -0700206 if (major != mDiskMajor) {
San Mehat97ac40e2010-03-24 10:24:19 -0700207 SLOGE("Partition '%s' has a different major than its disk!", devpath);
San Mehatdd9b8e92009-10-21 11:06:52 -0700208 return;
209 }
San Mehata2677e42009-12-13 10:40:18 -0800210#ifdef PARTITION_DEBUG
San Mehat97ac40e2010-03-24 10:24:19 -0700211 SLOGD("Dv:partAdd: part_num = %d, minor = %d\n", part_num, minor);
San Mehata2677e42009-12-13 10:40:18 -0800212#endif
Bruce Beared11b8332010-07-22 13:23:33 -0700213 if (part_num >= MAX_PARTITIONS) {
214 SLOGE("Dv:partAdd: ignoring part_num = %d (max: %d)\n", part_num, MAX_PARTITIONS-1);
Bruce Beared7660902010-07-22 13:23:33 -0700215 } else {
216 mPartMinors[part_num -1] = minor;
217 }
San Mehat59abc3c2009-10-12 14:48:47 -0700218 mPendingPartMap &= ~(1 << part_num);
Bruce Beared7660902010-07-22 13:23:33 -0700219
San Mehat59abc3c2009-10-12 14:48:47 -0700220 if (!mPendingPartMap) {
San Mehata2677e42009-12-13 10:40:18 -0800221#ifdef PARTITION_DEBUG
San Mehat97ac40e2010-03-24 10:24:19 -0700222 SLOGD("Dv:partAdd: Got all partitions - ready to rock!");
San Mehata2677e42009-12-13 10:40:18 -0800223#endif
San Mehat2a5b8ce2010-03-10 12:48:57 -0800224 if (getState() != Volume::State_Formatting) {
225 setState(Volume::State_Idle);
Joseph Lehrer507d31b2011-04-11 15:02:50 -0700226 if (mRetryMount == true) {
227 mRetryMount = false;
228 mountVol();
229 }
San Mehat2a5b8ce2010-03-10 12:48:57 -0800230 }
San Mehat59abc3c2009-10-12 14:48:47 -0700231 } else {
San Mehata2677e42009-12-13 10:40:18 -0800232#ifdef PARTITION_DEBUG
San Mehat97ac40e2010-03-24 10:24:19 -0700233 SLOGD("Dv:partAdd: pending mask now = 0x%x", mPendingPartMap);
San Mehata2677e42009-12-13 10:40:18 -0800234#endif
San Mehat59abc3c2009-10-12 14:48:47 -0700235 }
San Mehatfd7f5872009-10-12 11:32:47 -0700236}
237
San Mehata2677e42009-12-13 10:40:18 -0800238void DirectVolume::handleDiskChanged(const char *devpath, NetlinkEvent *evt) {
Kenny Rootda62e7c2010-03-24 20:18:00 -0700239 int major = atoi(evt->findParam("MAJOR"));
240 int minor = atoi(evt->findParam("MINOR"));
San Mehata2677e42009-12-13 10:40:18 -0800241
242 if ((major != mDiskMajor) || (minor != mDiskMinor)) {
243 return;
244 }
245
San Mehat97ac40e2010-03-24 10:24:19 -0700246 SLOGI("Volume %s disk has changed", getLabel());
San Mehat7b8f2db2010-01-04 14:03:36 -0800247 const char *tmp = evt->findParam("NPARTS");
248 if (tmp) {
249 mDiskNumParts = atoi(tmp);
250 } else {
San Mehat97ac40e2010-03-24 10:24:19 -0700251 SLOGW("Kernel block uevent missing 'NPARTS'");
San Mehat7b8f2db2010-01-04 14:03:36 -0800252 mDiskNumParts = 1;
253 }
254
San Mehata2677e42009-12-13 10:40:18 -0800255 int partmask = 0;
256 int i;
257 for (i = 1; i <= mDiskNumParts; i++) {
258 partmask |= (1 << i);
259 }
260 mPendingPartMap = partmask;
261
San Mehat2a5b8ce2010-03-10 12:48:57 -0800262 if (getState() != Volume::State_Formatting) {
263 if (mDiskNumParts == 0) {
264 setState(Volume::State_Idle);
265 } else {
266 setState(Volume::State_Pending);
267 }
San Mehata2677e42009-12-13 10:40:18 -0800268 }
San Mehata2677e42009-12-13 10:40:18 -0800269}
270
271void DirectVolume::handlePartitionChanged(const char *devpath, NetlinkEvent *evt) {
Kenny Rootda62e7c2010-03-24 20:18:00 -0700272 int major = atoi(evt->findParam("MAJOR"));
273 int minor = atoi(evt->findParam("MINOR"));
San Mehat97ac40e2010-03-24 10:24:19 -0700274 SLOGD("Volume %s %s partition %d:%d changed\n", getLabel(), getMountpoint(), major, minor);
San Mehata2677e42009-12-13 10:40:18 -0800275}
276
San Mehatae10b912009-10-12 14:57:05 -0700277void DirectVolume::handleDiskRemoved(const char *devpath, NetlinkEvent *evt) {
Kenny Rootda62e7c2010-03-24 20:18:00 -0700278 int major = atoi(evt->findParam("MAJOR"));
279 int minor = atoi(evt->findParam("MINOR"));
San Mehata2677e42009-12-13 10:40:18 -0800280 char msg[255];
281
San Mehat97ac40e2010-03-24 10:24:19 -0700282 SLOGD("Volume %s %s disk %d:%d removed\n", getLabel(), getMountpoint(), major, minor);
San Mehata2677e42009-12-13 10:40:18 -0800283 snprintf(msg, sizeof(msg), "Volume %s %s disk removed (%d:%d)",
284 getLabel(), getMountpoint(), major, minor);
285 mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeDiskRemoved,
286 msg, false);
287 setState(Volume::State_NoMedia);
San Mehatfd7f5872009-10-12 11:32:47 -0700288}
289
San Mehatae10b912009-10-12 14:57:05 -0700290void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt) {
Kenny Rootda62e7c2010-03-24 20:18:00 -0700291 int major = atoi(evt->findParam("MAJOR"));
292 int minor = atoi(evt->findParam("MINOR"));
San Mehata2677e42009-12-13 10:40:18 -0800293 char msg[255];
Ethan75a3e1a2010-07-21 23:07:51 +0800294 int state;
San Mehata2677e42009-12-13 10:40:18 -0800295
San Mehat97ac40e2010-03-24 10:24:19 -0700296 SLOGD("Volume %s %s partition %d:%d removed\n", getLabel(), getMountpoint(), major, minor);
San Mehata2677e42009-12-13 10:40:18 -0800297
298 /*
299 * The framework doesn't need to get notified of
300 * partition removal unless it's mounted. Otherwise
301 * the removal notification will be sent on the Disk
302 * itself
303 */
Ethan75a3e1a2010-07-21 23:07:51 +0800304 state = getState();
305 if (state != Volume::State_Mounted && state != Volume::State_Shared) {
San Mehata2677e42009-12-13 10:40:18 -0800306 return;
307 }
308
309 if ((dev_t) MKDEV(major, minor) == mCurrentlyMountedKdev) {
310 /*
311 * Yikes, our mounted partition is going away!
312 */
313
314 snprintf(msg, sizeof(msg), "Volume %s %s bad removal (%d:%d)",
315 getLabel(), getMountpoint(), major, minor);
316 mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeBadRemoval,
317 msg, false);
San Mehat1a06eda2010-04-15 12:58:50 -0700318
319 if (mVm->cleanupAsec(this, true)) {
320 SLOGE("Failed to cleanup ASEC - unmount will probably fail!");
321 }
322
Ken Sumrall0b8b5972011-08-31 16:14:23 -0700323 if (Volume::unmountVol(true, false)) {
San Mehat97ac40e2010-03-24 10:24:19 -0700324 SLOGE("Failed to unmount volume on bad removal (%s)",
San Mehata2677e42009-12-13 10:40:18 -0800325 strerror(errno));
326 // XXX: At this point we're screwed for now
327 } else {
San Mehat97ac40e2010-03-24 10:24:19 -0700328 SLOGD("Crisis averted");
San Mehata2677e42009-12-13 10:40:18 -0800329 }
Ethan75a3e1a2010-07-21 23:07:51 +0800330 } else if (state == Volume::State_Shared) {
331 /* removed during mass storage */
332 snprintf(msg, sizeof(msg), "Volume %s bad removal (%d:%d)",
333 getLabel(), major, minor);
334 mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeBadRemoval,
335 msg, false);
336
337 if (mVm->unshareVolume(getLabel(), "ums")) {
338 SLOGE("Failed to unshare volume on bad removal (%s)",
339 strerror(errno));
340 } else {
341 SLOGD("Crisis averted");
342 }
San Mehata2677e42009-12-13 10:40:18 -0800343 }
San Mehatfd7f5872009-10-12 11:32:47 -0700344}
San Mehat49e2bce2009-10-12 16:29:01 -0700345
San Mehatdd9b8e92009-10-21 11:06:52 -0700346/*
San Mehata2677e42009-12-13 10:40:18 -0800347 * Called from base to get a list of devicenodes for mounting
San Mehatdd9b8e92009-10-21 11:06:52 -0700348 */
San Mehata2677e42009-12-13 10:40:18 -0800349int DirectVolume::getDeviceNodes(dev_t *devs, int max) {
San Mehatdd9b8e92009-10-21 11:06:52 -0700350
351 if (mPartIdx == -1) {
San Mehata2677e42009-12-13 10:40:18 -0800352 // If the disk has no partitions, try the disk itself
San Mehatdd9b8e92009-10-21 11:06:52 -0700353 if (!mDiskNumParts) {
San Mehata2677e42009-12-13 10:40:18 -0800354 devs[0] = MKDEV(mDiskMajor, mDiskMinor);
355 return 1;
San Mehatdd9b8e92009-10-21 11:06:52 -0700356 }
357
San Mehata2677e42009-12-13 10:40:18 -0800358 int i;
359 for (i = 0; i < mDiskNumParts; i++) {
360 if (i == max)
361 break;
362 devs[i] = MKDEV(mDiskMajor, mPartMinors[i]);
363 }
364 return mDiskNumParts;
San Mehatdd9b8e92009-10-21 11:06:52 -0700365 }
San Mehata2677e42009-12-13 10:40:18 -0800366 devs[0] = MKDEV(mDiskMajor, mPartMinors[mPartIdx -1]);
367 return 1;
San Mehat49e2bce2009-10-12 16:29:01 -0700368}
Ken Sumrall29d8da82011-05-18 17:20:07 -0700369
370/*
371 * Called from base to update device info,
372 * e.g. When setting up an dm-crypt mapping for the sd card.
373 */
374int DirectVolume::updateDeviceInfo(char *new_path, int new_major, int new_minor)
375{
376 PathCollection::iterator it;
377
378 if (mPartIdx == -1) {
379 SLOGE("Can only change device info on a partition\n");
380 return -1;
381 }
382
383 /*
384 * This is to change the sysfs path associated with a partition, in particular,
385 * for an internal SD card partition that is encrypted. Thus, the list is
386 * expected to be only 1 entry long. Check that and bail if not.
387 */
388 if (mPaths->size() != 1) {
389 SLOGE("Cannot change path if there are more than one for a volume\n");
390 return -1;
391 }
392
393 it = mPaths->begin();
394 free(*it); /* Free the string storage */
395 mPaths->erase(it); /* Remove it from the list */
396 addPath(new_path); /* Put the new path on the list */
397
Ken Sumrall0b8b5972011-08-31 16:14:23 -0700398 /* Save away original info so we can restore it when doing factory reset.
399 * Then, when doing the format, it will format the original device in the
400 * clear, otherwise it just formats the encrypted device which is not
401 * readable when the device boots unencrypted after the reset.
402 */
403 mOrigDiskMajor = mDiskMajor;
404 mOrigDiskMinor = mDiskMinor;
405 mOrigPartIdx = mPartIdx;
406 memcpy(mOrigPartMinors, mPartMinors, sizeof(mPartMinors));
407
Ken Sumrall29d8da82011-05-18 17:20:07 -0700408 mDiskMajor = new_major;
409 mDiskMinor = new_minor;
410 /* Ugh, virual block devices don't use minor 0 for whole disk and minor > 0 for
411 * partition number. They don't have partitions, they are just virtual block
412 * devices, and minor number 0 is the first dm-crypt device. Luckily the first
413 * dm-crypt device is for the userdata partition, which gets minor number 0, and
414 * it is not managed by vold. So the next device is minor number one, which we
415 * will call partition one.
416 */
417 mPartIdx = new_minor;
418 mPartMinors[new_minor-1] = new_minor;
419
420 mIsDecrypted = 1;
421
422 return 0;
423}
424
425/*
Ken Sumrall0b8b5972011-08-31 16:14:23 -0700426 * Called from base to revert device info to the way it was before a
427 * crypto mapping was created for it.
428 */
429void DirectVolume::revertDeviceInfo(void)
430{
431 if (mIsDecrypted) {
432 mDiskMajor = mOrigDiskMajor;
433 mDiskMinor = mOrigDiskMinor;
434 mPartIdx = mOrigPartIdx;
435 memcpy(mPartMinors, mOrigPartMinors, sizeof(mPartMinors));
436
437 mIsDecrypted = 0;
438 }
439
440 return;
441}
442
443/*
Ken Sumrall29d8da82011-05-18 17:20:07 -0700444 * Called from base to give cryptfs all the info it needs to encrypt eligible volumes
445 */
446int DirectVolume::getVolInfo(struct volume_info *v)
447{
448 strcpy(v->label, mLabel);
449 strcpy(v->mnt_point, mMountpoint);
450 v->flags=mFlags;
451 /* Other fields of struct volume_info are filled in by the caller or cryptfs.c */
452
453 return 0;
454}