init.rc: Restored TCP performance tuning

This patch tunes the TCP buffer sizes for high
performance data links including global max rmem
and wmem.

Change-Id: I78dc92bc8190883686678230b0a34a8e32507fa5
CRs-Fixed: 439205 435908
init: Allow load of lpm.rc by parsing a cmdline argument

A usage example could be:
BOARD_LPM_BOOT_ARGUMENT_NAME := lpm_boot
BOARD_LPM_BOOT_ARGUMENT_VALUE := 1
Where lpm_boot is the argument to read, and 1 the value of it when kernel says we should enter offline charging mode

Change-Id: I2b073a0968d65ba9e3bf6b397280241c1fb0c0f9
Add support for -R (recurse) to init chown builtin.

This is helpful for setting ownerships on entire directory trees,
such as sysfs and selinuxfs, particularly when the precise set of
files is dynamically generated at runtime.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>

Change-Id: I81070ea36fd7ffcab4ee8b3ef1bb0028d4b7839c
init: uevent: Add msm video symbolic link handling

Create meaningful symbolic links for video encode/decode
devices based on link_name sysfs node so that video client
doesn't have to rely on dynamic dev node names like device32,
device33 etc.

(cherry picked from commit d26280b5d327994c3c89c573de7738b3f47b8600)
(cherry picked from commit c8f57166fadd26648bd9ee0a979a789c944ccba3)
(cherry picked from commit 72e4c35b308270f44795ebcc196319096397c6c1)
(cherry picked from commit aec73795517e7f49c5ebbea611da612b99ba75fb)

Change-Id: Id308a10d3e601616b63ecd1373809c96f0d04435
init: Check for symlinks with lstat() not open()

Using open() with an O_NOFOLLOW flag will result in a file falsely
being determined to be a symlink if the open fails for another
reason.

For example, a character device that isn't ready due to the
underlying hardware not being initialized yet will fail to open()

An example of this are any CG2900 device files prior to
execution of ste-cg29xx_ctrl

This uses lstat() instead of open() with O_NOFOLLOW to check
whether a file is a symlink or not.

Change-Id: Ie0d8d94b426c84c29b1b04d41a4cc15536cb307c
Merge "Add support for -R (recurse) to init chown builtin." into android-4.4
Revert "sdcard: Allow building as a static library"

For some reason (maybe gcc) the sdcard daemon is broken for some devices

I can't reproduce this error but I got some logs below:

from logcat
http://paste.omnirom.org/view/380f6994

from kernel
http://paste.omnirom.org/view/3ebfe137

This reverts commit 1e8b51531e4d9ff356da0c09da4bf2860d523c8c.

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I56b0b8c0b50fdc53101494557c773ce717273bd0
Merge "Revert "sdcard: Allow building as a static library"" into android-4.4
init: fix cache permissions

required fo dexopt

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I299509b68e82a2b3c60eabec1998eaa12c60bc71
init: set permissions on governors

1. interactive
2. ondemand

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: Ic609ba53981fa0156c1d0d1decf32bbc61a38df9
system: core: increase the polling time for remount_ro to 3600

eMMC4.5 introduces an addition of cache on the device.
We experienced long flush durations in some of the devices,
and therefore the adb reboot resets the target before the flush
completes.
Latest tests show that increasing it to 2400 wasn't enough thus
it was increased to 3600.

Conflicts:
	libcutils/android_reboot.c

Change-Id: Ifbe7af16aa1861d0d57c808b0240361c0317d5c5
init: Fix queue_all_property_triggers with nonexistent properties

Don't queue actions for "on property=*" if the property does not exist.
This fixes these errors on boot:

    init: property 'sys.powerctl' doesn't exist while
    expanding '${sys.powerctl}'
    init: powerctl: cannot expand '${sys.powerctl}

Change-Id: I3bd354d73a860f856be5df2c654f940445f9efd9
Add support for socket security context specification.

Add an optional argument to the socket option for specifying
a SELinux security context for the socket.  Normally the socket
security context is automatically computed from the service security
context or set using the seclabel option, but this facility allows
dealing with two scenarios that cannot be addressed using the existing
mechanisms:
1) Use of logwrapper to wrap a service.
In this case, init cannot determine the service security context
as it does not directly execute it and we do not want logwrapper
to run in the same domain as the service.

2) Situations where a service has multiple sockets and we want to
label them distinctly.

Signed-off-by: Humberto Borba <humberos@gmail.com>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Change-Id: I7ae9088c326a2140e56a8044bfb21a91505aea11
<system/audio.h>: do not use GNU old-style field designators

Avoiding the use of GCC extensions improves code
portability

Change-Id: I896118eb30951903b562bab95de3bc18d22db98a
Signed-off-by: DHOMD <DHO@dho.im>
restorecon_recursive("/sys") speed boot time

Currently, the restorecon_recursive("/sys") call in
init.c takes approx 2 seconds on hammerhead. This change
reduces the delay to 1.2 seconds.

1) Avoid double stat call when using nftw (time savings
of 0.3 seconds)
2) Avoid the repeated calls to is_selinux_enabled() (time
savings of 0.5 seconds)

Avoid calling lsetfilecon if the file is already properly
labeled. This doesn't speed up the restorecon on /sys,
but it should help when handling files on /data.

Change-Id: Icf344edc5bfc9520d3a0ebd9527a065d29832f87
Fix a bunch of small system/core bugs.

Missing frees in:
  adb/file_sync_client.c
  fastboot/fastboot.c
  libsparse/output_file.c

Missing closedirs in:
  adb/file_sync_service.c
  cpio/mkbootfs.c
  libcutils/dir_hash.c

Potential buffer overrun in:
  gpttool/gpttool.c

Incorrect NULL check in:
  libsparse/backed_block.c

Bug: https://code.google.com/p/android/issues/detail?id=61564
Change-Id: If97838a9e73a77aef7f416c31c237ce1fca4ce21
adbd: Don't close/reopen FFS ep0 on disconnect

In case of bulk read/write failure or disconnect, transport_usb
calls usb_ffs_kick in order to force the daemon to re-open the
FunctionFS ep files as a way to soft restart the kernel driver.

However, there's no reason to always close the ep0 file, as it
would need to be reopened and the descriptors rewritten--this
is unnecessary, especially in the simple/frequent case of cable
disconnect, and causes the kernel driver to unbind and bind *all*
of the function drivers. This is causing USB Chapter 9 tests to fail.

Thus, try to reuse the same ep0 file handle across reconnects. In
case there is a failure, the ep1/ep2 opens would fail and all the
file handles get dropped. For the adb root case, the entire daemon
gets restarted anyway.

CRs-fixed: 571846
Change-Id: I0840085c52a0795dcb2d751c39aa4a436c039ee2