[syslinux] isohybrid: seek error - 6: Invalid argument

Gerardo Exequiel Pozzi vmlinuz386 at yahoo.com.ar
Mon Sep 13 15:34:12 PDT 2010


  On 09/13/2010 12:55 PM, H. Peter Anvin wrote:
> On 09/13/2010 12:01 AM, P J P wrote:
>> --- On Mon, 13/9/10, H. Peter Anvin<hpa at zytor.com>  wrote:
>>> By the way, using seek + write for this is pretty broken.  A much better
>>> option is to use ftruncate().
>>
>> Cool...I'll send an update.
>>
> Use ftruncate(), not truncate().
>
Based on patch from P J P, using ftruncate() + fileno() and fixing the 
argument should be filesize+padding.
I guess is ok, works fine.

===
--- isohybrid.c.orig    2010-09-13 19:13:01.605221181 -0300
+++ isohybrid.c    2010-09-13 19:25:31.225221334 -0300
@@ -541,21 +541,8 @@
      if (fwrite(buf, sizeof(char), i, fp) != (size_t)i)
          err(1, "%s: write error - 1", argv[0]);

-    if (padding)
-    {
-        if (!(buf = realloc(buf, padding)))
-            err(1, "%s: could not re-size buffer", argv[0]);
-
-        if (mode & VERBOSE)
-            printf("imgsize: %zu\n", (size_t)isostat.st_size);
-
-        if (fseek(fp, isostat.st_size, SEEK_SET))
-            err(1, "%s: seek error - 6", argv[0]);
-
-        memset(buf, 0, padding);
-        if (fwrite(buf, sizeof(char), padding, fp) != (size_t)padding)
-            err(1, "%s: write error - 2", argv[0]);
-    }
+    if (padding & ftruncate(fileno(fp), isostat.st_size + padding))
+        err(1, "%s: could not add padding bytes", argv[0]);

      free(buf);
      fclose(fp);
===

-- 
Gerardo Exequiel Pozzi
\cos^2\alpha + \sin^2\alpha = 1





More information about the Syslinux mailing list