From 57ecbb2cda1c4624b170148571f011c022d8e19c Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 15 Jan 2020 23:20:07 +0300 Subject: [PATCH] Parse OSD commandline options --- osd_main.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/osd_main.cpp b/osd_main.cpp index 7c4700f40..c6c357ba8 100644 --- a/osd_main.cpp +++ b/osd_main.cpp @@ -1,5 +1,12 @@ #include "osd.h" +#include + +void handle_sigint(int sig) +{ + exit(0); +} + int main(int narg, char *args[]) { if (sizeof(osd_any_op_t) >= OSD_PACKET_SIZE || @@ -9,9 +16,15 @@ int main(int narg, char *args[]) return 1; } blockstore_config_t config; - config["meta_device"] = "./test_meta.bin"; - config["journal_device"] = "./test_journal.bin"; - config["data_device"] = "./test_data.bin"; + for (int i = 1; i < narg; i++) + { + if (args[i][0] == '-' && args[i][1] == '-' && i < narg-1) + { + char *opt = args[i]+2; + config[opt] = args[++i]; + } + } + signal(SIGINT, handle_sigint); ring_loop_t *ringloop = new ring_loop_t(512); blockstore_t *bs = new blockstore_t(config, ringloop); osd_t *osd = new osd_t(config, bs, ringloop);