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: return error if we specified a wrong image name for rbd du #11031

Merged
merged 1 commit into from Sep 21, 2016
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
6 changes: 6 additions & 0 deletions src/tools/rbd/action/DiskUsage.cc
Expand Up @@ -110,12 +110,14 @@ static int do_disk_usage(librbd::RBD &rbd, librados::IoCtx &io_ctx,
uint64_t used_size = 0;
uint64_t total_prov = 0;
uint64_t total_used = 0;
bool found = false;
std::sort(names.begin(), names.end());
for (std::vector<string>::const_iterator name = names.begin();
name != names.end(); ++name) {
if (imgname != NULL && *name != imgname) {
continue;
}
found = true;

librbd::Image image;
r = rbd.open_read_only(io_ctx, image, name->c_str(), NULL);
Expand Down Expand Up @@ -206,6 +208,10 @@ static int do_disk_usage(librbd::RBD &rbd, librados::IoCtx &io_ctx,
++count;
}
}
if (!found) {
std::cerr << "specified image " << imgname << " is not found." << std::endl;
return -ENOENT;
}

out:
if (f) {
Expand Down