recovery: Fix adb backup

Using http://goo.gl/6AQ3u might fail. The resulting backup
consists of a tarball of the filesystem being backed up,
but it might end up truncated, for reasons yet unknown.

Issuing adb backup data, for instance, causes recovery to
call tar, streaming it's stdout <a> through a socket <b>.
The adb client reads from <b> and copies what it to the
final backup file.

Somehow, sometimes, not all the content generated at <a> is
read at the adb client, which causes a truncated tar file
to result. I'm unsure why this happens: Doesn't <a> get
flushed before <b> is closed? Or is it that <b> is closed
with outstanding data in its buffers, which never make it
to the other side?

Either calling sync() or sleep() seems to remedy the issue,
but I'm not sure if sync() has any effect on sockets or
pipes. I also understand that sleeping for some time is not
the best solution to a race condition.

Therefore, I'm adding calls to sync() and sleep() and
waiting for reviews from someone who knows better how
these calls work.

Patch set 2: Remove sync() call

Change-Id: If4733066fdad809eb73e87c670f37acc4debe82d
Remove (un)mount option for datamedia partitions

When /sdcard is /data/media, it can be formatted but it cannot be
mounted/unmounted independently of /data (aside from creating or
destrying the symlink). This removes /sdcard from the mountable
volumes list, but leaves it as a formattable partition.

Change-Id: If59e4516a12da4589ffb0dbd19702f219260370e
Fix compiler warning: redefinition in extendedcommands.c

ITEM_APPLY_SDCARD is already defined in recovery_ui.h, fortunately
also as 1.

This suggestion comes from Phil3759.

Change-Id: I9ac370ca9640d61b6b96f60954d35f7aa458d75b
Merge "recovery: Fix adb backup" into cm-10.1
Merge "Remove (un)mount option for datamedia partitions" into cm-10.1
Merge "Fix compiler warning: redefinition in extendedcommands.c" into cm-10.1
move "install zip from sideload" to installation submenu

* Also includes the below commit:

fix installation from internal sdcard

bug introduced in previous commit

Change-Id: If41d409801e9a58df9515ac783bf503f80909d3e

* I've done some minor changes to the original commit,
  which includes but is not limited to moving the
  "install zip from sideload" above "/sdcard/update.zip".

Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org>
Change-Id: I27a763a0d41085719a6c7d9c3b8a20fbcae4b072
Fix the potential segmentation fault

Extral newline can trigger recovery segmentation fault
Test case:
host$ adb shell 'echo -en "--update_package=ota_update.zip\n--show_text\n\n" > /cache/recovery/command'
host$ adb reboot recovery

Change-Id: If1781c1f5ad94a273f1cb122b67cedd9fb562433
Signed-off-by: Jin Feng <jin88.feng@gmail.com>
recovery: use just the mount point instead of the full path

When resorting to using mount because a block device uses 'auto'
filesystem, we should use the mount point and not the full path.
This fixes an issue with nandroid to external sd on yuga.

Change-Id: Idbff944ea6d5af9112644c2ed46e23ea0a33e5ee
Merge "recovery: use just the mount point instead of the full path" into cm-10.1
fix stat usage

Change-Id: Iab3290adca1602a23fc407d2b3f50b9aeac60389
Fix usage of stat vs statfs

Change-Id: Id59b79f079c587630f5f6ed0418a45f2b8cd99ff

Conflicts:
	nandroid.c
Bump to 6.0.3.3

Change-Id: I089fad25002a28cc5b368288c5bb34c37f9752bc
Update for zlib changes

Depends on http://review.cyanogenmod.org/#/c/37912/

Change-Id: I7d541813f520c3a3187f6c193e47b201cd220957
SELinux: don't suppress the "no file_contexts" message on the UI

Change-Id: I1456e7e2d2a1f3e143c084e1410dd31c505793ad
add --headless mode

Change-Id: I6338ed1d093a8db20250bd060cf97896db268976
Merge "add --headless mode" into cm-10.1
more headless fixes

Change-Id: I25243f67b8bcbef41867497b442d1b7f38f638dd
Remove "fix permissions" option

Original discussion here: http://review.cyanogenmod.org/45559

Patchset 2: really remove the option
Patchset 3: fix options that I broke on ps2

Signed-off-by: Michael Bestas <mikeioannina@gmail.com>

Change-Id: I54877a24444c24a296c8c044efd977f30cc66de4
Add power off & reboot to bootloader mode in advanced menu

Also:
Cleanup leftovers from previous poweroff option
Always ensure a clean reboot (Thanks to PhilZ for his implementation)

Bootloader option defaults to "bootloader" (fastboot mode), it can be overriden
by defining "ro.bootloader.mode=download" prop for samsung download mode
We leave reboot to bootloader option always enabled, that way we can
override the get_filtered_menu_selection bug that breaks the order
of the options when NULLifying menu options.

Signed-off-by: Michael Bestas <mikeioannina@gmail.com>

Change-Id: I6d674b37ab41ab342b105993719277360b4707e4