[PATCH 6/8] linux_read: give a proper diagnostic for an "end of file" error

Jim Meyering meyering at redhat.com
Fri Nov 13 12:43:58 UTC 2009


Before today's gpt_probe bug fix, its test case would provoke
an invalid diagnostic.  This makes the diagnostic useful.
* libparted/arch/linux.c (linux_read): When hitting EOF while reading,
diagnose it properly, rather than via strerror(0) (i.e., "Success").
---
 libparted/arch/linux.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 744f854..4fe48ec 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1711,7 +1711,9 @@ linux_read (const PedDevice* dev, void* buffer, PedSector start,
                 ex_status = ped_exception_throw (
                         PED_EXCEPTION_ERROR,
                         PED_EXCEPTION_RETRY_IGNORE_CANCEL,
-                        _("%s during read on %s"),
+                        (status == 0
+                         ? _("end of file while reading %s")
+                         : _("%s during read on %s")),
                         strerror (errno),
                         dev->path);

--
1.6.5.2.372.gc0502




More information about the parted-devel mailing list