summaryrefslogtreecommitdiffstats
path: root/fdisks
diff options
context:
space:
mode:
authorKarel Zak2012-07-23 11:40:46 +0200
committerKarel Zak2012-07-23 11:40:46 +0200
commited3e0e373845fd7fb991a34386e49ffc48ca01d6 (patch)
tree5b4b3bc63297e39a1cf1a23ad4737f5b18d85a6b /fdisks
parentfdisk: (dos) cleanup function names (diff)
downloadkernel-qcow2-util-linux-ed3e0e373845fd7fb991a34386e49ffc48ca01d6.tar.gz
kernel-qcow2-util-linux-ed3e0e373845fd7fb991a34386e49ffc48ca01d6.tar.xz
kernel-qcow2-util-linux-ed3e0e373845fd7fb991a34386e49ffc48ca01d6.zip
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 <kzak@redhat.com>
Diffstat (limited to 'fdisks')
-rw-r--r--fdisks/utils.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fdisks/utils.c b/fdisks/utils.c
index 07348d380..d8a4bd184 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: