summaryrefslogtreecommitdiffstats
path: root/src/librados-config.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/librados-config.cc
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/librados-config.cc')
-rw-r--r--src/librados-config.cc86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/librados-config.cc b/src/librados-config.cc
new file mode 100644
index 00000000..e8bb694d
--- /dev/null
+++ b/src/librados-config.cc
@@ -0,0 +1,86 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License version 2, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+#include "common/config.h"
+
+#include "common/ceph_argparse.h"
+#include "global/global_init.h"
+#include "global/global_context.h"
+#include "include/rados/librados.h"
+
+void usage()
+{
+ cout << "usage: librados-config [option]\n"
+ << "where options are:\n"
+ << " --version library version\n"
+ << " --vernum library version code\n";
+}
+
+void usage_exit()
+{
+ usage();
+ exit(1);
+}
+
+int main(int argc, const char **argv)
+{
+ vector<const char*> args;
+ argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
+
+ bool opt_version = false;
+ bool opt_vernum = false;
+
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ common_init_finish(g_ceph_context);
+ for (std::vector<const char*>::iterator i = args.begin();
+ i != args.end(); ) {
+ if (strcmp(*i, "--") == 0) {
+ break;
+ }
+ else if (strcmp(*i, "--version") == 0) {
+ opt_version = true;
+ i = args.erase(i);
+ }
+ else if (strcmp(*i, "--vernum") == 0) {
+ opt_vernum = true;
+ i = args.erase(i);
+ }
+ else
+ ++i;
+ }
+
+ if (!opt_version && !opt_vernum)
+ usage_exit();
+
+ if (opt_version) {
+ int maj, min, ext;
+ rados_version(&maj, &min, &ext);
+ cout << maj << "." << min << "." << ext << std::endl;
+ } else if (opt_vernum) {
+ cout << hex << LIBRADOS_VERSION_CODE << dec << std::endl;
+ }
+
+ return 0;
+}
+