diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-10-27 03:36:24 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-10-27 03:36:24 +0000 |
commit | de29eec33a2f5cba9cd7b481f8ffe5886f2e5e35 (patch) | |
tree | 20d11c58fe89c1cb98b2586895b893aef94f7912 | |
parent | a6546b339946f9dc4da8ce26ed9b891f77066390 (diff) | |
parent | af5be1dcd661868f58abfdf3fe6869db13ad42d0 (diff) | |
download | core-de29eec33a2f5cba9cd7b481f8ffe5886f2e5e35.tar.gz |
Merge cherrypicks of ['googleplex-android-review.googlesource.com/25156721'] into udc-qpr1-release.android-14.0.0_r21android-14.0.0_r20android-14.0.0_r19android-14.0.0_r18android-14.0.0_r17android-14.0.0_r16android14-qpr1-s2-release
Change-Id: I80fd4b673e1e982e13393a46657a2a0e878e3229
-rw-r--r-- | fs_mgr/fs_mgr.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp index 742cdfab0..8b9bce1db 100644 --- a/fs_mgr/fs_mgr.cpp +++ b/fs_mgr/fs_mgr.cpp @@ -700,6 +700,29 @@ static void SetReadAheadSize(const std::string& entry_block_device, off64_t size } // +// Mechanism to allow fsck to be triggered by setting ro.preventative_fsck +// Introduced to address b/305658663 +// If the property value is not equal to the flag file contents, trigger +// fsck and store the property value in the flag file +// If we want to trigger again, simply change the property value +// +static bool check_if_preventative_fsck_needed(const FstabEntry& entry) { + const char* flag_file = "/metadata/vold/preventative_fsck"; + if (entry.mount_point != "/data") return false; + + // Don't error check - both default to empty string, which is OK + std::string prop = android::base::GetProperty("ro.preventative_fsck", ""); + std::string flag; + android::base::ReadFileToString(flag_file, &flag); + if (prop == flag) return false; + // fsck is run immediately, so assume it runs or there is some deeper problem + if (!android::base::WriteStringToFile(prop, flag_file)) + PERROR << "Failed to write file " << flag_file; + LINFO << "Run preventative fsck on /data"; + return true; +} + +// // Prepare the filesystem on the given block device to be mounted. // // If the "check" option was given in the fstab record, or it seems that the @@ -749,7 +772,7 @@ static int prepare_fs_for_mount(const std::string& blk_device, const FstabEntry& } } - if (entry.fs_mgr_flags.check || + if (check_if_preventative_fsck_needed(entry) || entry.fs_mgr_flags.check || (fs_stat & (FS_STAT_UNCLEAN_SHUTDOWN | FS_STAT_QUOTA_ENABLED))) { check_fs(blk_device, entry.fs_type, mount_point, &fs_stat); } |