RELAND: kernel: throne_tracker: always cleanup
sometimes crowning fails especially when you replace managers. it is likely due to using different manager hashes. this will initialize this dynamically and then clear out unconditionally, manager or not, to try avoid stale data. while that is a good thing, this will cause a lot of repetetive work, especially when nothing is crowned. but ehh, I'd take the reliability and simplicity. Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com> Signed-off-by: fc5b87cf <rissu.ntk@gmail.com>
This commit is contained in:
@@ -212,7 +212,7 @@ struct apk_path_hash {
|
|||||||
struct list_head list;
|
struct list_head list;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct list_head apk_path_hash_list = LIST_HEAD_INIT(apk_path_hash_list);
|
static struct list_head apk_path_hash_list;
|
||||||
|
|
||||||
struct my_dir_context {
|
struct my_dir_context {
|
||||||
struct dir_context ctx;
|
struct dir_context ctx;
|
||||||
@@ -279,8 +279,9 @@ FILLDIR_RETURN_TYPE my_actor(struct dir_context *ctx, const char *name,
|
|||||||
data->depth = my_ctx->depth - 1;
|
data->depth = my_ctx->depth - 1;
|
||||||
list_add_tail(&data->list, my_ctx->data_path_list);
|
list_add_tail(&data->list, my_ctx->data_path_list);
|
||||||
} else {
|
} else {
|
||||||
if ((namelen == 8) && (strncmp(name, "base.apk", namelen) == 0)) {
|
if ((namelen == 8) &&
|
||||||
struct apk_path_hash *pos, *n;
|
(strncmp(name, "base.apk", namelen) == 0)) {
|
||||||
|
struct apk_path_hash *pos;
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||||
unsigned int hash = full_name_hash(dirpath, strlen(dirpath));
|
unsigned int hash = full_name_hash(dirpath, strlen(dirpath));
|
||||||
#else
|
#else
|
||||||
@@ -307,32 +308,18 @@ FILLDIR_RETURN_TYPE my_actor(struct dir_context *ctx, const char *name,
|
|||||||
crown_manager(dirpath, my_ctx->private_data, 0);
|
crown_manager(dirpath, my_ctx->private_data, 0);
|
||||||
*my_ctx->stop = 1;
|
*my_ctx->stop = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct apk_path_hash *apk_data = kzalloc(sizeof(*apk_data), GFP_ATOMIC);
|
|
||||||
if (apk_data) {
|
|
||||||
apk_data->hash = hash;
|
|
||||||
apk_data->exists = true;
|
|
||||||
list_add_tail(&apk_data->list, &apk_path_hash_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_manager_apk(dirpath)) {
|
|
||||||
// Manager found, clear APK cache list
|
|
||||||
list_for_each_entry_safe(pos, n, &apk_path_hash_list, list) {
|
|
||||||
list_del(&pos->list);
|
|
||||||
kfree(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FILLDIR_ACTOR_CONTINUE;
|
return FILLDIR_ACTOR_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void search_manager(const char *path, int depth, struct list_head *uid_data)
|
static void search_manager(const char *path, int depth, struct list_head *uid_data)
|
||||||
{
|
{
|
||||||
int i, stop = 0;
|
int i, stop = 0;
|
||||||
struct list_head data_path_list;
|
struct list_head data_path_list;
|
||||||
INIT_LIST_HEAD(&data_path_list);
|
INIT_LIST_HEAD(&data_path_list);
|
||||||
|
INIT_LIST_HEAD(&apk_path_hash_list);
|
||||||
unsigned long data_app_magic = 0;
|
unsigned long data_app_magic = 0;
|
||||||
|
|
||||||
// Initialize APK cache list
|
// Initialize APK cache list
|
||||||
@@ -397,14 +384,13 @@ void search_manager(const char *path, int depth, struct list_head *uid_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove stale cached APK entries
|
// clear apk_path_hash_list unconditionally
|
||||||
|
pr_info("search manager: cleanup!\n");
|
||||||
list_for_each_entry_safe (pos, n, &apk_path_hash_list, list) {
|
list_for_each_entry_safe (pos, n, &apk_path_hash_list, list) {
|
||||||
if (!pos->exists) {
|
|
||||||
list_del(&pos->list);
|
list_del(&pos->list);
|
||||||
kfree(pos);
|
kfree(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static bool is_uid_exist(uid_t uid, char *package, void *data)
|
static bool is_uid_exist(uid_t uid, char *package, void *data)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user