diff --git a/include/toksvc/toksvc.h b/include/toksvc/toksvc.h index 485717f..bd596cb 100644 --- a/include/toksvc/toksvc.h +++ b/include/toksvc/toksvc.h @@ -56,6 +56,7 @@ extern "C" { #define TOKS_DRIVER_ACTION_ABORT 0X400000 #define TOKS_DRIVER_ACTION_NTOKENS_GET 0X1000000 +#define TOKS_DRIVER_ACTION_NTOKENS_SET 0X2000000 /* message options */ #define TOKS_OPT_SYSTEM_PID 0x0000 diff --git a/src/driver/toks_amain.c b/src/driver/toks_amain.c index e3acc67..d1ff0be 100644 --- a/src/driver/toks_amain.c +++ b/src/driver/toks_amain.c @@ -149,6 +149,32 @@ int toks_main(char ** argv, char ** envp) toks_get_driver_ntokens(dctx)); } + if (dctx->cctx->drvflags & TOKS_DRIVER_ACTION_NTOKENS_SET) { + status = toks_service_ioctl( + dctx,TOKS_IOCTL_SET_TOKEN_COUNT, + &(uintptr_t){toks_get_driver_ntokens(dctx)}, + 0); + + ret = status ? 2 : 0; + + switch (status) { + case NT_STATUS_SUCCESS: + toks_dprintf(STDERR_FILENO, + "%s: the service's ntokens parameter " + "was successfully set to %d\n", + toks_log_basename(argv[0]), + toks_get_driver_ntokens(dctx)); + break; + + default: + toks_dprintf(STDERR_FILENO, + "%s: the TOKS_IOCTL_SET_TOKEN_COUNT " + "ioctl operataion has failed " + "(check the system's documentation) [0x%x].", + toks_log_basename(argv[0]),status); + } + } + return (dctx->cctx->drvflags & TOKS_DRIVER_MODE_SERVER) ? NT_STATUS_SERVICE_NOTIFICATION : toks_exit(dctx,ret); diff --git a/src/driver/toks_driver_ctx.c b/src/driver/toks_driver_ctx.c index 62ad5e8..718829b 100644 --- a/src/driver/toks_driver_ctx.c +++ b/src/driver/toks_driver_ctx.c @@ -451,6 +451,13 @@ int toks_get_driver_ctx( cctx.drvflags |= TOKS_DRIVER_MODE_CLIENT; cctx.drvflags |= TOKS_DRIVER_ACTION_NTOKENS_GET; break; + + case TAG_NTOKENSSET: + cctx.drvflags &= ~(uint64_t)TOKS_DRIVER_MODE_SERVER; + cctx.drvflags |= TOKS_DRIVER_MODE_CLIENT; + cctx.drvflags |= TOKS_DRIVER_ACTION_NTOKENS_SET; + ntokens = toks_arg_to_int32(entry); + break; } } else /* strict */ diff --git a/src/internal/toksvc_driver_impl.h b/src/internal/toksvc_driver_impl.h index 8c50cf0..6e5cc11 100644 --- a/src/internal/toksvc_driver_impl.h +++ b/src/internal/toksvc_driver_impl.h @@ -44,6 +44,7 @@ enum app_tags { TAG_LOGFILE, TAG_LOGLEVEL, TAG_NTOKENSGET, + TAG_NTOKENSSET, }; struct toks_ticks { diff --git a/src/skin/toks_skin_default.c b/src/skin/toks_skin_default.c index 3b5be49..74f49fe 100644 --- a/src/skin/toks_skin_default.c +++ b/src/skin/toks_skin_default.c @@ -77,5 +77,9 @@ const struct argv_option toks_default_options[] = { "connect to the server and output the current overall " "number of tokens"}, + {"set-token-pool-size", 'N',TAG_NTOKENSSET,ARGV_OPTARG_REQUIRED,0,0,"", + "connect to the server and set the service's overall " + "number of tokens to %s"}, + {0,0,0,0,0,0,0,0} };