From unknown Sun Aug 17 10:27:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#5913: [PATCH] maint: ftruncate is always available, even without gnulib Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 09 Apr 2010 08:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 5913 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: 5913@debbugs.gnu.org Cc: bug-gnulib@gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.127080341917475 (code B ref -1); Fri, 09 Apr 2010 08:57:01 +0000 Received: (at submit) by debbugs.gnu.org; 9 Apr 2010 08:56:59 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0A1K-0004Xo-Sy for submit@debbugs.gnu.org; Fri, 09 Apr 2010 04:56:59 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0A1H-0004Xj-OV for submit@debbugs.gnu.org; Fri, 09 Apr 2010 04:56:57 -0400 Received: from lists.gnu.org ([199.232.76.165]:45727) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O0A1E-0006sc-1L for submit@debbugs.gnu.org; Fri, 09 Apr 2010 04:56:52 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O0A1C-00087l-FE for bug-coreutils@gnu.org; Fri, 09 Apr 2010 04:56:50 -0400 Received: from [140.186.70.92] (port=36096 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O0A18-00086d-4z for bug-coreutils@gnu.org; Fri, 09 Apr 2010 04:56:48 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O0A13-0004AF-7F for bug-coreutils@gnu.org; Fri, 09 Apr 2010 04:56:44 -0400 Received: from smtp3-g21.free.fr ([212.27.42.3]:53521) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0A12-00049m-KO; Fri, 09 Apr 2010 04:56:41 -0400 Received: from smtp3-g21.free.fr (localhost [127.0.0.1]) by smtp3-g21.free.fr (Postfix) with ESMTP id 7A703818083; Fri, 9 Apr 2010 10:56:35 +0200 (CEST) Received: from mx.meyering.net (mx.meyering.net [82.230.74.64]) by smtp3-g21.free.fr (Postfix) with ESMTP id 9200D81818A; Fri, 9 Apr 2010 10:56:33 +0200 (CEST) Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 70A37ABB; Fri, 9 Apr 2010 10:56:33 +0200 (CEST) From: Jim Meyering Date: Fri, 09 Apr 2010 10:56:33 +0200 Message-ID: <87d3y957i6.fsf@meyering.net> Lines: 90 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -3.5 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.8 (----) 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@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 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 /* sets _FILE_OFFSET_BITS=64 etc. */ #include -- 1.7.1.rc0.239.g8b27e From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 09 13:47:13 2010 Received: (at control) by debbugs.gnu.org; 9 Apr 2010 17:47:13 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0IIS-0000Qr-UT for submit@debbugs.gnu.org; Fri, 09 Apr 2010 13:47:13 -0400 Received: from smtp3-g21.free.fr ([212.27.42.3]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0IIP-0000Qk-Ov for control@debbugs.gnu.org; Fri, 09 Apr 2010 13:47:10 -0400 Received: from smtp3-g21.free.fr (localhost [127.0.0.1]) by smtp3-g21.free.fr (Postfix) with ESMTP id 4C880818163 for ; Fri, 9 Apr 2010 19:47:01 +0200 (CEST) Received: from mx.meyering.net (mx.meyering.net [82.230.74.64]) by smtp3-g21.free.fr (Postfix) with ESMTP id 712E2818087 for ; Fri, 9 Apr 2010 19:46:59 +0200 (CEST) Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 55AF7C0D; Fri, 9 Apr 2010 19:46:59 +0200 (CEST) From: Jim Meyering To: control@debbugs.gnu.org Subject: control Date: Fri, 09 Apr 2010 19:46:59 +0200 Message-ID: <87ochs1pt8.fsf@meyering.net> Lines: 1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) close 5913