Use common/strict_strtol, which actually parses integers in a proper
way, instead of atoi for parsing /sys/bus/rbd/devices/<id>/major. This
is important, because the kernel apparently can write things like
"(none)" into that file, and in general is more bulletproof.
Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
<< cpp_strerror(-r) << std::endl;
continue;
}
+ string err;
+ int cur_major = strict_strtol(major, 10, &err);
+ if (!err.empty()) {
+ cerr << err << std::endl;
+ cerr << "rbd: could not parse major number read from " << fn << ": "
+ << cpp_strerror(-r) << std::endl;
+ continue;
+ }
- int cur_major = atoi(major);
if (cur_major == major_num) {
seq = string(dent->d_name);
closedir(device_dir);