Add support to patch QCDT

Old Qualcomn devices have their own special QC table of DTB to
store device trees. Since patching fstab is now mandatory on Android 10,
and for older devices all early mount devices have to be included into
the fstab in DTBs, patching QCDT is crucial for rooting Android 10
on legacy devices.

Close #1876 (Thanks for getting me aware of this issue!)
This commit is contained in:
topjohnwu
2019-10-07 00:38:02 -04:00
parent 21099eabfa
commit e0927cd763
4 changed files with 206 additions and 45 deletions

View File

@@ -181,3 +181,20 @@ int parse_int(const char *s) {
}
return val;
}
uint32_t binary_gcd(uint32_t u, uint32_t v) {
if (u == 0) return v;
if (v == 0) return u;
auto shift = __builtin_ctz(u | v);
u >>= __builtin_ctz(u);
do {
v >>= __builtin_ctz(v);
if (u > v) {
auto t = v;
v = u;
u = t;
}
v -= u;
} while (v != 0);
return u << shift;
}

View File

@@ -14,6 +14,7 @@ char *rtrim(char *str);
void init_argv0(int argc, char **argv);
void set_nice_name(const char *name);
int parse_int(const char *s);
uint32_t binary_gcd(uint32_t u, uint32_t v);
#ifdef __cplusplus
}