[parted-devel] [PATCH] Handle partial reads correctly

Michael Brennan brennan.brisad at gmail.com
Fri Jul 6 03:15:35 UTC 2007


I found a little bug in the linux_read function and now want to
try to send a minimal patch to fix it.  But I have never done
it before and I'm not sure on how this works.  Here I have just
taken the output from git-diff and sent it in the mail, is that
the correct way to do it?  Also does it matter if the patch is
sent as an attachment or in the message body? 
Is there any more info I need to send in order to send patches?

Thanks

The patch fixes a problem where a partial read would not be
handled correctly, I also changed the status variable to ssize_t.

Michael
-------------- next part --------------
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index b921730..ade8da4 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1405,7 +1405,6 @@ linux_read (const PedDevice* dev, void* buffer, PedSector start,
             PedSector count)
 {
         LinuxSpecific*          arch_specific = LINUX_SPECIFIC (dev);
-        int                     status;
         PedExceptionOption      ex_status;
         void*                   diobuf;
 
@@ -1453,10 +1452,10 @@ linux_read (const PedDevice* dev, void* buffer, PedSector start,
                 return 0;
 
         while (1) {
-                status = read (arch_specific->fd, diobuf, read_length);
+                ssize_t status = read (arch_specific->fd, diobuf, read_length);
                 if (status > 0)
                         memcpy(buffer, diobuf, status);
-                if (status == count * dev->sector_size) break;
+                if (status == read_length) break;
                 if (status > 0) {
                         read_length -= status;
                         buffer = (char *) buffer + status;


More information about the parted-devel mailing list