Add timeout for mount on untrusted media
Under some circumstances it seems mounting a device can take a long
time. We already abort fsck if it runs for too long, so this is the last
remaining spot this could happen.
Bug: 339740354
Test: Mount a very slow device, observe no Android restart
Change-Id: I3607be269d3aeb4c2391d1d8e2372e3a6795e7c4
diff --git a/Utils.h b/Utils.h
index 39723ec..0eca902 100644
--- a/Utils.h
+++ b/Utils.h
@@ -39,6 +39,7 @@
static const char* kExternalStorageSdcardfs = "external_storage.sdcardfs.enabled";
static constexpr std::chrono::seconds kUntrustedFsckSleepTime(45);
+static constexpr std::chrono::seconds kUntrustedMountSleepTime(20);
/* SELinux contexts used depending on the block device type */
extern char* sBlkidContext;
@@ -107,6 +108,7 @@
std::string* fsLabel);
/* Returns either WEXITSTATUS() status, or a negative errno */
+status_t ForkTimeout(int (*func)(void*), void* args, std::chrono::seconds timeout);
status_t ForkExecvp(const std::vector<std::string>& args,
std::vector<std::string>* output = nullptr, char* context = nullptr);
status_t ForkExecvpTimeout(const std::vector<std::string>& args, std::chrono::seconds timeout,