Add more logging

This commit is contained in:
kamkow1
2025-07-06 00:19:41 +02:00
parent 5ee7e02f7a
commit e88dc0426a
3 changed files with 28 additions and 2 deletions

View File

@ -22,10 +22,12 @@ void add_baked_resource(char *key, const uchar *data, size_t size)
}
write(fd, data, size);
shput(baked_resources.value, key, ((Baked_Resource_Value){ .memfd = fd, .bufptr = (void *)data }));
LOGI("Added baked resource: %s\n", key);
}
void init_baked_resources(void)
{
LOGI("Initializing baked resources...\n");
struct zip_t *zip = zip_stream_open(bundle_zip_data, bundle_zip_size, BUNDLE_ZIP_COMPRESSION, 'r');
size_t n = zip_entries_total(zip);
for (size_t i = 0; i < n; i++) {
@ -41,24 +43,29 @@ void init_baked_resources(void)
zip_entry_close(zip);
}
zip_stream_close(zip);
LOGI("baked resources done\n");
}
void free_baked_resources(void)
{
LOGI("freeing baked resouces\n");
for (size_t i = 0; i < shlen(baked_resources.value); i++) {
close(baked_resources.value[i].value.memfd);
free(baked_resources.value[i].key);
free(baked_resources.value[i].value.bufptr);
}
shfree(baked_resources.value);
LOGI("baked resources done\n");
}
bool get_baked_resource_path(char *key, char *buf, size_t size)
{
LOGI("Request for baked resource path: %s\n", key);
lockx(&baked_resources);
if (shgeti(baked_resources.value, key) != -1) {
Baked_Resource_Value brv = shget(baked_resources.value, key);
snprintf(buf, size, "/proc/%d/fd/%d", getpid(), brv.memfd);
LOGI("Memfd path %s\n", buf);
unlockx(&baked_resources);
return true;
}