diff options
| author | Bowgo Tsai <bowgotsai@google.com> | 2017-03-24 01:19:38 +0800 |
|---|---|---|
| committer | Bowgo Tsai <bowgotsai@google.com> | 2017-03-25 19:25:43 +0800 |
| commit | 37bd44174bf2511320961f3f8cd1f698a1c72b66 (patch) | |
| tree | e48dcc560100a44b6b48159f5825273fc6128ae4 /bootloader_message | |
| parent | f09efaff895a0a050f43842a015aef6457dabfd4 (diff) | |
libbootloader_message: use different fstab paths for normal/recovery boot
libbootloader_message is used by both normal boot and recovery boot.
It needs to use different fstab paths, respectively. Otherwise, factory
reset will fail when we move /fstab.{ro.hardware} to /vendor/etc/.
Recovery boot: fs_mgr_read_fstab_with_dt("/etc/recovery.fstab")
Normal boot: fs_mgr_read_fstab_default()
Bug: 35811655
Bug: 36502022
Test: normal boot sailfish, go to Settings > System & tap on
"Factory Data reset"
Test: recovery boot sailfish
Change-Id: I253f5bdfb9be8a01f80856eb1194f85cdf992bbd
Diffstat (limited to 'bootloader_message')
| -rw-r--r-- | bootloader_message/bootloader_message.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp index d8086be2..d17e055b 100644 --- a/bootloader_message/bootloader_message.cpp +++ b/bootloader_message/bootloader_message.cpp @@ -19,6 +19,7 @@ #include <errno.h> #include <fcntl.h> #include <string.h> +#include <unistd.h> #include <string> #include <vector> @@ -30,8 +31,13 @@ #include <fs_mgr.h> static std::string get_misc_blk_device(std::string* err) { - std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(), - fs_mgr_free_fstab); + std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(nullptr, fs_mgr_free_fstab); + // Use different fstab paths for normal boot and recovery boot, respectively + if (access("/sbin/recovery", F_OK) == 0) { + fstab.reset(fs_mgr_read_fstab_with_dt("/etc/recovery.fstab")); + } else { + fstab.reset(fs_mgr_read_fstab_default()); + } if (!fstab) { *err = "failed to read default fstab"; return ""; |
