diff --git a/metadata.cc b/metadata.cc index 8de2974..a7da4b9 100644 --- a/metadata.cc +++ b/metadata.cc @@ -65,8 +65,8 @@ namespace { if (r) throw runtime_error("Couldn't stat dev path"); - if (S_ISREG(info.st_mode)) - nr_blocks = div_down(info.st_size, MD_BLOCK_SIZE); + if (S_ISREG(info.st_mode) && info.st_size) + nr_blocks = div_up(info.st_size, MD_BLOCK_SIZE); else if (S_ISBLK(info.st_mode)) { // To get the size of a block device we need to diff --git a/thin_check.cc b/thin_check.cc index 104c8b8..abf87df 100644 --- a/thin_check.cc +++ b/thin_check.cc @@ -41,7 +41,7 @@ namespace { } } catch (std::exception &e) { if (!quiet) - cerr << e.what(); + cerr << e.what() << endl; return 1; }