fix: add fallback support for .replace marker file
The replace-dir detection relied solely on the xattr, causing .replace marker files to be ignored. This commit restores the intended behavior by checking for <dir>/.replace when the xattr is missing or empty.
This commit is contained in:
parent
31c9751393
commit
6d198a353d
2 changed files with 14 additions and 5 deletions
|
|
@ -163,11 +163,19 @@ static bool dir_is_replace(const char *path)
|
|||
{
|
||||
char buf[8];
|
||||
ssize_t len = lgetxattr(path, REPLACE_DIR_XATTR, buf, sizeof(buf) - 1);
|
||||
if (len <= 0)
|
||||
return false;
|
||||
|
||||
buf[len] = '\0';
|
||||
return (strcmp(buf, "y") == 0);
|
||||
|
||||
if (len > 0) {
|
||||
buf[len] = '\0';
|
||||
if (strcmp(buf, "y") == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
int dirfd = open(path, O_RDONLY | O_DIRECTORY);
|
||||
if (dirfd < 0) return false;
|
||||
|
||||
bool exists = (faccessat(dirfd, REPLACE_DIR_FILE_NAME, F_OK, 0) == 0);
|
||||
close(dirfd);
|
||||
return exists;
|
||||
}
|
||||
|
||||
static Node *node_new_module(const char *name, const char *path,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#define SKIP_MOUNT_FILE_NAME "skip_mount"
|
||||
|
||||
#define REPLACE_DIR_XATTR "trusted.overlay.opaque"
|
||||
#define REPLACE_DIR_FILE_NAME ".replace"
|
||||
|
||||
#define DEFAULT_MOUNT_SOURCE "KSU"
|
||||
#define DEFAULT_MODULE_DIR "/data/adb/modules"
|
||||
|
|
|
|||
Loading…
Reference in a new issue