From: Karel Zak Date: Mon, 23 Jul 2012 09:40:46 +0000 (+0200) Subject: fdisk: fix error message for too small devices X-Git-Tag: v2.22-rc1~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed3e0e373845fd7fb991a34386e49ffc48ca01d6;p=thirdparty%2Futil-linux.git fdisk: fix error message for too small devices # touch ~/a # fdisk -l ~/a # fdisk: cannot open /root/a: Success should be (at least): fdisk: cannot open /root/a: Invalid argument Signed-off-by: Karel Zak --- diff --git a/fdisks/utils.c b/fdisks/utils.c index 07348d3803..d8a4bd1848 100644 --- a/fdisks/utils.c +++ b/fdisks/utils.c @@ -76,8 +76,11 @@ static int __init_mbr_buffer(struct fdisk_context *cxt) goto fail; /* read MBR */ - if (512 != read(cxt->dev_fd, cxt->mbr, 512)) + if (512 != read(cxt->dev_fd, cxt->mbr, 512)) { + if (errno == 0) + errno = EINVAL; /* probably too small file/device */ goto fail; + } return 0; fail: