fiddle about a bit
This commit is contained in:
@@ -133,17 +133,17 @@ HiloadResult file_watch_add(hiFileWatcherContext *ctx, u32 mask,
|
||||
}
|
||||
|
||||
if (!has_mask(HI_FILE_PARENT, mask)) {
|
||||
char *parent = get_parent_folder(path);
|
||||
hiFileWatch *parent_watch = file_watch_find_by_path(ctx, parent, NULL);
|
||||
char *parent_name = get_parent_folder(path);
|
||||
hiFileWatch *parent_watch = file_watch_find_by_path(ctx, parent_name, NULL);
|
||||
if (!parent_watch) {
|
||||
// parent not yet watched
|
||||
int wd = inotify_add_watch(ctx->fd, parent, params.parent_mask);
|
||||
hiFileWatch wp = {.wd = wd, .mask = HI_FILE_PARENT, .path = parent};
|
||||
int wd = inotify_add_watch(ctx->fd, parent_name, params.parent_mask);
|
||||
hiFileWatch wp = {.wd = wd, .mask = HI_FILE_PARENT, .path = parent_name};
|
||||
sc_array_init(&wp.files);
|
||||
sc_array_add(&wp.files, strdup(watch->path));
|
||||
sc_array_add(&ctx->watches, wp);
|
||||
} else {
|
||||
free(parent);
|
||||
free(parent_name);
|
||||
inotify_add_watch(ctx->fd, parent_watch->path, params.parent_mask);
|
||||
{
|
||||
// Make sure we don't add a duplicate if the file is already marked
|
||||
|
||||
@@ -304,6 +304,7 @@ int file_watcher_watch(void *arg) {
|
||||
|
||||
event = (const struct inotify_event *)ptr;
|
||||
hiFileEvent e = file_event_create(event, &ctx->context);
|
||||
if (e.type != HI_FILE_NONE) {
|
||||
sc_array_add(&ctx->events, e);
|
||||
|
||||
if (event->len) {
|
||||
@@ -312,6 +313,7 @@ int file_watcher_watch(void *arg) {
|
||||
hi_file_watch_type_to_str(e.type));
|
||||
}
|
||||
}
|
||||
}
|
||||
continue; // read again without waiting
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ static int gather_module_data_callback(struct dl_phdr_info *info, size_t size,
|
||||
assert(handle);
|
||||
|
||||
HiModuleData module = {0};
|
||||
module.dlhandle = handle;
|
||||
module.address = info->dlpi_addr;
|
||||
|
||||
log_debugv(" header size: %u\n", size);
|
||||
@@ -216,7 +217,7 @@ int hi_init(unsigned n, const char **enabled_modules) {
|
||||
}
|
||||
|
||||
HiloadResult re = gather_module_infos(&context.modules);
|
||||
if (re == HILOAD_OK) {
|
||||
if (re != HILOAD_OK) {
|
||||
log_error("Failed to gather module infos.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "memory.h"
|
||||
#include "moduler/elf.h"
|
||||
#include "types.h"
|
||||
#include <libelf.h>
|
||||
|
||||
HiloadResult moduler_reload(HiModuleData *module,
|
||||
const struct sc_array_memreg *const memregs) {
|
||||
@@ -22,6 +21,8 @@ HiloadResult moduler_reload(HiModuleData *module,
|
||||
return HILOAD_FAIL;
|
||||
}
|
||||
|
||||
/* void *new_handle = dlopen(module->name, RTLD_NOW); */
|
||||
/* assert(new_handle != module->dlhandle); */
|
||||
void *module_address = (void *)module->address;
|
||||
|
||||
size_t phdrnum = 0;
|
||||
@@ -89,11 +90,9 @@ HiloadResult moduler_reload(HiModuleData *module,
|
||||
"pltgot: %p\n"
|
||||
"pltrelsz: %zu\n"
|
||||
"pltrel: %p\n",
|
||||
strtab, symtab, strsz, syment, rela, relasz, relaent, relacount,
|
||||
pltgot, pltrelsz, pltrel);
|
||||
strtab, symtab, strsz, syment, rela, relasz, relaent,
|
||||
relacount, pltgot, pltrelsz, pltrel);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
module->state = HI_MODULE_STATE_CLEAN;
|
||||
|
||||
@@ -15,6 +15,7 @@ enum HiModuleState {
|
||||
|
||||
typedef struct {
|
||||
const char *name; // Filename if found
|
||||
void *dlhandle;
|
||||
uptr address;
|
||||
u8 state;
|
||||
} HiModuleData;
|
||||
|
||||
Reference in New Issue
Block a user