Merge "NTFS-3G: use newer libfuse-light in pie." into android-9.0
diff --git a/etc/init.recovery.logd.rc b/etc/init.recovery.logd.rc
index 7bdbfb8..423039c 100644
--- a/etc/init.recovery.logd.rc
+++ b/etc/init.recovery.logd.rc
@@ -1,20 +1,8 @@
 on load_all_props_action
     start logd
-    start logd-reinit
 
 on load_persist_props_action
     start logd
-    start logd-reinit
-
-on post-fs
-    start logd
-
-on post-fs-data
-    start logd
-
-on property:vold.decrypt=trigger_load_persist_props
-    start logd
-    start logd-reinit
 
 service logd /sbin/logd
     class core
@@ -23,8 +11,3 @@
     socket logdw dgram 0222 logd logd
     group root system
     seclabel u:r:logd:s0
-
-service logd-reinit /sbin/logd --reinit
-    oneshot
-    disabled
-    seclabel u:r:logd:s0
diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml
index 7a60120..9b525f0 100755
--- a/gui/theme/common/languages/en.xml
+++ b/gui/theme/common/languages/en.xml
@@ -109,7 +109,6 @@
 		<string name="wipe_cache_dalvik_confirm">Wipe Cache &amp; Dalvik?</string>
 		<string name="wipe_dalvik_confirm">Wipe Dalvik?</string>
 		<string name="wiping_cache_dalvik">Wiping Cache &amp; Dalvik...</string>
-		<string name="wiping_dalvik">Wiping Dalvik...</string>
 		<string name="wipe_cache_dalvik_complete">Cache &amp; Dalvik Wipe Complete</string>
 		<string name="wipe_dalvik_complete">Dalvik Wipe Complete</string>
 		<string name="swipe_wipe">Swipe to Wipe</string>
diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk
index 5592a8c..5c0b441 100644
--- a/prebuilt/Android.mk
+++ b/prebuilt/Android.mk
@@ -21,7 +21,15 @@
     RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/sh
     RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrypto.so
     ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 23; echo $$?),0)
+        RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/grep
+        LOCAL_POST_INSTALL_CMD += $(hide) if [ -e "$(TARGET_RECOVERY_ROOT_OUT)/sbin/egrep" ]; then \
+                                    rm $(TARGET_RECOVERY_ROOT_OUT)/sbin/egrep; fi; ln -sr $(TARGET_RECOVERY_ROOT_OUT)/sbin/grep $(TARGET_RECOVERY_ROOT_OUT)/sbin/egrep; \
+                                    if [ -e "$(TARGET_RECOVERY_ROOT_OUT)/sbin/fgrep" ]; then \
+                                    rm $(TARGET_RECOVERY_ROOT_OUT)/sbin/fgrep; fi; ln -sr $(TARGET_RECOVERY_ROOT_OUT)/sbin/grep $(TARGET_RECOVERY_ROOT_OUT)/sbin/fgrep;
         RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/toybox
+        ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 23; echo $$?),0)
+            RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/dd
+        endif
         ifneq ($(wildcard external/zip/Android.mk),)
             RELINK_SOURCE_FILES += $(TARGET_OUT_OPTIONAL_EXECUTABLES)/zip
         endif
@@ -31,6 +39,9 @@
         ifneq ($(wildcard system/core/libziparchive/Android.bp),)
             RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/unzip
         endif
+        ifneq ($(wildcard external/one-true-awk/Android.bp),)
+            RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/awk
+        endif
     endif
 endif
 RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/pigz
@@ -530,12 +541,11 @@
 ifeq ($(TW_USE_TOOLBOX), true)
     include $(CLEAR_VARS)
     LOCAL_MODULE := mkshrc_twrp
+    LOCAL_MODULE_STEM := mkshrc
     LOCAL_MODULE_TAGS := eng
     LOCAL_MODULE_CLASS := ETC
     LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/etc
     LOCAL_SRC_FILES := $(LOCAL_MODULE)
-    LOCAL_POST_INSTALL_CMD := \
-        $(hide) mv $(TARGET_RECOVERY_ROOT_OUT)/etc/mkshrc_twrp $(TARGET_RECOVERY_ROOT_OUT)/etc/mkshrc
     include $(BUILD_PREBUILT)
 endif
 
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index 7d1b602..6698491 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -43,8 +43,7 @@
 ifeq ($(TW_USE_TOOLBOX), true)
     ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0)
         # These are the only toolbox tools in M. The rest are now in toybox.
-        BSD_TOOLS := \
-            $(if $(filter $(PLATFORM_SDK_VERSION), 23 24), du)
+        BSD_TOOLS :=
 
         OUR_TOOLS := \
             newfs_msdos
@@ -60,9 +59,10 @@
                 stop
         endif
 
-        ifneq (,$(filter $(PLATFORM_SDK_VERSION), 23))
+        ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
             BSD_TOOLS += \
                 dd \
+                du \
 
             OUR_TOOLS += \
                 df \
