From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 11 15:29:48 2017 Received: (at submit) by debbugs.gnu.org; 11 Nov 2017 20:29:48 +0000 Received: from localhost ([127.0.0.1]:35670 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eDcPT-0005az-Oi for submit@debbugs.gnu.org; Sat, 11 Nov 2017 15:29:47 -0500 Received: from eggs.gnu.org ([208.118.235.92]:46329) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eDc4u-00056k-GT for submit@debbugs.gnu.org; Sat, 11 Nov 2017 15:08:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDc4o-000604-4t for submit@debbugs.gnu.org; Sat, 11 Nov 2017 15:08:27 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: ** X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_50, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_IMAGE_ONLY_16,HTML_MESSAGE, HTML_SHORT_LINK_IMG_2,T_DKIM_INVALID,T_REMOTE_IMAGE autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:38719) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDc4o-0005zx-1U for submit@debbugs.gnu.org; Sat, 11 Nov 2017 15:08:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDc4m-0004ID-Q1 for bug-coreutils@gnu.org; Sat, 11 Nov 2017 15:08:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDc4l-0005yK-Kq for bug-coreutils@gnu.org; Sat, 11 Nov 2017 15:08:24 -0500 Received: from mail-vk0-x235.google.com ([2607:f8b0:400c:c05::235]:54548) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eDc4l-0005xA-FM for bug-coreutils@gnu.org; Sat, 11 Nov 2017 15:08:23 -0500 Received: by mail-vk0-x235.google.com with SMTP id b18so5680931vkd.11 for ; Sat, 11 Nov 2017 12:08:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ak7cvMS3zxJPAsSOrW2vaNmQMRiueD2UWRHCrPcIpHs=; b=jBcQlr0DUKBDV+wPqbWMUScDgczbfx49yze1KGRrnV2nUHeuqwuDselH3guBh3tibs JGD5K/XTSifsmHsppliOTTTBBr0BWWFQv5CdRaQjR7hvIGx1WqkqnZ9W6d50GrjbqXh3 owass+dx3um5Qz58NQWRDvaLg3RcZXXG1Kurh6fkzEWC9Hu8yw2V+pZB+67feY3BRmkV +a2W0UnMtfrmDoQdI9CBjcozZwUq8iglVin7LLd/IxoGIVsbqkvGPY1Yr5aGLuRUsU6d EegYa8/FsNKEfjsZ1TuUZni67Isf55UBaoM8TNS9+PuoWqZegxYixMfelBRgtolkflAk YNsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ak7cvMS3zxJPAsSOrW2vaNmQMRiueD2UWRHCrPcIpHs=; b=VBV8JQ5mmiHEgIPfv0bNmqyDi7d5zk/SSr0edkPG+MdajhtaomsFrdAnHx06g4Rw2n W+fFGOu6IFJIXN1Uu/5ci8nmP4dRDaSJu3fkVM/ElMfEzvsl5AE/ZBoyQGGhLIAAiGeC UQ9XWpgbJUrpbvwKGN0PCV4hexROxIAZs4yFUsE7X2B9/6AfdmOa0Qr2qkFDjDtDxlzk eQ9nWteiO4jqlJdrZ1A+Bhe7DIO+Nm3wHSun0NJllF031Cd6GHSKAhoqrHMIWKqTiJDZ NKFRAU12jfHILcyztOXstOZtzLvP/EKrxJ+z50MnZFdMYSddlh+GzWcIkwnTmoNbAo88 PiBg== X-Gm-Message-State: AJaThX6vqZXLQCBG3akz0TDAMBpDuI3zFnXqOhR0AM89qq2dxw32KX8y zfA/cuFRHtfn73bmj4WRWQ7Eml963xiJ5JGHEZS1hw== X-Google-Smtp-Source: AGs4zMYCkPHGHcVIpQnm6tmYg/qFumRvXoUpAYG6d//wh+wzcmnaN/y+lKosjRO/t+ZCWGV0u8gXH3hm4lm3kPVh9AQ= X-Received: by 10.31.235.3 with SMTP id j3mr3488998vkh.66.1510430902357; Sat, 11 Nov 2017 12:08:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.159.33.169 with HTTP; Sat, 11 Nov 2017 12:08:22 -0800 (PST) From: David Durham Date: Sat, 11 Nov 2017 15:08:22 -0500 Message-ID: Subject: tail does not seek to the end of block device To: bug-coreutils@gnu.org Content-Type: multipart/alternative; boundary="94eb2c092d2c64a78a055dba99e3" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 11 Nov 2017 15:29:46 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.5 (--) --94eb2c092d2c64a78a055dba99e3 Content-Type: text/plain; charset="UTF-8" sudo tail -c 1024 /dev/sda2 | hd the entire /dev/sda2 device rather than seeking to the end. This takes a very long time with large disks. Deltik gives a nice explanation here - https://superuser.com/questions/1267402/how-do-i-tail-a-block-device-in-linux - of how ioctl can be used to obtain the size of a block device instead of fstat. Virus-free. www.avast.com <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> --94eb2c092d2c64a78a055dba99e3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
sudo tail -c 1024 /dev/sda2 | hd=C2=A0 the entire /dev/sda= 2 device rather than seeking to the end. This takes a very long time with l= arge disks. Deltik gives a nice explanation here - https://s= uperuser.com/questions/1267402/how-do-i-tail-a-block-device-in-linux - = of how ioctl can be used to obtain the size of a block device instead of fs= tat.

