diff --git a/mars_server.c b/mars_server.c index 733f90c8..67474982 100644 --- a/mars_server.c +++ b/mars_server.c @@ -279,6 +279,12 @@ struct task_struct *_grab_handler(struct server_brick *brick) return res; } +static +int dummy_worker(struct mars_global *global, struct mars_dent *dent, bool prepare, bool direction) +{ + return 0; +} + static int handler_thread(void *data) { @@ -335,19 +341,34 @@ int handler_thread(void *data) } case CMD_GETENTS: { + struct mars_global local = { + .dent_anchor = LIST_HEAD_INIT(local.dent_anchor), + .brick_anchor = LIST_HEAD_INIT(local.brick_anchor), + .server_anchor = LIST_HEAD_INIT(local.server_anchor), + .global_power = { + .button = true, + }, + .main_event = __WAIT_QUEUE_HEAD_INITIALIZER(local.main_event), + }; + status = -EINVAL; - if (unlikely(!cmd.cmd_str1 || !mars_global)) + if (unlikely(!cmd.cmd_str1)) break; + init_rwsem(&local.dent_mutex); + init_rwsem(&local.brick_mutex); + + status = mars_dent_work(&local, "/mars", sizeof(struct mars_dent), light_checker, dummy_worker, &local, 3); + down(&brick->socket_sem); - down_read(&mars_global->dent_mutex); - status = mars_send_dent_list(sock, &mars_global->dent_anchor); - up_read(&mars_global->dent_mutex); + status = mars_send_dent_list(sock, &local.dent_anchor); up(&brick->socket_sem); if (status < 0) { MARS_WRN("#%d could not send dentry information, status = %d\n", sock->s_debug_nr, status); } + + mars_free_dent_all(&local, &local.dent_anchor); break; } case CMD_CONNECT: diff --git a/sy_old/mars_light.c b/sy_old/mars_light.c index c18b6265..56968ad4 100644 --- a/sy_old/mars_light.c +++ b/sy_old/mars_light.c @@ -3574,7 +3574,7 @@ static const struct light_class light_classes[] = { /* Helper routine to pre-determine the relevance of a name from the filesystem. */ -static int light_checker(struct mars_dent *parent, const char *_name, int namlen, unsigned int d_type, int *prefix, int *serial, bool *use_channel) +int light_checker(struct mars_dent *parent, const char *_name, int namlen, unsigned int d_type, int *prefix, int *serial, bool *use_channel) { int class; int status = -2; diff --git a/sy_old/strategy.h b/sy_old/strategy.h index 12fc0d16..4565ed6a 100644 --- a/sy_old/strategy.h +++ b/sy_old/strategy.h @@ -160,6 +160,8 @@ extern int mars_max_loadavg; extern int mars_mem_percent; +extern int light_checker(struct mars_dent *parent, const char *_name, int namlen, unsigned int d_type, int *prefix, int *serial, bool *use_channel); + ///////////////////////////////////////////////////////////////////////// // init