mirror of
https://github.com/ceph/ceph
synced 2025-03-06 08:20:12 +00:00
Merge pull request #9845 from dx9/wip-config-basename
common: remove basename() dependency Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
commit
81ca1cbdd7
@ -35,10 +35,6 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#if defined(__FreeBSD__)
|
||||
/* FreeBSD/Clang requires basename() whereas Linux preffers the version in <string.h> */
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
|
||||
/* Don't use standard Ceph logging in this file.
|
||||
* We can't use logging until it's initialized, and a lot of the necessary
|
||||
@ -267,10 +263,9 @@ int md_config_t::parse_config_files_impl(const std::list<std::string> &conf_file
|
||||
* If cluster name is not set yet, use the prefix of the
|
||||
* basename of configuration file as cluster name.
|
||||
*/
|
||||
const char *fn = c->c_str();
|
||||
std::string name(basename(fn));
|
||||
int pos = name.find(".conf");
|
||||
if (pos < 0) {
|
||||
auto start = c->rfind('/') + 1;
|
||||
auto end = c->find(".conf", start);
|
||||
if (end == c->npos) {
|
||||
/*
|
||||
* If the configuration file does not follow $cluster.conf
|
||||
* convention, we do the last try and assign the cluster to
|
||||
@ -278,7 +273,7 @@ int md_config_t::parse_config_files_impl(const std::list<std::string> &conf_file
|
||||
*/
|
||||
cluster = "ceph";
|
||||
} else {
|
||||
cluster = name.substr(0, pos);
|
||||
cluster = c->substr(start, end - start);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user