osutils: add sync API

Basic wrapper around `sync` to make it a little easier to program
against, and so we can make calls directly if need be to be faster,
and to add better debugging/fallback code when things fail.

BUG=b:256896261
TEST=CQ passes

Change-Id: I99d09cb4454938a8d77902e8f6e81db3e9c1b298
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4127337
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Ram Chandrasekar <rchandrasekar@google.com>
diff --git a/cli/flash.py b/cli/flash.py
index 9627dc5..fb1dc34 100644
--- a/cli/flash.py
+++ b/cli/flash.py
@@ -254,9 +254,7 @@
         cros_build_lib.sudo_run(
             ["partx", "-u", device], debug_level=self.debug_level
         )
-        cros_build_lib.sudo_run(
-            ["sync", "-d", device], debug_level=self.debug_level
-        )
+        osutils.sync_storage(device, data_only=True, sudo=True)
 
     def _GetImagePath(self):
         """Returns the image path to use."""