Fix overlay.d on SAR again
This commit is contained in:
parent
87de0e7a0e
commit
c113f854a2
@ -316,8 +316,8 @@ void SARBase::patch_rootdir() {
|
|||||||
// Handle overlay.d
|
// Handle overlay.d
|
||||||
load_overlay_rc(ROOTOVL);
|
load_overlay_rc(ROOTOVL);
|
||||||
if (access(ROOTOVL "/sbin", F_OK) == 0) {
|
if (access(ROOTOVL "/sbin", F_OK) == 0) {
|
||||||
// Move files in overlay.d/sbin into Magisk's tmp_dir
|
// Move files in overlay.d/sbin into tmp_dir
|
||||||
mv_path(ROOTOVL "/sbin", tmp_dir);
|
mv_path(ROOTOVL "/sbin", ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch init.rc
|
// Patch init.rc
|
||||||
|
@ -86,11 +86,13 @@ void frm_rf(int dirfd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mv_path(const char *src, const char *dest) {
|
void mv_path(const char *src, const char *dest) {
|
||||||
file_attr a;
|
file_attr attr;
|
||||||
getattr(src, &a);
|
getattr(src, &attr);
|
||||||
if (S_ISDIR(a.st.st_mode)) {
|
if (S_ISDIR(attr.st.st_mode)) {
|
||||||
|
if (access(dest, F_OK) != 0) {
|
||||||
xmkdirs(dest, 0);
|
xmkdirs(dest, 0);
|
||||||
setattr(dest, &a);
|
setattr(dest, &attr);
|
||||||
|
}
|
||||||
mv_dir(xopen(src, O_RDONLY | O_CLOEXEC), xopen(dest, O_RDONLY | O_CLOEXEC));
|
mv_dir(xopen(src, O_RDONLY | O_CLOEXEC), xopen(dest, O_RDONLY | O_CLOEXEC));
|
||||||
} else{
|
} else{
|
||||||
xrename(src, dest);
|
xrename(src, dest);
|
||||||
@ -100,7 +102,7 @@ void mv_path(const char *src, const char *dest) {
|
|||||||
|
|
||||||
void mv_dir(int src, int dest) {
|
void mv_dir(int src, int dest) {
|
||||||
auto dir = xopen_dir(src);
|
auto dir = xopen_dir(src);
|
||||||
run_finally f([&]{ close(dest); });
|
run_finally f([=]{ close(dest); });
|
||||||
for (dirent *entry; (entry = xreaddir(dir.get()));) {
|
for (dirent *entry; (entry = xreaddir(dir.get()));) {
|
||||||
switch (entry->d_type) {
|
switch (entry->d_type) {
|
||||||
case DT_DIR:
|
case DT_DIR:
|
||||||
|
Loading…
Reference in New Issue
Block a user