3D"" Virus-free. www.avast.com
--94eb2c092d2c64a78a055dba99e3-- From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 13 00:50:38 2017 Received: (at 29259) by debbugs.gnu.org; 13 Nov 2017 05:50:38 +0000 Received: from localhost ([127.0.0.1]:37558 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eE7dm-0003qc-5N for submit@debbugs.gnu.org; Mon, 13 Nov 2017 00:50:38 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:44008) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eE7dk-0003qS-Mc for 29259@debbugs.gnu.org; Mon, 13 Nov 2017 00:50:37 -0500 Received: from localhost.localdomain (c-73-158-116-184.hsd1.ca.comcast.net [73.158.116.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 820B59BA9; Mon, 13 Nov 2017 05:50:31 +0000 (GMT) Subject: Re: bug#29259: tail does not seek to the end of block device To: David Durham , 29259@debbugs.gnu.org References: From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: <56c3bc8d-2002-610e-2448-f09778991771@draigBrady.com> Date: Sun, 12 Nov 2017 21:50:29 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29259 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 11/11/17 12:08, David Durham wrote: > sudo tail -c 1024 /dev/sda2 | hd the entire /dev/sda2 device rather than > seeking to the end. This takes a very long time with large disks. Deltik > gives a nice explanation here - > https://superuser.com/questions/1267402/how-do-i-tail-a-block-device-in-linux > - of how ioctl can be used to obtain the size of a block device instead of > fstat. > > > Virus-free. > www.avast.com > > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > Yes maybe. The answer at the link shows how to do it efficiently with the existing `dd` and `blockdev --getsize64` tools. I also mentioned there the iflag=skip_bytes option which allows one to efficiently skip portions of a disk independently from the I/O size. Given dd is a more natural tool for dealing with device I/O, and that processing the end of a device is an unusual use case, I'm on the fence as to whether `tail` should handle this case specially. cheers, Pádraig From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 13 00:52:51 2017 Received: (at 29259) by debbugs.gnu.org; 13 Nov 2017 05:52:51 +0000 Received: from localhost ([127.0.0.1]:37562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eE7fv-0003vI-Ig for submit@debbugs.gnu.org; Mon, 13 Nov 2017 00:52:51 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41668) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eE7fu-0003v0-4k for 29259@debbugs.gnu.org; Mon, 13 Nov 2017 00:52:50 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 40CF11610E7; Sun, 12 Nov 2017 21:52:44 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id j4nMNJgbjauK; Sun, 12 Nov 2017 21:52:43 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9BA6D1610F7; Sun, 12 Nov 2017 21:52:43 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fg3LTwSYMfoh; Sun, 12 Nov 2017 21:52:43 -0800 (PST) Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 78949160735; Sun, 12 Nov 2017 21:52:43 -0800 (PST) Subject: Re: bug#29259: tail does not seek to the end of block device To: =?UTF-8?Q?P=c3=a1draig_Brady?= , David Durham , 29259@debbugs.gnu.org References: <56c3bc8d-2002-610e-2448-f09778991771@draigBrady.com> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Sun, 12 Nov 2017 21:52:43 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <56c3bc8d-2002-610e-2448-f09778991771@draigBrady.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 29259 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Why doesn't lseek work for this? From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 13 01:21:19 2017 Received: (at 29259) by debbugs.gnu.org; 13 Nov 2017 06:21:19 +0000 Received: from localhost ([127.0.0.1]:37570 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eE87S-0004gN-T8 for submit@debbugs.gnu.org; Mon, 13 Nov 2017 01:21:19 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:44090) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eE87R-0004gF-4s for 29259@debbugs.gnu.org; Mon, 13 Nov 2017 01:21:17 -0500 Received: from localhost.localdomain (c-73-158-116-184.hsd1.ca.comcast.net [73.158.116.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id E33379C0A; Mon, 13 Nov 2017 06:21:15 +0000 (GMT) Subject: Re: bug#29259: tail does not seek to the end of block device To: Paul Eggert , David Durham , 29259@debbugs.gnu.org References: <56c3bc8d-2002-610e-2448-f09778991771@draigBrady.com> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: <70de50cb-bfb0-c6f3-0c73-5a1406159ed6@draigBrady.com> Date: Sun, 12 Nov 2017 22:21:14 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29259 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 12/11/17 21:52, Paul Eggert wrote: > Why doesn't lseek work for this? Good call, it probably would. Something like the following is more acceptable since it adds very little complexity: diff --git a/src/tail.c b/src/tail.c index 1c7418d..a10470b 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1846,9 +1846,13 @@ tail_bytes (const char *pretty_filename, int fd, uintmax_ } else { - off_t end_pos = ((! presume_input_pipe && usable_st_size (&stats) - && n_bytes <= OFF_T_MAX) - ? stats.st_size : -1); + off_t end_pos = -1; + if (! presume_input_pipe && n_bytes <= OFF_T_MAX) + { + end_pos = usable_st_size (&stats) + ? stats.st_size + : lseek (fd, n_bytes, SEEK_END); + } if (end_pos <= ST_BLKSIZE (stats)) return pipe_bytes (pretty_filename, fd, n_bytes, read_pos); off_t current_pos = xlseek (fd, 0, SEEK_CUR, pretty_filename); From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 13 03:03:22 2017 Received: (at 29259) by debbugs.gnu.org; 13 Nov 2017 08:03:23 +0000 Received: from localhost ([127.0.0.1]:37605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eE9i9-00076E-AP for submit@debbugs.gnu.org; Mon, 13 Nov 2017 03:03:22 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:44450) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eE9i2-00075x-Gy for 29259@debbugs.gnu.org; Mon, 13 Nov 2017 03:03:14 -0500 Received: from localhost.localdomain (c-73-158-116-184.hsd1.ca.comcast.net [73.158.116.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 7614F4A74; Mon, 13 Nov 2017 08:03:08 +0000 (GMT) Subject: Re: bug#29259: tail does not seek to the end of block device To: Paul Eggert , David Durham , 29259@debbugs.gnu.org References: <56c3bc8d-2002-610e-2448-f09778991771@draigBrady.com> <70de50cb-bfb0-c6f3-0c73-5a1406159ed6@draigBrady.com> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: <4616feb4-c07c-3ef1-c7d8-95516b9e3f97@draigBrady.com> Date: Mon, 13 Nov 2017 00:03:06 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <70de50cb-bfb0-c6f3-0c73-5a1406159ed6@draigBrady.com> Content-Type: multipart/mixed; boundary="------------695C4064A619049B7B067B67" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29259 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------695C4064A619049B7B067B67 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 12/11/17 22:21, Pádraig Brady wrote: > On 12/11/17 21:52, Paul Eggert wrote: >> Why doesn't lseek work for this? > > Good call, it probably would. > Something like the following is more acceptable > since it adds very little complexity: Full patch attached with tests. cheers, Pádraig --------------695C4064A619049B7B067B67 Content-Type: text/x-patch; name="tail-end-of-device.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tail-end-of-device.patch" >From 691b547c6ad68ee17cafe161b55138b962c3cd7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sun, 12 Nov 2017 23:06:08 -0800 Subject: [PATCH] tail: seek to the end of block devices * src/tail.c (tail_bytes): Try lseek(..., SEEK_END) when we can't determine the file size. * tests/tail-2/end-of-device.sh: Add a new root only test. * tests/local.mk: Reference the new test. * NEWS: Mention the improvement. Paul Eggert suggested using lseek() (rather than ioctl(BLKGETSIZE64)). Fixes https://bugs.gnu.org/29259 --- NEWS | 5 +++++ src/tail.c | 27 +++++++++++++++--------- tests/local.mk | 1 + tests/tail-2/end-of-device.sh | 48 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 10 deletions(-) create mode 100755 tests/tail-2/end-of-device.sh diff --git a/NEWS b/NEWS index 3e6704d..bc5d5be 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,11 @@ GNU coreutils NEWS -*- outline -*- timeout would have then waited for the time limit to expire. [bug introduced in coreutils-8.27] +** Improvements + + tail --bytes=NUM will efficiently seek to the end of block devices, + rather than reading from the start. + ** Build-related Default man pages are now distributed which are used if perl is diff --git a/src/tail.c b/src/tail.c index 1c7418d..c6de7f1 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1830,12 +1830,11 @@ tail_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, if (from_start) { - if ( ! presume_input_pipe - && S_ISREG (stats.st_mode) && n_bytes <= OFF_T_MAX) - { - xlseek (fd, n_bytes, SEEK_CUR, pretty_filename); - *read_pos += n_bytes; - } + if (! presume_input_pipe && n_bytes <= OFF_T_MAX + && ((S_ISREG (stats.st_mode) + && xlseek (fd, n_bytes, SEEK_CUR, pretty_filename) >= 0) + || lseek (fd, n_bytes, SEEK_CUR) != -1)) + *read_pos += n_bytes; else { int t = start_bytes (pretty_filename, fd, n_bytes, read_pos); @@ -1846,12 +1845,20 @@ tail_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, } else { - off_t end_pos = ((! presume_input_pipe && usable_st_size (&stats) - && n_bytes <= OFF_T_MAX) - ? stats.st_size : -1); + off_t end_pos = -1; + off_t current_pos = -1; + + if (! presume_input_pipe && n_bytes <= OFF_T_MAX) + { + if (usable_st_size (&stats)) + end_pos = stats.st_size; + else if ((current_pos = lseek (fd, -n_bytes, SEEK_END)) != -1) + end_pos = current_pos + n_bytes; + } if (end_pos <= ST_BLKSIZE (stats)) return pipe_bytes (pretty_filename, fd, n_bytes, read_pos); - off_t current_pos = xlseek (fd, 0, SEEK_CUR, pretty_filename); + if (current_pos == -1) + current_pos = xlseek (fd, 0, SEEK_CUR, pretty_filename); if (current_pos < end_pos) { off_t bytes_remaining = end_pos - current_pos; diff --git a/tests/local.mk b/tests/local.mk index 74426f6..8ee7c50 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -135,6 +135,7 @@ all_root_tests = \ tests/rm/one-file-system.sh \ tests/rm/read-only.sh \ tests/tail-2/append-only.sh \ + tests/tail-2/end-of-device.sh \ tests/touch/now-owned-by-other.sh ALL_RECURSIVE_TARGETS += check-root diff --git a/tests/tail-2/end-of-device.sh b/tests/tail-2/end-of-device.sh new file mode 100755 index 0000000..9123c80 --- /dev/null +++ b/tests/tail-2/end-of-device.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Ensure that tail seeks to the end of a device + +# Copyright (C) 2017 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ tail + +# need write access to local device +# (even though we don't actually write anything) +require_root_ +require_local_dir_ + +get_device_size() { + BLOCKDEV=blockdev + $BLOCKDEV -V >/dev/null 2>&1 || BLOCKDEV=/sbin/blockdev + $BLOCKDEV --getsize64 "$1" +} + +# Get path to device the current dir is on. +# Note df can only get fs size, not device size. +device=$(df --output=source . | tail -n1) || framework_failure_ + +dev_size=$(get_device_size "$device") || + skip_ "failed to determine size of $device" + +tail_offset=$(expr $dev_size - 1023) || + skip_ "failed to determine tail offset" + +timeout 10 tail -c 1024 "$device" > end1 || fail=1 +timeout 10 tail -c +"$tail_offset" "$device" > end2 || fail=1 +test $(wc -c < end1) = 1024 || fail=1 +cmp end1 end2 || fail=1 + +Exit $fail -- 2.9.3 --------------695C4064A619049B7B067B67-- From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 13 10:10:04 2017 Received: (at 29259) by debbugs.gnu.org; 13 Nov 2017 15:10:04 +0000 Received: from localhost ([127.0.0.1]:38715 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eEGNA-0007zJ-Ju for submit@debbugs.gnu.org; Mon, 13 Nov 2017 10:10:04 -0500 Received: from mail-qk0-f169.google.com ([209.85.220.169]:49085) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eEGN8-0007yj-Uj for 29259@debbugs.gnu.org; Mon, 13 Nov 2017 10:10:03 -0500 Received: by mail-qk0-f169.google.com with SMTP id a142so20046159qkb.5 for <29259@debbugs.gnu.org>; Mon, 13 Nov 2017 07:10:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=6exHQ3TJuFtmh7qUKpkaiwMpwM5twc7K/fPZzh953vQ=; b=GCsvFW+XtV/ykhLz0G+i4fEKC0vtmmqCrRTvwshY1Jo/NsmRcYMBFOSS2a0Esvv5hZ ZPR0yRR8rgjzgdN/UOqahU/w5yCz/wQWLU/ba+ex4IkXYK/6KBHoYVpWMwYCwTVYrd3h 4/qOst8hvQUdJG0VAs1yeF1sJvY7TRlVjbinwjgQ3Y6d5E8/xLIUPEk/CfNXayb9UIPu 1CXjSK8eLa6gOSpbW5QbVf0iltl+lfo16Mx9k8hzrHs0cUj/1EKRUvdnPiTJ6B7afyTJ 1b//rMsQlP5gfwC5ax1t8pXMWtPvxH+YNQGmelcaWmthJpkGEUWouS9vZU/kBHF9nf+d Ltkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=6exHQ3TJuFtmh7qUKpkaiwMpwM5twc7K/fPZzh953vQ=; b=M4qeTAPq2PlSIIqZKm3foCTT0r7KT0FtERusPeDlSJVzhnyHKBRdHY35L61Adh4UrD v8apJk4DaaFrHpkWso52pJbzF8mLV4laa1kaVHHvRilRNC2iUWdvDM8osnMjAdTyAamR xEMJ8L5d+4LEezOUqoiB7K0uw5qOr2r/8EmD0IGe8eWhCTZhSWodDO/09p4CCWe21QU0 hLkY8xqxCi4TjNoMz1lRtmyJwFtK9TVrwX2Ejp0RiGvsCM4Xaj1Jnc5fSU1/RIKHoCB1 4nqDG738ydXMssvfrOy6B//812waQLGrRoRwrlwU6eYzYc7p/chD3oM5envoarCStnLH N1yA== X-Gm-Message-State: AJaThX7rzDsYzIL0NyGWVy/Rlb/HnJQeiOIQW1LACUNqzTXDZFLyVOeG v1R/DRaTUHWBUHwp/cxC/tvZUIUnaZoQ4QYCi1Q= X-Google-Smtp-Source: AGs4zMbFRc1QvDF7XEN6qNZO74DU9sqLcAl7yvWIaFDNJ7u0HVEQHG93EIgdMGIQrjA5M847vpvqEgfakP7r4DzsFes= X-Received: by 10.55.120.131 with SMTP id t125mr14384777qkc.63.1510585797334; Mon, 13 Nov 2017 07:09:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.55.9.17 with HTTP; Mon, 13 Nov 2017 07:09:36 -0800 (PST) In-Reply-To: <4616feb4-c07c-3ef1-c7d8-95516b9e3f97@draigBrady.com> References: <56c3bc8d-2002-610e-2448-f09778991771@draigBrady.com> <70de50cb-bfb0-c6f3-0c73-5a1406159ed6@draigBrady.com> <4616feb4-c07c-3ef1-c7d8-95516b9e3f97@draigBrady.com> From: Jim Meyering Date: Mon, 13 Nov 2017 07:09:36 -0800 X-Google-Sender-Auth: kK1BL_ED0FhlrLTGm9SI2EJqW18 Message-ID: Subject: Re: bug#29259: tail does not seek to the end of block device To: =?UTF-8?Q?P=C3=A1draig_Brady?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 29259 Cc: Paul Eggert , 29259@debbugs.gnu.org, David Durham X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) On Mon, Nov 13, 2017 at 12:03 AM, P=C3=A1draig Brady wro= te: > On 12/11/17 22:21, P=C3=A1draig Brady wrote: >> On 12/11/17 21:52, Paul Eggert wrote: >>> Why doesn't lseek work for this? >> >> Good call, it probably would. >> Something like the following is more acceptable >> since it adds very little complexity: > > Full patch attached with tests. Nice work. I found nothing to improve. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 29 22:05:47 2018 Received: (at 29259) by debbugs.gnu.org; 30 Oct 2018 02:05:47 +0000 Received: from localhost ([127.0.0.1]:52531 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHJPe-00014O-OY for submit@debbugs.gnu.org; Mon, 29 Oct 2018 22:05:46 -0400 Received: from mail-it1-f176.google.com ([209.85.166.176]:53181) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHJPd-000146-5w; Mon, 29 Oct 2018 22:05:45 -0400 Received: by mail-it1-f176.google.com with SMTP id r5-v6so10035104ith.2; Mon, 29 Oct 2018 19:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=QSw8CjeSEq2zuX1odAJ1rtOEZihMfV/+iYO0OCW5ahA=; b=MNKUuGX/LQz6lsLg94kBFF6e8pI8zjRqMAXy3wea8y4JTXSjLT8CK1vbkfPMfivuRb /7nVYYhfW1iilWLqzEmGgW0cgyZjpqSg6/h8PzvUbW1nvEpbq6iQvSd50uxMlFHaTMi4 BtSH/UNSqyiywbC9Oac17gg+UJOD8xC+UUTp0rAtQ9L2YRv/3yuZShb+4BV4yyDwRQZs Cwk1/m/UwpYOp6eexOk/RMffDJy9r7O0SSP1H5WqwpGkVz0LGOvPTPIPZiPytRWyX0Ju iADOymqvtOtQWJDnE4dzLAXZz4/pyJz5Jbrp4lQ8Qq8CpFsnBeKIQn10wjpapN0W94xP cJ7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QSw8CjeSEq2zuX1odAJ1rtOEZihMfV/+iYO0OCW5ahA=; b=gEopSJLlnEMZQ4hkf2kIEai5iD+1rlntu/9/JfPt82MmgrWPRfbXgglARFlWFYJpw2 TpEm2NuwvItzWnD3KPSpQln0cNFW6dDFUKWYb+4e7PkS+QhpT+/9D08BAd6KF8Rdqmv2 4V2c2t4mQX26CkLG0UY6/Z38V4tnZ+a557hXYaTGt/mOpl2n+D53RXx2k6sDJ1hZQJFS /C9yN4UV9ElAt0ZeS/BowEpvz+XNL/oq257067m/9YSDWZBPpYUaaryxRF2Foz7dBlML KOkvT1byoh8guw3AzDfZFiiOZsGu8NIbrG4OgOrTjChbcR/pbyycKeCUq5Std+Ilq+w+ 25ng== X-Gm-Message-State: AGRZ1gK6VtlszknuFI4FGQOUDh42jSPjHOkOvAH8ooIkQWE5/+Gw0k19 sb01wFTk1ZBlS1ETmF3uhAwmMHUkQyI= X-Google-Smtp-Source: AJdET5cTUPfbVMs+o8CHTHszqZhXyRMoxiDONZp7u5nWkoLDvVh8FiMauSJnYV3BFdg5hf0+oiu03w== X-Received: by 2002:a24:8641:: with SMTP id u62-v6mr178699itd.44.1540865138866; Mon, 29 Oct 2018 19:05:38 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id t190-v6sm8300372ita.39.2018.10.29.19.05.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 19:05:37 -0700 (PDT) Subject: Re: bug#29259: tail does not seek to the end of block device To: 29259@debbugs.gnu.org References: <56c3bc8d-2002-610e-2448-f09778991771@draigBrady.com> <70de50cb-bfb0-c6f3-0c73-5a1406159ed6@draigBrady.com> <4616feb4-c07c-3ef1-c7d8-95516b9e3f97@draigBrady.com> From: Assaf Gordon Message-ID: Date: Mon, 29 Oct 2018 20:05:36 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29259 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 29259 fixed close 29259 stop (triaging old bugs) Pushed here: tail: seek to the end of block devices https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=31dd7a0de272affa1120ba1fbc7db3445c548aa5 so closing as "fixed". -assaf From unknown Wed Sep 10 06:21:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 27 Nov 2018 12:24:09 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator