mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-05 23:14:03 -05:00
base: eliminate /proc/self/fd path resolution
Remove reliance on /proc/self/fd symlink resolution across base and core components: - Add top-level pre_order_walk and post_order_walk that track entry paths via an internal buffer, and unify Directory walk methods to support path-tracking and pathless traversals without extra overhead. - Add DirEntry::get_stat using fstatat(AT_SYMLINK_NOFOLLOW) directly on directory file descriptors. - Update Directory::copy_into and link_into to operate directly on file descriptors with fd_get_attr/fd_set_attr, passing paths only for symlink attribute updates. - Refactor find_apk_path and restore_tmpcon to use pre_order_walk, and update get_app_no_list to use DirEntry::get_stat. - Remove DirEntry::resolve_path, Directory::path_at, Directory::resolve_path, and fd_path. - Replace remaining consumers of xrealpath and canonical_path (in su and magiskinit) with standard realpath or partition matching, allowing removal of Utf8CStr::realpath and its C FFI exports. Assisted-by: Gemini 3.8 Flash
This commit is contained in:
@@ -16,7 +16,6 @@ struct devinfo {
|
||||
char devname[32];
|
||||
char partname[32];
|
||||
char dmname[32];
|
||||
char devpath[PATH_MAX];
|
||||
};
|
||||
|
||||
static vector<devinfo> dev_list;
|
||||
@@ -27,7 +26,6 @@ bool avd_hack = false;
|
||||
|
||||
static void parse_device(devinfo *dev, const char *uevent) {
|
||||
dev->partname[0] = '\0';
|
||||
dev->devpath[0] = '\0';
|
||||
dev->dmname[0] = '\0';
|
||||
dev->devname[0] = '\0';
|
||||
parse_prop_file(uevent, [=](Utf8CStr key, Utf8CStr value) -> bool {
|
||||
@@ -38,7 +36,7 @@ static void parse_device(devinfo *dev, const char *uevent) {
|
||||
else if (key == "DEVNAME")
|
||||
strscpy(dev->devname, value.c_str(), sizeof(dev->devname));
|
||||
else if (key == "PARTNAME")
|
||||
strscpy(dev->partname, value.c_str(), sizeof(dev->devname));
|
||||
strscpy(dev->partname, value.c_str(), sizeof(dev->partname));
|
||||
|
||||
return true;
|
||||
});
|
||||
@@ -64,8 +62,6 @@ void MagiskInit::collect_devices() const noexcept {
|
||||
// use androidboot.partition_map as partname fallback.
|
||||
strscpy(dev.partname, it->value.data(), sizeof(dev.partname));
|
||||
}
|
||||
sprintf(path, "/sys/dev/block/%s", entry->d_name);
|
||||
xrealpath(path, dev.devpath, sizeof(dev.devpath));
|
||||
dev_list.push_back(dev);
|
||||
}
|
||||
}
|
||||
@@ -84,8 +80,6 @@ uint64_t MagiskInit::find_block(const char *partname) const noexcept {
|
||||
name = dev.dmname;
|
||||
else if (strcasecmp(dev.devname, partname) == 0)
|
||||
name = dev.devname;
|
||||
else if (std::string_view(dev.devpath).ends_with("/"s + partname))
|
||||
name = dev.devpath;
|
||||
else
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user