recovery: Revenge of MiniVold

 * Vold has been refactored to be friendly to an environment such as
   recovery. Using Vold will eliminate many hacks and add previously
   unavailable features.
 * Link with libminivold and create a pseudo-binary to launch as a
   service in recovery.
 * Libvoldclient is an event-driven client for controlling the daemon.
 * Handles device hotplug and automatic mounting, if desired.
 * Manages USB storage
 * Can check and format volumes using any supported filesystem
 * Dynamically generate all storage paths
 * Dynamically refresh menus affected by storage changes
 * Fixed wall-of-compile-warnings and const-correctness in extendedcommands.c
 * Misc cleanups
 * Say goodbye to "apply /sdcard/update.zip". You have served us well.

Change-Id: I13a3d72493f8fce7c19f192f9e94ad22cb60a2d2
recovery: Don't enable UMS function unless needed

 * This causes problems with some hosts. Only enable the composition if
   the user actually turns UMS on.

Change-Id: I18b109a3416d55ef711d346685d46a93851da332
recovery: Don't automount external storage at startup

 * Do it for hotplug and on-demand only.

Change-Id: I9c0ca96203a8ff1f16fa42e31f426cd25bdaba1d
recovery: Add sdcard daemon

 * Our custom ext4 support for sdcards needs it.

Change-Id: Ie1c22c1d6a3255cbe3a7ff3c072243f4a5461a17
recovery: try to write EMMC partitions more reliably

Nexus 4 has flash errors that manifest during large writes (eg, of the
radio partition).  Writes of some blocks seem to be dropped silently,
without any errors being returned to the user level.

Make two changes to the partition-writing code:

- break it up into 1MB writes instead of writing partitions with a
  single fwrite() call.  Pause for 50ms in between every chunk.

- read the partition back after writing and verify that we read what
  we wrote.  Drop caches before reading so we (hopefully) are reading
  off the actual flash and not some cache.

Neither of these should be necessary.

Bug: 9602014

Change-Id: Ice2e24dd4c11f1a57968277b5eb1468c772f6f63
recovery: write partitions more conservatively

Write and verify partitions using write(2) and read(2) rather than the
stdio functions.  Read and write in 4kb blocks.  When writing, fsync()
every 1MB.

Bug: 9602014
Change-Id: Ie98ce38e857786fc0f4ebf36bb5ffc93b41bc96f
recovery: sleep after writing partition and closing it

Another speculative attempt to get everything we write actually stored
to the device.

Change-Id: Icf40b0741b4c535e55ea34848073a97d90dc0e70
recovery: Support for compressed backups

 * Systems are getting quite large nowadays, and performing backups
   without using compression is wildly inefficient. A good compression
   algorithm also gives us a big speedup on backup and restore times since
   the process is entirely I/O bound.
 * Bring in pigz (via libminipigz), which is a multithreaded version of
   gzip and pipe tar backups and restores thru it.
 * Autodetect compressed images where appropriate, and add a menu option
   to select the compressed format by default.
 * Also fixed various trivial warnings and const-correctness issues.

Comparison on my Flo device right now:

Uncompressed:
  1868512   2013-08-24.07.10.08

Compressed:
  1149300   2013-08-24.06.51.14

Change-Id: I55025c993662142f5b647e600daf6885f9be6667
recovery: all vold loglines deserve newlines

Self-nominating for the most impactful commit CM has seen
since 2009.

Change-Id: I450167573b7cf6db1a92227aef7ff3ed95856dd5
recovery: close zip archive after installation

Otherwise recovery will restart itself (gets killed by vold for
leaving a file open) when reboot is selected.

Change-Id: I915c3082bd99ca994c3a4cbe5ba913866051bc0e
recovery: Cleanups

 * Fixing warnings, const-correctness
 * Split the multi-call list out into recovery_cmds.h

 * This is part of an effort to improve security in recovery mode.

Change-Id: I1e913345c94537225639183434ea4803348ad335
recovery: only use vold format for exact path match

Otherwise when formatting /sdcard/.android_secure, it will be
matched to /sdcard and vold will format the entire /sdcard.

Change-Id: Ifc26121f982b391b4ccf582b6162ab76feb72cae
recovery: don't overallocate for get_android_secure_path

We simply need the space to fill both strings and a final null.

a char pointer is a lot larger than a char ;)

Change-Id: I3472e1a9978fb2f6d439d4af9c072a98cec0cd19
recovery: fix --update_package using legacy path

When using legacy path, recovery will not be able to mount the
correct device. Fix by resolving the symlink before installing.

Change-Id: Ibb268908458c49de09204a1a0ba3143e83ccc0c4
Merge "recovery: fix --update_package using legacy path" into cm-10.2
Revert "recovery: fix --update_package using legacy path"

Backing this out for now to prevent a tragic recovery loop
where it'll keep restarting to flash from /cache/recovery/command
and crash from signature verification bug. The loop can only
be ended by removing the command file via adb.

This reverts commit ca028615e43fe09c3dcceeb47ca8cf3ceb08c2b4.

Change-Id: Iea29ee04871e136c680df699f5d19570aba44113
Merge "Revert "recovery: fix --update_package using legacy path"" into cm-10.2
recovery: Don't link with minivold

 * There are issues with conflicting symbols in OpenSSL that cause some
   nasty problems. Let's just build minivold as a standalone binary so
   we avoid anything like this in the future as well.

Change-Id: I691a403bb377171989cba4ff74a515050862be40
Revert "Revert "recovery: fix --update_package using legacy path""

This reverts commit ea09a67a552e58835f82382cc76b59b892535468.

Change-Id: I172ec887dd52e373d249d61b22eccaaae03dfb75
Recovery: Loki patching support

Add support for automatically checking and making loki images
for locked bootloader bypass on loki supported devices. Loki
support is enabled with ENABLE_LOKI_RECOVERY.

Change-Id: I81fe267d58f0dda18a790e25df223f011dca3e37