Unmount all asec apps before encrypting

Now that forward locked apps are stored on /data as asec image files
that are mounted, they need to be unmounted before /data can be unmounted
so it can be encrypted.

Change-Id: I7c87deb52aaed21c8ad8ce8aceb7c15c2338620a
vold: allow override of MAX_PARTITIONS for devices with > 4 partitions

Change-Id: Iec4de6e7e5ad52a6dfa45952bb19104f500d9c58a
Reintroduce BOARD_VOLD_EMMC_SHARES_DEV_MAJOR

Code taken from CM7's vold
Give user read-write access to non-primary storage
Allow mounting of multiple volumes via mass storage (vold part)

commit 662006fe5419803938790a164cb1ba73b05e3f41
Author: Pawit Pornkitprasan <p.pawit@gmail.com>
Date:   Sat Dec 3 13:31:46 2011 +0700

    Extracted primary storage detection into isPrimaryStorage()

    Change-Id: Ia76ace183869283e7e6563ea8d5eb919283ffe55

commit 0303f8b0722bfac3c1b0a522f42c921e3ed4666a
Author: Genokolar <genokolar@gmail.com>
Date:   Sat Oct 1 21:34:00 2011 +0800

    Add custom second lun number support

    like u8800 have different second lun number
    use TARGET_USE_CUSTOM_SECOND_LUN_NUM options to custom lun number

    Change-Id: I36f8c92f1f8041efeaa0304795a11eb1cc49e5e1
    (cherry picked from commit 24860389177df3aa839a8eb77d79608b15e0af8d)

commit 4b99cd585d12fa47b2f8d99cde430f37d2fe7293
Author: Alex Zepeda <alex@inferiorhumanorgans.com>
Date:   Mon Jul 18 10:55:33 2011 -0700

    Use a list of possible lun paths instead of a hardcoded one.

    This will easily play nice with kernels that use gadget drivers and
    function drivers (ex: tethering support doesn't require a new vold).

    Change-Id: I71796114501cf2d64dea5fd077ac5baf54873af4

commit 1f822e51cde73bc0d8e1b575848614f696534a88
Author: mik_os <kiril.mik.os@gmail.com>
Date:   Mon Feb 14 16:10:36 2011 +0200

    Added ability to use custom lun path.

    Change-Id: If39e445383c0ea0d64556df5708de80c06056174
    (cherry picked from commit 5edf3ce983ddd3ffed01c398244493ab962e3304)

commit baa2d75929be1bebb1e04d93044d7718460d5b14
Author: Josh Stone <cuviper@gmail.com>
Date:   Sat Jan 22 11:52:01 2011 -0800

    vold: cleanupAsec should only do work for EXTERNAL_STORAGE

    For devices like DINC which have both emmc and sdcard storage, only one
    of these is used for ASEC mounts.  When we're unmounting volumes, we
    need to discriminate which is which before forcing ASEC closures.

    Change-Id: I94efda36414bb0eb2c4c4e31891ce4f318582a8e
    (cherry picked from commit 61272bf32aff5515aa6f48acb2e8ea7e95b47aa3)

commit 73aeea8a3c834d7d822edc088f19934843511779
Author: Tony Layher <layhertony@gmail.com>
Date:   Sun Jan 2 19:17:39 2011 -0500

    Fix build break on Vold, have to remove uneeded code

    Change-Id: Ie594367d3675cf25cf4c86703aaa01055a9892a6
    (cherry picked from commit f04648bda6bf58391f46fc8694718e5878e4abb9)

commit 332a373eaadb487f069fd86f0876abade84f7189
Author: Tony Layher <layhertony@gmail.com>
Date:   Sun Jan 2 14:48:26 2011 -0500

    Forward Port of vold changes for having 2 UMS devices and use only EXTERNAL_STORAGE for ASEC

    Change-Id: Ia26b4251226103441afb2656ea411c68525974c9

Change-Id: I5695a0441a6672e9c1c2f2aef95c38f0b08a7145
vold: add ro.vold.umsdirtyratio property

This allows control of what /proc/sys/vm/dirty_ratio is used when USB mounting.
Some platforms like the HTC Desire (bravo) get a _HUGE_ performance boost when
writing to the sdcard when USB mounting if this is set to 20 (which is the default)
on the HTC Desire.

This addresses this issue: http://code.google.com/p/cyanogenmod/issues/detail?id=2949

Basicly it makes it possible to undo or control the effect of this commit:
https://github.com/CyanogenMod/android_system_vold/commit/a28056b38275003895ff5d9576681aca01544822

Change-Id: I86b7bbd02695fb0c19f39448714a219257bf806f
DirectVolume: handle discs with multiple major numbers

CFlag: BOARD_VOLD_DISC_HAS_MULTIPLE_MAJORS

Allows Direct Volume to handle discs with multiple major numbers.
Needed on Samsung Galaxy S II and variants.

For example:
mmcblk0p1 - 179:0
mmcblk0p2 - 179:1
mmcblk0p3 - 179:2
mmcblk0p4 - 256:0
mmcblk0p5 - 256:1

Change-Id: I633ac882a721cde25f0df779b4028efa6be15750
vold: fix an offset one bug that makes partition 4 unusable

Change-Id: Ic8e18e6191ad7ee33162e36060b57a6802cf0883
Add auto-mount and fake SD card support

Modified from:
http://git.android-x86.org/?p=platform/system/vold.git;a=commit;h=123572c9de7194344509d4094a397749daec0c59

Change-Id: I853dc273ff57623ec1e6d9a8e442b3d9702596ce
vold: Add ntfs (read-only) support.

See http://review.cyanogenmod.com/#change,7457 for more info.

Change-Id: Ic841e73be6435e8bbbb22984cc749e27c46826e8
vold: Allow pre-configured device pairs to switch mountpoints

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.

Change-Id: I9559fa442c833e3168287d820b7b8347736abb15
vold: fix handling of discs with multiple majors on DirectVolume::getShareDevice()

The method DirectVolume::getShareDevice() returns an invalid device if the partition referenced by
mPartIdx is bad. A bad partition is one where the major/minor numbers on disk don't match what is
expected.

The original major number is stored for bad partitions so the fix attempts to retrieve it and
return it if applicable.

This fix is one part of fixing ICS encryption on the i777 (and possibly other devices) where bad
partitions may exist.

Change-Id: Ic3b05dbf45315bde502c151f53928ca1891483f0
Merge branch 'jb-release' of https://android.googlesource.com/platform/system/vold into aosp