Merge changes from topic 'fs_mgr_dt'
am: dbb40b64e9
Change-Id: I8e54aecb4825f4adc3fd92ceff1da76e1c4b227b
This commit is contained in:
commit
ad384fc992
3 changed files with 37 additions and 38 deletions
|
|
@ -49,15 +49,8 @@ bool fs_mgr_get_boot_config(const std::string& key, std::string* out_val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// lastly, check the device tree
|
// lastly, check the device tree
|
||||||
std::string file_name = kAndroidDtDir + "/compatible";
|
if (is_dt_compatible()) {
|
||||||
std::string dt_value;
|
std::string file_name = kAndroidDtDir + "/" + key;
|
||||||
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;
|
|
||||||
// DT entries terminate with '\0' but so do the properties
|
// DT entries terminate with '\0' but so do the properties
|
||||||
if (android::base::ReadFileToString(file_name, out_val)) {
|
if (android::base::ReadFileToString(file_name, out_val)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,24 @@ static uint64_t parse_size(const char *arg)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* fills 'dt_value' with the underlying device tree value string without
|
||||||
|
* the trailing '\0'. Returns true if 'dt_value' has a valid string, 'false'
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
static bool read_dt_file(const std::string& file_name, 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);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static int parse_flags(char *flags, struct flag_list *fl,
|
static int parse_flags(char *flags, struct flag_list *fl,
|
||||||
struct fs_mgr_flag_values *flag_vals,
|
struct fs_mgr_flag_values *flag_vals,
|
||||||
char *fs_options, int fs_options_len)
|
char *fs_options, int fs_options_len)
|
||||||
|
|
@ -295,29 +313,10 @@ static int parse_flags(char *flags, struct flag_list *fl,
|
||||||
return f;
|
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() {
|
static bool is_dt_fstab_compatible() {
|
||||||
std::string dt_value;
|
std::string dt_value;
|
||||||
std::string file_name = kAndroidDtDir + "/fstab/compatible";
|
std::string file_name = kAndroidDtDir + "/fstab/compatible";
|
||||||
|
if (read_dt_file(file_name, &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,fstab") {
|
if (dt_value == "android,fstab") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -354,41 +353,36 @@ static std::string read_fstab_from_dt() {
|
||||||
std::string file_name;
|
std::string file_name;
|
||||||
std::string value;
|
std::string value;
|
||||||
file_name = android::base::StringPrintf("%s/%s/dev", fstabdir_name.c_str(), dp->d_name);
|
file_name = android::base::StringPrintf("%s/%s/dev", fstabdir_name.c_str(), dp->d_name);
|
||||||
if (!android::base::ReadFileToString(file_name, &value)) {
|
if (!read_dt_file(file_name, &value)) {
|
||||||
LERROR << "dt_fstab: Failed to find device for partition " << dp->d_name;
|
LERROR << "dt_fstab: Failed to find device for partition " << dp->d_name;
|
||||||
fstab.clear();
|
fstab.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// trim the terminating '\0' out
|
|
||||||
value.resize(value.size() - 1);
|
|
||||||
fstab_entry.push_back(value);
|
fstab_entry.push_back(value);
|
||||||
fstab_entry.push_back(android::base::StringPrintf("/%s", dp->d_name));
|
fstab_entry.push_back(android::base::StringPrintf("/%s", dp->d_name));
|
||||||
|
|
||||||
file_name = android::base::StringPrintf("%s/%s/type", fstabdir_name.c_str(), dp->d_name);
|
file_name = android::base::StringPrintf("%s/%s/type", fstabdir_name.c_str(), dp->d_name);
|
||||||
if (!android::base::ReadFileToString(file_name, &value)) {
|
if (!read_dt_file(file_name, &value)) {
|
||||||
LERROR << "dt_fstab: Failed to find type for partition " << dp->d_name;
|
LERROR << "dt_fstab: Failed to find type for partition " << dp->d_name;
|
||||||
fstab.clear();
|
fstab.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
value.resize(value.size() - 1);
|
|
||||||
fstab_entry.push_back(value);
|
fstab_entry.push_back(value);
|
||||||
|
|
||||||
file_name = android::base::StringPrintf("%s/%s/mnt_flags", fstabdir_name.c_str(), dp->d_name);
|
file_name = android::base::StringPrintf("%s/%s/mnt_flags", fstabdir_name.c_str(), dp->d_name);
|
||||||
if (!android::base::ReadFileToString(file_name, &value)) {
|
if (!read_dt_file(file_name, &value)) {
|
||||||
LERROR << "dt_fstab: Failed to find type for partition " << dp->d_name;
|
LERROR << "dt_fstab: Failed to find type for partition " << dp->d_name;
|
||||||
fstab.clear();
|
fstab.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
value.resize(value.size() - 1);
|
|
||||||
fstab_entry.push_back(value);
|
fstab_entry.push_back(value);
|
||||||
|
|
||||||
file_name = android::base::StringPrintf("%s/%s/fsmgr_flags", fstabdir_name.c_str(), dp->d_name);
|
file_name = android::base::StringPrintf("%s/%s/fsmgr_flags", fstabdir_name.c_str(), dp->d_name);
|
||||||
if (!android::base::ReadFileToString(file_name, &value)) {
|
if (!read_dt_file(file_name, &value)) {
|
||||||
LERROR << "dt_fstab: Failed to find type for partition " << dp->d_name;
|
LERROR << "dt_fstab: Failed to find type for partition " << dp->d_name;
|
||||||
fstab.clear();
|
fstab.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
value.resize(value.size() - 1);
|
|
||||||
fstab_entry.push_back(value);
|
fstab_entry.push_back(value);
|
||||||
|
|
||||||
fstab += android::base::Join(fstab_entry, " ");
|
fstab += android::base::Join(fstab_entry, " ");
|
||||||
|
|
@ -398,6 +392,17 @@ static std::string read_fstab_from_dt() {
|
||||||
return fstab;
|
return fstab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_dt_compatible() {
|
||||||
|
std::string file_name = kAndroidDtDir + "/compatible";
|
||||||
|
std::string dt_value;
|
||||||
|
if (read_dt_file(file_name, &dt_value)) {
|
||||||
|
if (dt_value == "android,firmware") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
struct fstab *fs_mgr_read_fstab_file(FILE *fstab_file)
|
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_set_blk_ro(const char *blockdev);
|
||||||
int fs_mgr_test_access(const char *device);
|
int fs_mgr_test_access(const char *device);
|
||||||
int fs_mgr_update_for_slotselect(struct fstab *fstab);
|
int fs_mgr_update_for_slotselect(struct fstab *fstab);
|
||||||
|
bool is_dt_compatible();
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue