From f029ca743b58cf6c7e3cd11722f13b98ec6c6af0 Mon Sep 17 00:00:00 2001 From: midipix Date: Jun 21 2020 10:13:59 +0000 Subject: logging: toks_log_service_info(): initial implementation and integration. --- diff --git a/project/common.mk b/project/common.mk index e773276..79ad331 100644 --- a/project/common.mk +++ b/project/common.mk @@ -26,6 +26,7 @@ INTERNAL_SRCS = \ src/internal/toksvc_ntaio_impl.c \ src/internal/toksvc_open_impl.c \ src/log/toks_log_lpc_message.c \ + src/log/toks_log_service_info.c \ src/service/toks_service_abort.c \ src/service/toks_service_ioctl.c \ src/service/toks_service_start.c \ diff --git a/src/daemon/toks_daemon_loop.c b/src/daemon/toks_daemon_loop.c index 3fd5ca9..dbb31c3 100644 --- a/src/daemon/toks_daemon_loop.c +++ b/src/daemon/toks_daemon_loop.c @@ -189,6 +189,9 @@ int32_t __stdcall toks_daemon_loop(void * ctx) ntapi->zw_close(rtdata->hsync); } + /* service info */ + toks_log_service_info(dctx); + /* init */ request = &dctx->request; reply = &dctx->reply; diff --git a/src/internal/toksvc_log_impl.h b/src/internal/toksvc_log_impl.h index 12469cd..c27178c 100644 --- a/src/internal/toksvc_log_impl.h +++ b/src/internal/toksvc_log_impl.h @@ -48,6 +48,9 @@ void toks_log_get_process_name( void toks_log_get_arbitrary_process_name( nt_cid *, char *, size_t); +void toks_log_service_info( + struct toks_daemon_ctx *); + void toks_log_lpc_request( struct toks_daemon_ctx *, const nt_tty_port_msg *); diff --git a/src/log/toks_log_service_info.c b/src/log/toks_log_service_info.c new file mode 100644 index 0000000..588c939 --- /dev/null +++ b/src/log/toks_log_service_info.c @@ -0,0 +1,59 @@ +/*********************************************************/ +/* toksvc: a framework-native token broker service */ +/* Copyright (C) 2020 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.TOKSVC. */ +/*********************************************************/ + +#include +#include + +#include +#include "toksvc_driver_impl.h" +#include "toksvc_daemon_impl.h" +#include "toksvc_log_impl.h" + +void toks_log_service_info(struct toks_daemon_ctx * dctx) +{ + struct toks_driver_ctx * drvctx = dctx->driver_ctx; + + TOKS_LOG_LEVEL(drvctx,1); + + nt_cid cid; + char path[2048]; + + cid.process_id = pe_get_current_process_id(); + cid.thread_id = pe_get_current_thread_id(); + + toks_log_get_arbitrary_process_name( + &cid,path,sizeof(path)); + + toks_log_header( + drvctx, + TOKS_LOG_ENTRY_SERVER_INFO, + "token service information for %s " + "(syspid %d, systid %d): " + "DRIVER_INFO = {" + ".allocated_tokens=%d, " + ".available_tokens=%d, " + ".log_level=%d}, " + "DAEMON_INFO = {" + ".free_tokens=%d, " + ".used_tokens=%d, " + ".controlling_pid=%d, " + ".controlling_syspid=%d}\n", + toks_log_basename(path), + cid.process_id, + cid.thread_id, + toks_get_driver_atokens(dctx->driver_ctx), + toks_get_driver_ntokens(dctx->driver_ctx), + dctx->driver_ctx->cctx->loglevel, + dctx->ftokens, + dctx->utokens, + dctx->ctrlpid, + dctx->csyspid); + + toks_log_write( + drvctx, + TOKS_LOG_ENTRY_SUB_LEVEL_2, + "%s.\n",path); +}