Merge "Lose chmod to toybox."
diff --git a/adb/remount_service.c b/adb/remount_service.c
index 05d3169..9746f9a 100644
--- a/adb/remount_service.c
+++ b/adb/remount_service.c
@@ -115,7 +115,6 @@
 static int remount(const char* dir, int* dir_ro)
 {
     char *dev;
-    int OFF = 0;
 
     if (dir_ro == 0) {
         return 0;
diff --git a/debuggerd/utility.cpp b/debuggerd/utility.cpp
index 2baf9de..e10feff 100644
--- a/debuggerd/utility.cpp
+++ b/debuggerd/utility.cpp
@@ -131,12 +131,6 @@
   return -1;
 }
 
-#if defined (__mips__)
-#define DUMP_MEMORY_AS_ASCII 1
-#else
-#define DUMP_MEMORY_AS_ASCII 0
-#endif
-
 void dump_memory(log_t* log, pid_t tid, uintptr_t addr) {
     char code_buffer[64];
     char ascii_buffer[32];
@@ -183,7 +177,6 @@
                                static_cast<uintptr_t>(data));
             }
 
-#if DUMP_MEMORY_AS_ASCII
             for (size_t j = 0; j < sizeof(long); j++) {
                 /*
                  * Our isprint() allows high-ASCII characters that display
@@ -197,7 +190,6 @@
                     *asc_out++ = '.';
                 }
             }
-#endif
             p += sizeof(long);
         }
         *asc_out = '\0';
diff --git a/fastboot/Android.mk b/fastboot/Android.mk
index f03bbea..aa5b14a 100644
--- a/fastboot/Android.mk
+++ b/fastboot/Android.mk
@@ -53,7 +53,6 @@
 LOCAL_STATIC_LIBRARIES := \
     $(EXTRA_STATIC_LIBS) \
     libzipfile \
-    libunz \
     libext4_utils_host \
     libsparse_host \
     libz
diff --git a/include/utils/Singleton.h b/include/utils/Singleton.h
index c60680e..ffc03cb 100644
--- a/include/utils/Singleton.h
+++ b/include/utils/Singleton.h
@@ -65,9 +65,10 @@
  */
 
 #define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE)                 \
-    template<> Mutex Singleton< TYPE >::sLock(Mutex::PRIVATE);  \
-    template<> TYPE* Singleton< TYPE >::sInstance(0);           \
-    template class Singleton< TYPE >;
+    template<> ::android::Mutex  \
+        (::android::Singleton< TYPE >::sLock)(::android::Mutex::PRIVATE);  \
+    template<> TYPE* ::android::Singleton< TYPE >::sInstance(0);  \
+    template class ::android::Singleton< TYPE >;
 
 
 // ---------------------------------------------------------------------------
diff --git a/init/init.c b/init/init.c
index 2b82937..7ddab80 100644
--- a/init/init.c
+++ b/init/init.c
@@ -858,26 +858,6 @@
 }
 #endif
 
-static const struct selinux_opt seopts_prop[] = {
-        { SELABEL_OPT_PATH, "/property_contexts" },
-        { SELABEL_OPT_PATH, "/data/security/current/property_contexts" },
-        { 0, NULL }
-};
-
-struct selabel_handle* selinux_android_prop_context_handle(void)
-{
-    int policy_index = selinux_android_use_data_policy() ? 1 : 0;
-    struct selabel_handle* sehandle = selabel_open(SELABEL_CTX_ANDROID_PROP,
-                                                   &seopts_prop[policy_index], 1);
-    if (!sehandle) {
-        ERROR("SELinux:  Could not load property_contexts:  %s\n",
-              strerror(errno));
-        return NULL;
-    }
-    INFO("SELinux: Loaded property contexts from %s\n", seopts_prop[policy_index].value);
-    return sehandle;
-}
-
 void selinux_init_all_handles(void)
 {
     sehandle = selinux_android_file_context_handle();
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index 2318978..a48906a 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -904,7 +904,9 @@
     if (!node) {
         return -ENOENT;
     }
-    if (!check_caller_access_to_node(fuse, hdr, node, W_OK, has_rw)) {
+
+    if (!(req->valid & FATTR_FH) &&
+            !check_caller_access_to_node(fuse, hdr, node, W_OK, has_rw)) {
         return -EACCES;
     }