@@ -165,6 +165,7 @@
     OUR_TOOLS += getevent
     LOCAL_C_INCLUDES += $(TWRP_TOOLBOX_PATH)
     LOCAL_WHOLE_STATIC_LIBRARIES += libtoolbox_dd
+
     ifneq ($(TW_USE_TOOLBOX), true)
         OUR_TOOLS += newfs_msdos
     endif
@@ -288,6 +289,37 @@
 $(TOOLS_H):
 	$(transform-generated-source)
 
+
+ifeq ($(TW_USE_TOOLBOX), true)
+    ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 23; echo $$?),0)
+        include $(CLEAR_VARS)
+        LOCAL_MODULE := dd_twrp
+        LOCAL_MODULE_STEM := dd
+        LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
+        LOCAL_MODULE_TAGS := optional
+        LOCAL_CFLAGS := -include bsd-compatibility.h -DNO_CONV -Wno-unused-parameter
+        LOCAL_C_INCLUDES := system/core/toolbox/upstream-netbsd/include/ system/core/toolbox/upstream-netbsd/bin/dd system/core/toolbox
+
+        LOCAL_SHARED_LIBRARIES := \
+	        libcutils \
+
+        LOCAL_SRC_FILES += \
+            upstream-netbsd/bin/dd/args.c \
+            upstream-netbsd/bin/dd/conv.c \
+            upstream-netbsd/bin/dd/dd.c \
+            upstream-netbsd/bin/dd/dd_hostops.c \
+            upstream-netbsd/bin/dd/misc.c \
+            upstream-netbsd/bin/dd/position.c \
+            upstream-netbsd/lib/libc/gen/getbsize.c \
+            upstream-netbsd/lib/libc/gen/humanize_number.c \
+            upstream-netbsd/lib/libc/stdlib/strsuftoll.c \
+            upstream-netbsd/lib/libc/string/swab.c \
+            upstream-netbsd/lib/libutil/raise_default_signal.c
+
+        include $(BUILD_EXECUTABLE)
+    endif
+endif
+
 # toolbox setenforce is used during init in non-symlink form, so it was
 # required to be included as part of the suite above. if busybox already
 # provides setenforce, we can omit the toolbox symlink
diff --git a/toybox/Android.mk b/toybox/Android.mk
index c88f360..5f6edec 100644
--- a/toybox/Android.mk
+++ b/toybox/Android.mk
@@ -189,6 +189,15 @@
     toys/posix/wc.c \
     toys/posix/xargs.c
 
+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -eq 26; echo $$?),0)
+# Android 8.0 had some tools in different paths
+LOCAL_SRC_FILES += \
+    toys/pending/dmesg.c
+else
+LOCAL_SRC_FILES += \
+    toys/lsb/dmesg.c
+endif
+
 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 23; echo $$?),0)
 # there are some conflicts here with AOSP-7.[01] and CM-14.[01]
 # the following items have been removed for compatibility
@@ -222,14 +231,6 @@
 LOCAL_SRC_FILES += \
     toys/pending/xzcat.c
 endif
-ifeq ($(shell test $(PLATFORM_SDK_VERSION) -eq 26; echo $$?),0)
-# Android 8.0 had some tools in different paths
-LOCAL_SRC_FILES += \
-    toys/pending/dmesg.c
-else
-LOCAL_SRC_FILES += \
-    toys/lsb/dmesg.c
-endif
 
 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 25; echo $$?),0)
 # Android 8.0/8.1 had some tools in different paths
@@ -319,6 +320,7 @@
 endif
 
 LOCAL_CFLAGS += \
+    -std=c99 \
     -std=gnu11 \
     -Os \
     -Wno-char-subscripts \
@@ -330,8 +332,13 @@
     -ffunction-sections -fdata-sections \
     -fno-asynchronous-unwind-tables \
 
-toybox_version := $(shell sed 's/#define.*TOYBOX_VERSION.*"\(.*\)"/\1/p;d' $(LOCAL_PATH)/main.c)
-LOCAL_CFLAGS += -DTOYBOX_VERSION=\"$(toybox_version)\"
+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
+    toybox_version := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)-android
+    LOCAL_CFLAGS += -DTOYBOX_VERSION='"$(toybox_version)"'
+else
+    toybox_version := $(shell sed 's/#define.*TOYBOX_VERSION.*"\(.*\)"/\1/p;d' $(LOCAL_PATH)/main.c)
+    LOCAL_CFLAGS += -DTOYBOX_VERSION=\"$(toybox_version)\"
+endif
 
 LOCAL_CLANG := true
 
@@ -478,18 +485,14 @@
     arp \
     base64 \
     chattr \
-    dd \
     df \
     diff \
-    egrep \
-    fgrep \
     flock \
     freeramdisk \
     fsfreeze \
     fstype \
     ftpget \
     ftpput \
-    grep \
     help \
     install \
     ionice \
@@ -543,7 +546,7 @@
     gzip \
     gunzip \
     zcat
-ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 27; echo $$?),0)
+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 25; echo $$?),0)
 ALL_TOOLS += \
     fmt \
     start \