fs_mgr: consolidate DT compatible check
Fixes the compatible check in fs_mgr_boot_config by consolidating the check in a single privately exported function within fs_mgr (i.e. is_dt_compatible()). b/27805372 Test: Boot sailfish w/ early mount Change-Id: Ie2d1646b81cf9eba8d16828ca8cf2c75156c294c Signed-off-by: Sandeep Patil <sspatil@google.com>
This commit is contained in:
parent
16f4fb9c4e
commit
e396c607ff
|
@ -49,15 +49,8 @@ bool fs_mgr_get_boot_config(const std::string& key, std::string* out_val) {
|
|||
}
|
||||
|
||||
// lastly, check the device tree
|
||||
std::string file_name = kAndroidDtDir + "/compatible";
|
||||
std::string dt_value;
|
||||
if (android::base::ReadFileToString(file_name, &dt_value)) {
|
||||
if (dt_value != "android,firmware") {
|
||||
LERROR << "Error finding compatible android DT node";
|
||||
return false;
|
||||
}
|
||||
|
||||
file_name = kAndroidDtDir + "/" + key;
|
||||
if (is_dt_compatible()) {
|
||||
std::string file_name = kAndroidDtDir + "/" + key;
|
||||
// DT entries terminate with '\0' but so do the properties
|
||||
if (android::base::ReadFileToString(file_name, out_val)) {
|
||||
return true;
|
||||
|
|
|
@ -295,21 +295,6 @@ static int parse_flags(char *flags, struct flag_list *fl,
|
|||
return f;
|
||||
}
|
||||
|
||||
static bool is_dt_compatible() {
|
||||
std::string file_name = kAndroidDtDir + "/compatible";
|
||||
std::string dt_value;
|
||||
if (android::base::ReadFileToString(file_name, &dt_value)) {
|
||||
// trim the trailing '\0' out, otherwise the comparison
|
||||
// will produce false-negatives.
|
||||
dt_value.resize(dt_value.size() - 1);
|
||||
if (dt_value == "android,firmware") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool is_dt_fstab_compatible() {
|
||||
std::string dt_value;
|
||||
std::string file_name = kAndroidDtDir + "/fstab/compatible";
|
||||
|
@ -398,6 +383,22 @@ static std::string read_fstab_from_dt() {
|
|||
return fstab;
|
||||
}
|
||||
|
||||
bool is_dt_compatible() {
|
||||
std::string file_name = kAndroidDtDir + "/compatible";
|
||||
std::string dt_value;
|
||||
if (android::base::ReadFileToString(file_name, &dt_value)) {
|
||||
if (!dt_value.empty()) {
|
||||
// trim the trailing '\0' out, otherwise the comparison
|
||||
// will produce false-negatives.
|
||||
dt_value.resize(dt_value.size() - 1);
|
||||
if (dt_value == "android,firmware") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
struct fstab *fs_mgr_read_fstab_file(FILE *fstab_file)
|
||||
{
|
||||
|
|
|
@ -117,6 +117,7 @@ __BEGIN_DECLS
|
|||
int fs_mgr_set_blk_ro(const char *blockdev);
|
||||
int fs_mgr_test_access(const char *device);
|
||||
int fs_mgr_update_for_slotselect(struct fstab *fstab);
|
||||
bool is_dt_compatible();
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in New Issue