Fix mbr error messages on empty partitions.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-10-01 20:12:08 +02:00
parent cef4c8d982
commit 5c0c479347
1 changed files with 3 additions and 2 deletions

View File

@ -237,9 +237,10 @@ int main(int argc, char* argv[])
if ( fd < 0 )
error(1, errno, "`%s'", path);
struct mbr mbr;
if ( preadall(fd, &mbr, sizeof(mbr), 0) != sizeof(mbr) )
size_t amount = preadall(fd, &mbr, sizeof(mbr), 0);
if ( amount < sizeof(mbr) && errno != EEOF )
error(1, errno, "read: `%s'", path);
if ( !verify_is_mbr(&mbr) )
if ( amount < sizeof(mbr) || !verify_is_mbr(&mbr) )
{
if ( probe )
exit(1);