DO NOT MERGE. Fix crash in vold

b/11239345

Change-Id: I46a8d6b38e3c093e20e1e5c4f01efc13d1960ad4
merge in klp-release (no-op)
Merge "DO NOT MERGE. Fix crash in vold" into klp-dev
Extract UUID and label from inserted volumes.

Uses "blkid" tool to extract metadata from an inserted volume, and
reports it up to the framework.  This needs to happen in vold, since
only the FUSE-wrapped volume is visible to userspace.

Remove autorun sanitization, since FUSE takes care of this now.

Bug: 11175082
Change-Id: Ie69b38011ad6011bfb50e40d4f35a29e02150c19
Clean up ASEC unmounting on physical storage.

When physical devices are unsafely removed, unmountAllAsecsInDir()
fails to find any ASECs, and leaves them all mounted, preventing the
rest of volume from going down.

Now we examine all ASEC containers, and remove when on external
storage, or when the storage media is no longer found.

Bug: 11175082
Change-Id: Iffa38ea43f7e5ad78b598374ebeb60a8727d99fd
Merge "Extract UUID and label from inserted volumes." into klp-dev
Merge "Clean up ASEC unmounting on physical storage." into klp-dev
Use correct minor device number to format SD card

When formatting SD card partitions, instead of assuming partition
minor device numbers start from 1, use (minor device number of
the disk device + 1) as the starting point.

Bug: 11352632
Change-Id: I69d37f57aec6b62fe2a055470f7525ec09dc3859
Signed-off-by: Blair Prescott <blairp@broadcom.com>
Signed-off-by: Pierre <pierre@broadcom.com>
Handle missing UUID/LABEL from blkid.

Bug: 11627785
Change-Id: Iee757abbc3795234f41d513a6aed8ad33855cb7a
vold: cryptfs: Don't update KDF without validating pwd/key.

Prior to this, the Key derivation function would get
 blindly updated even if the user entered the wrong password.
Now, we only attempt to upgrade the KDF if the pwd/key have
been verified (i.e. after a successful mount).

Bug: 11460197
Change-Id: I0469228cc9b87c47754e8ca3c7146651da177da5
Allow pre-configured device pairs to switch mountpoints

Original CM patch by Ricardo Cerqueira <cyanogenmod@cerqueira.org>,
message from commit dc8d157d73fb88ee33b38e724a8aabe7d5e53eee follows:

  The use-case for this are devices with internal extended storage
  (pseudo-SDCard emmc) and an actual microSD card reader.
  In CM, we choose to use the microSD as primary storage, and leave
  the internal partition mostly unused; some users usually come up with
  imaginative and data-destroying ways of working around that.

  This allows us to specify a pair of mountpoints which can be
  switched from a user preference. For this vold.fstab:

  -----
  dev_mount sdcard /mnt/sdcard ...<path-to-microSD-sysfs>
  dev_mount emmc /mnt/emmc ...<path-to-emmc-partition>
  -----

  We can add to build.prop:
  "ro.vold.switchablepair=/mnt/sdcard,/mnt/emmc"

  A persistent toggle (persist.sys.vold.switchexternal), controllable
  through CMParts, can be presented to the user to allow choosing
  something other than our default as primary storage.

In Android 4.4 (CM11.0) vold uses labels instead of mount points in the
fstab files, so instead of ro.vold.switchablepair the property is named
ro.vold.switchablelabels -- this way both properties can be specified
and the same device tree can be used for pre-4.4 versions as well.
Logging-fu