From ed3e0e373845fd7fb991a34386e49ffc48ca01d6 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 23 Jul 2012 11:40:46 +0200 Subject: [PATCH] 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 --- fdisks/utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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: -- 2.47.3