From 195d1e8c8e5f128dc49b1e03e79ac01218f92760 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 5 Apr 2021 16:28:11 +0800 Subject: [PATCH] tools/ceph-dencoder: print human-readable error message if $CEPH_LIB is not specified. Signed-off-by: Kefu Chai --- src/tools/ceph-dencoder/ceph_dencoder.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tools/ceph-dencoder/ceph_dencoder.cc b/src/tools/ceph-dencoder/ceph_dencoder.cc index 2bb73db0854e2..ccf51575c738c 100644 --- a/src/tools/ceph-dencoder/ceph_dencoder.cc +++ b/src/tools/ceph-dencoder/ceph_dencoder.cc @@ -23,6 +23,7 @@ namespace fs = std::filesystem; #include namespace fs = std::experimental::filesystem; #endif +#include #include "ceph_ver.h" #include "include/types.h" @@ -105,6 +106,12 @@ vector load_plugins() if (auto ceph_lib = getenv("CEPH_LIB"); ceph_lib) { mod_dir = ceph_lib; } + if (!fs::is_directory(mod_dir)) { + std::cerr << "unable to load dencoders from " + << std::quoted(mod_dir.native()) << ". " + << "it is not a directory." << std::endl; + return {}; + } vector dencoder_plugins; for (auto& entry : fs::directory_iterator(mod_dir)) { static const string_view DENC_MOD_PREFIX = "denc-mod-"; -- 2.39.5