diff options
author | San Mehat <san@google.com> | 2009-10-21 11:06:52 -0700 |
---|---|---|
committer | San Mehat <san@google.com> | 2009-10-21 11:07:21 -0700 |
commit | dd9b8e92aaf330b48ddb40a7380588ef92b53de6 (patch) | |
tree | 230fed516faca555d4a4d247ec4b24cfac3c0c70 /DirectVolume.cpp | |
parent | 49e2bce5b74129c26a35e25d4693cbfe98c4688e (diff) | |
download | system_vold-dd9b8e92aaf330b48ddb40a7380588ef92b53de6.tar.gz system_vold-dd9b8e92aaf330b48ddb40a7380588ef92b53de6.tar.bz2 system_vold-dd9b8e92aaf330b48ddb40a7380588ef92b53de6.zip |
vold2: Some more work on partitioning support
Signed-off-by: San Mehat <san@google.com>
Diffstat (limited to 'DirectVolume.cpp')
-rw-r--r-- | DirectVolume.cpp | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/DirectVolume.cpp b/DirectVolume.cpp index 515a33a..cd12cf4 100644 --- a/DirectVolume.cpp +++ b/DirectVolume.cpp @@ -31,6 +31,8 @@ DirectVolume::DirectVolume(const char *label, const char *mount_point, int partI mPartIdx = partIdx; mPaths = new PathCollection(); + for (int i = 0; i < MAX_PARTITIONS; i++) + mPartMinors[i] = -1; } DirectVolume::~DirectVolume() { @@ -80,7 +82,8 @@ int DirectVolume::handleBlockEvent(NetlinkEvent *evt) { } void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) { - mDiskMaj = atoi(evt->findParam("MAJOR")); + mDiskMajor = atoi(evt->findParam("MAJOR")); + mDiskMinor = atoi(evt->findParam("MAJOR")); mDiskNumParts = atoi(evt->findParam("NPARTS")); int partmask = 0; @@ -105,6 +108,12 @@ void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt) int minor = atoi(evt->findParam("MINOR")); int part_num = atoi(evt->findParam("PARTN")); + if (major != mDiskMajor) { + LOGE("Partition '%s' has a different major than its disk!", devpath); + return; + } + mPartMinors[part_num -1] = minor; + mPendingPartMap &= ~(1 << part_num); if (!mPendingPartMap) { LOGD("Dv:partAdd: Got all partitions - ready to rock!"); @@ -120,7 +129,37 @@ void DirectVolume::handleDiskRemoved(const char *devpath, NetlinkEvent *evt) { void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt) { } +/* + * Called from Volume to determine the major/minor numbers + * to be used for mounting + */ int DirectVolume::prepareToMount(int *major, int *minor) { - errno = ENOSYS; - return -1; + *major = mDiskMajor; + + if (mPartIdx == -1) { + /* No specific partition specified */ + + if (!mDiskNumParts) { + *minor = mDiskMinor; + return 0; + } + + /* + * XXX: Use first partition for now. + * The right thing to do would be to choose + * this based on the partition type. + * + */ + + *minor = mPartMinors[0]; + return 0; + } + + if (mPartIdx - 1 > mDiskNumParts) { + errno = EINVAL; + return -1; + } + + *minor = mPartMinors[mPartIdx-1]; + return 0; } |