fs_mgr_remount: support legacy devices (marlin)

Deal with first version of verity for legacy products.

Test: system/core/fs_mgr/tests/adb-remount-test.sh
Bug: 120448575
Bug: 123079041
Change-Id: I7a2dd8309cbb19751fdbb05d4efc30c486615e04
diff --git a/fs_mgr/Android.bp b/fs_mgr/Android.bp
index 0a048f9..4ee9624 100644
--- a/fs_mgr/Android.bp
+++ b/fs_mgr/Android.bp
@@ -121,6 +121,8 @@
     shared_libs: [
         "libbootloader_message",
         "libbase",
+        "libcrypto",
+        "libfec",
         "libfs_mgr",
     ],
     header_libs: [
diff --git a/fs_mgr/fs_mgr_remount.cpp b/fs_mgr/fs_mgr_remount.cpp
index 105d18c..c0e0ccd 100644
--- a/fs_mgr/fs_mgr_remount.cpp
+++ b/fs_mgr/fs_mgr_remount.cpp
@@ -33,6 +33,7 @@
 #include <android-base/strings.h>
 #include <bootloader_message/bootloader_message.h>
 #include <cutils/android_reboot.h>
+#include <fec/io.h>
 #include <fs_mgr_overlayfs.h>
 #include <fs_mgr_priv.h>
 #include <fstab/fstab.h>
@@ -243,6 +244,9 @@
                             continue;
                         }
                         reboot(false);
+                    } else if (fs_mgr_set_blk_ro(entry.blk_device, false)) {
+                        fec::io fh(entry.blk_device.c_str(), O_RDWR);
+                        if (fh && fh.set_verity_status(false)) reboot_later = true;
                     }
                 }
             }
@@ -268,6 +272,7 @@
     }
 
     if (partitions.empty()) {
+        if (reboot_later) reboot(false);
         LOG(WARNING) << "No partitions to remount";
         return retval;
     }