GNU bug report logs - #5913
[PATCH] maint: ftruncate is always available, even without gnulib

Previous Next

Package: coreutils;

Reported by: Jim Meyering <jim <at> meyering.net>

Date: Fri, 9 Apr 2010 08:57:01 UTC

Severity: normal

Tags: patch

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5913 in the body.
You can then email your comments to 5913 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#5913; Package coreutils. (Fri, 09 Apr 2010 08:57:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jim Meyering <jim <at> meyering.net>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 09 Apr 2010 08:57:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: bug-coreutils <at> gnu.org
Cc: bug-gnulib <at> gnu.org
Subject: [PATCH] maint: ftruncate is always available, even without gnulib
Date: Fri, 09 Apr 2010 10:56:33 +0200
FYI, I'll push this later today.
In case you don't read the URL thread, note that for more than 3 years,
anyone who builds coreutils on a system without ftruncate would get this
message along with a failed configure:

    Your system lacks the ftruncate function.
    Please report this, along with the output of "uname -a", to the
    bug-coreutils <at> gnu.org mailing list.  To continue past this point,
    rerun configure with SKIP_FTRUNCATE_CHECK=yes.
    E.g., ./configure SKIP_FTRUNCATE_CHECK=yes

The only report I've seen was due to MinGW, and that was 3 years ago.
Newer (as in 2004 or newer) versions do provide ftruncate.


From ef5758c3282b3325340d8b601deed5ab5e7ade64 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering <at> redhat.com>
Date: Fri, 9 Apr 2010 10:49:38 +0200
Subject: [PATCH] maint: ftruncate is always available, even without gnulib

Now that even MinGW provides ftruncate, we know that all
reasonable portability targets provide this function.
Remove the workaround code.  We nearly removed the gnulib
module three years ago:
  http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/9203
and it is now officially "obsolete".
* bootstrap.conf (gnulib_modules): Remove ftruncate.
* src/copy.c (copy_reg): Remove use of HAVE_FTRUNCATE and its
no-longer-used workaround code.
* src/truncate.c: Remove a comment about handling missing ftruncate.
---
 bootstrap.conf |    1 -
 src/copy.c     |   10 ++--------
 src/truncate.c |    7 +------
 3 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 9cdf984..ad7d6d5 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -97,7 +97,6 @@ gnulib_modules="
   fsusage
   fsync
   ftello
-  ftruncate
   fts
   getdate
   getgroups
diff --git a/src/copy.c b/src/copy.c
index 29f37c9..3c32fa3 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -798,15 +798,9 @@ copy_reg (char const *src_name, char const *dst_name,

       if (last_write_made_hole)
         {
-          if (HAVE_FTRUNCATE
-              ? /* ftruncate sets the file size,
-                   so there is no need for a write.  */
-              ftruncate (dest_desc, n_read_total) < 0
-              : /* Seek backwards one character and write a null.  */
-              (lseek (dest_desc, (off_t) -1, SEEK_CUR) < 0L
-               || full_write (dest_desc, "", 1) != 1))
+          if (ftruncate (dest_desc, n_read_total) < 0)
             {
-              error (0, errno, _("writing %s"), quote (dst_name));
+              error (0, errno, _("truncating %s"), quote (dst_name));
               return_val = false;
               goto close_src_and_dst_desc;
             }
diff --git a/src/truncate.c b/src/truncate.c
index 70573cc..ece52ee 100644
--- a/src/truncate.c
+++ b/src/truncate.c
@@ -18,12 +18,7 @@

    This is backwards compatible with the FreeBSD utility, but is more
    flexible wrt the size specifications and the use of long options,
-   to better fit the "GNU" environment.
-
-   Note if !defined(HAVE_FTRUNCATE) then the --skip-ftruncate configure flag
-   was specified or we're in a mingw environment. In these cases gnulib
-   emulation will be used and GNULIB_FTRUNCATE is defined. Note if emulation
-   can't even be provided ftruncate() will return EIO.  */
+   to better fit the "GNU" environment.  */

 #include <config.h>             /* sets _FILE_OFFSET_BITS=64 etc. */
 #include <stdio.h>
--
1.7.1.rc0.239.g8b27e





bug closed, send any further explanations to Jim Meyering <jim <at> meyering.net> Request was from Jim Meyering <jim <at> meyering.net> to control <at> debbugs.gnu.org. (Fri, 09 Apr 2010 17:48:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 08 May 2010 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 15 years and 104 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.