in src/sys_info.cc [342:367]
off_t SysInfo::partition_size(dev_t device_id) {
if (!id_to_device.count(device_id)) {
fprintf(
stderr,
"Tried to lookup nonexistent device %u,%u in sys_info!\n",
major(device_id),
minor(device_id));
exit(1);
}
std::string line;
std::ifstream sizefile("/sys/class/block/" + id_to_device[device_id] + "/size");
if (!sizefile.is_open()) {
fprintf(stderr, "Couldn't open size file for device\n");
exit(1);
}
std::getline(sizefile, line);
sizefile.close();
unsigned long long sz = strtoull(line.c_str(), NULL, 10);
sz *= 512; // linux treats all devices as having a sector size of 512
return static_cast<off_t>(sz);
}