[all tools] Improve the error message if opening the metadata fails.
Remind the admin that you shouldn't run the tools on live data.
This commit is contained in:
parent
c32aaab028
commit
8fab56680c
@ -46,14 +46,23 @@ namespace {
|
|||||||
// to exception.h
|
// to exception.h
|
||||||
void syscall_failed(char const *call) {
|
void syscall_failed(char const *call) {
|
||||||
ostringstream out;
|
ostringstream out;
|
||||||
out << "syscall '" << call << "' failed: " << base::error_string(errno);;
|
out << "syscall '" << call << "' failed: " << base::error_string(errno);
|
||||||
|
throw runtime_error(out.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void syscall_failed(string const &call, string const &message)
|
||||||
|
{
|
||||||
|
ostringstream out;
|
||||||
|
out << "syscall '" << call << "' failed: " << base::error_string(errno) << "\n"
|
||||||
|
<< message;
|
||||||
throw runtime_error(out.str());
|
throw runtime_error(out.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int open_file(string const &path, int flags) {
|
int open_file(string const &path, int flags) {
|
||||||
int fd = ::open(path.c_str(), OPEN_FLAGS | flags, DEFAULT_MODE);
|
int fd = ::open(path.c_str(), OPEN_FLAGS | flags, DEFAULT_MODE);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
syscall_failed("open");
|
syscall_failed("open",
|
||||||
|
"Note: you cannot run this tool with these options on live metadata.");
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user