Call ioctl before each write on retry

If the update is a retry, ioctl(BLKDISCARD) the destination blocks before
writing to these blocks.

Bug: 28990135
Change-Id: I1e703808e68ebb1292cd66afd76be8fd6946ee59
diff --git a/updater/updater.cpp b/updater/updater.cpp
index b5db71e..e956dd5 100644
--- a/updater/updater.cpp
+++ b/updater/updater.cpp
@@ -48,7 +48,7 @@
     setbuf(stdout, NULL);
     setbuf(stderr, NULL);
 
-    if (argc != 4) {
+    if (argc != 4 && argc != 5) {
         printf("unexpected number of arguments (%d)\n", argc);
         return 1;
     }
@@ -142,6 +142,14 @@
     state.script = script;
     state.errmsg = NULL;
 
+    if (argc == 5) {
+        if (strcmp(argv[4], "retry") == 0) {
+            state.is_retry = true;
+        } else {
+            printf("unexpected argument: %s", argv[4]);
+        }
+    }
+
     char* result = Evaluate(&state, root);
 
     if (have_eio_error) {