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)) {
|
if (!has_mask(HI_FILE_PARENT, mask)) {
|
||||||
char *parent = get_parent_folder(path);
|
char *parent_name = get_parent_folder(path);
|
||||||
hiFileWatch *parent_watch = file_watch_find_by_path(ctx, parent, NULL);
|
hiFileWatch *parent_watch = file_watch_find_by_path(ctx, parent_name, NULL);
|
||||||
if (!parent_watch) {
|
if (!parent_watch) {
|
||||||
// parent not yet watched
|
// parent not yet watched
|
||||||
int wd = inotify_add_watch(ctx->fd, parent, params.parent_mask);
|
int wd = inotify_add_watch(ctx->fd, parent_name, params.parent_mask);
|
||||||
hiFileWatch wp = {.wd = wd, .mask = HI_FILE_PARENT, .path = parent};
|
hiFileWatch wp = {.wd = wd, .mask = HI_FILE_PARENT, .path = parent_name};
|
||||||
sc_array_init(&wp.files);
|
sc_array_init(&wp.files);
|
||||||
sc_array_add(&wp.files, strdup(watch->path));
|
sc_array_add(&wp.files, strdup(watch->path));
|
||||||
sc_array_add(&ctx->watches, wp);
|
sc_array_add(&ctx->watches, wp);
|
||||||
} else {
|
} else {
|
||||||
free(parent);
|
free(parent_name);
|
||||||
inotify_add_watch(ctx->fd, parent_watch->path, params.parent_mask);
|
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
|
// Make sure we don't add a duplicate if the file is already marked
|
||||||
|
|||||||
@@ -304,12 +304,14 @@ int file_watcher_watch(void *arg) {
|
|||||||
|
|
||||||
event = (const struct inotify_event *)ptr;
|
event = (const struct inotify_event *)ptr;
|
||||||
hiFileEvent e = file_event_create(event, &ctx->context);
|
hiFileEvent e = file_event_create(event, &ctx->context);
|
||||||
sc_array_add(&ctx->events, e);
|
if (e.type != HI_FILE_NONE) {
|
||||||
|
sc_array_add(&ctx->events, e);
|
||||||
|
|
||||||
if (event->len) {
|
if (event->len) {
|
||||||
sc_log_debug("Event created: queue-size: %u, %s %s\n",
|
sc_log_debug("Event created: queue-size: %u, %s %s\n",
|
||||||
sc_array_size(&ctx->events), e.pathname,
|
sc_array_size(&ctx->events), e.pathname,
|
||||||
hi_file_watch_type_to_str(e.type));
|
hi_file_watch_type_to_str(e.type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue; // read again without waiting
|
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);
|
assert(handle);
|
||||||
|
|
||||||
HiModuleData module = {0};
|
HiModuleData module = {0};
|
||||||
|
module.dlhandle = handle;
|
||||||
module.address = info->dlpi_addr;
|
module.address = info->dlpi_addr;
|
||||||
|
|
||||||
log_debugv(" header size: %u\n", size);
|
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);
|
HiloadResult re = gather_module_infos(&context.modules);
|
||||||
if (re == HILOAD_OK) {
|
if (re != HILOAD_OK) {
|
||||||
log_error("Failed to gather module infos.\n");
|
log_error("Failed to gather module infos.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "moduler/elf.h"
|
#include "moduler/elf.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <libelf.h>
|
|
||||||
|
|
||||||
HiloadResult moduler_reload(HiModuleData *module,
|
HiloadResult moduler_reload(HiModuleData *module,
|
||||||
const struct sc_array_memreg *const memregs) {
|
const struct sc_array_memreg *const memregs) {
|
||||||
@@ -22,6 +21,8 @@ HiloadResult moduler_reload(HiModuleData *module,
|
|||||||
return HILOAD_FAIL;
|
return HILOAD_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* void *new_handle = dlopen(module->name, RTLD_NOW); */
|
||||||
|
/* assert(new_handle != module->dlhandle); */
|
||||||
void *module_address = (void *)module->address;
|
void *module_address = (void *)module->address;
|
||||||
|
|
||||||
size_t phdrnum = 0;
|
size_t phdrnum = 0;
|
||||||
@@ -79,21 +80,19 @@ HiloadResult moduler_reload(HiModuleData *module,
|
|||||||
++dyn;
|
++dyn;
|
||||||
}
|
}
|
||||||
log_debugv("\nstrtab: %p\n"
|
log_debugv("\nstrtab: %p\n"
|
||||||
"symtab: %p\n"
|
"symtab: %p\n"
|
||||||
"strsz: %zu\n"
|
"strsz: %zu\n"
|
||||||
"syment: %zu\n"
|
"syment: %zu\n"
|
||||||
"rela: %p\n"
|
"rela: %p\n"
|
||||||
"relasz: %zu\n"
|
"relasz: %zu\n"
|
||||||
"relaent: %zu\n"
|
"relaent: %zu\n"
|
||||||
"relacount: %zu\n"
|
"relacount: %zu\n"
|
||||||
"pltgot: %p\n"
|
"pltgot: %p\n"
|
||||||
"pltrelsz: %zu\n"
|
"pltrelsz: %zu\n"
|
||||||
"pltrel: %p\n",
|
"pltrel: %p\n",
|
||||||
strtab, symtab, strsz, syment, rela, relasz, relaent, relacount,
|
strtab, symtab, strsz, syment, rela, relasz, relaent,
|
||||||
pltgot, pltrelsz, pltrel);
|
relacount, pltgot, pltrelsz, pltrel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module->state = HI_MODULE_STATE_CLEAN;
|
module->state = HI_MODULE_STATE_CLEAN;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ enum HiModuleState {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name; // Filename if found
|
const char *name; // Filename if found
|
||||||
|
void *dlhandle;
|
||||||
uptr address;
|
uptr address;
|
||||||
u8 state;
|
u8 state;
|
||||||
} HiModuleData;
|
} HiModuleData;
|
||||||
|
|||||||
Reference in New Issue
Block a user