Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbd-fuse: librados will filter out -r option from command-line #46839

Merged
merged 1 commit into from Jul 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 18 additions & 9 deletions src/rbd_fuse/rbd-fuse.cc
Expand Up @@ -912,20 +912,25 @@ connect_to_cluster(rados_t *pcluster)
return 0;
}

#define OPT_NOT_FOUND -1

int main(int argc, const char *argv[])
{
memset(&rbd_image_data, 0, sizeof(rbd_image_data));

// librados will filter out -f/-d options from command-line
std::map<std::string, bool> filter_args = {
{"-f", false},
{"-d", false}};
// librados will filter out -r/-f/-d options from command-line
std::map<std::string, int> filter_options = {
{"-r", OPT_NOT_FOUND},
{"-f", OPT_NOT_FOUND},
{"-d", OPT_NOT_FOUND}};

std::set<std::string> require_arg_options = {"-r"};

std::vector<const char*> arg_vector;
for (auto idx = 0; idx < argc; ++idx) {
auto it = filter_args.find(argv[idx]);
if (it != filter_args.end()) {
it->second = true;
auto it = filter_options.find(argv[idx]);
if (it != filter_options.end()) {
it->second = idx;
}
arg_vector.push_back(argv[idx]);
}
Expand All @@ -941,9 +946,13 @@ int main(int argc, const char *argv[])
exit(1);
}

for (auto& it : filter_args) {
if (it.second) {
for (auto& it : filter_options) {
if (it.second != OPT_NOT_FOUND) {
arg_vector.push_back(it.first.c_str());
if (require_arg_options.count(it.first) &&
it.second + 1 < argc) {
arg_vector.push_back(argv[it.second + 1]);
}
}
}

Expand Down