Merge "toolbox: implement rm -f flag"
diff --git a/adb/usb_windows.c b/adb/usb_windows.c
index b216999..251bf17 100644
--- a/adb/usb_windows.c
+++ b/adb/usb_windows.c
@@ -255,7 +255,7 @@
 }
 
 int usb_write(usb_handle* handle, const void* data, int len) {
-  unsigned long time_out = 500 + len * 8;
+  unsigned long time_out = 5000;
   unsigned long written = 0;
   int ret;
 
@@ -300,7 +300,7 @@
 }
 
 int usb_read(usb_handle *handle, void* data, int len) {
-  unsigned long time_out = 500 + len * 8;
+  unsigned long time_out = 0;
   unsigned long read = 0;
   int ret;
 
@@ -322,7 +322,7 @@
 
         if (len == 0)
           return 0;
-      } else if (saved_errno != ERROR_SEM_TIMEOUT) {
+      } else {
         // assume ERROR_INVALID_HANDLE indicates we are disconnected
         if (saved_errno == ERROR_INVALID_HANDLE)
           usb_kick(handle);
diff --git a/init/builtins.c b/init/builtins.c
index 41fc03e..661c9b1 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -75,12 +75,23 @@
     }
 }
 
+static int _open(const char *path)
+{
+    int fd;
+
+    fd = open(path, O_RDONLY | O_NOFOLLOW);
+    if (fd < 0)
+        fd = open(path, O_WRONLY | O_NOFOLLOW);
+
+    return fd;
+}
+
 static int _chown(const char *path, unsigned int uid, unsigned int gid)
 {
     int fd;
     int ret;
 
-    fd = open(path, O_RDONLY | O_NOFOLLOW);
+    fd = _open(path);
     if (fd < 0) {
         return -1;
     }
@@ -103,7 +114,7 @@
     int fd;
     int ret;
 
-    fd = open(path, O_RDONLY | O_NOFOLLOW);
+    fd = _open(path);
     if (fd < 0) {
         return -1;
     }