GNU bug report logs - #6268
Suggestion: truncate should allow -r and -s options together

Previous Next

Package: coreutils;

Reported by: "Richard W.M. Jones" <rjones <at> redhat.com>

Date: Tue, 25 May 2010 15:42:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eric Blake <eblake <at> redhat.com>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 6268 <at> debbugs.gnu.org, "Voelker, Bernhard" <bernhard.voelker <at> siemens-enterprise.com>
Subject: bug#6268: Suggestion: truncate should allow -r and -s options together
Date: Tue, 01 Jun 2010 09:53:48 -0600
[Message part 1 (text/plain, inline)]
On 05/31/2010 02:50 AM, Pádraig Brady wrote:
>> So the user could use:
>> 	truncate --ref=- -s +5G myfile < /dev/sda5
>>
>> Just a thought ...
> 
> Well we never supported referencing stdin as
> we stat() the name. Also one needs to use a separate
> operation to get the size of a block device,
> so before the patch we just returned 0 which was invalid.
> 
> I wrote a comment in the code to say referencing
> the size of a block device is probably useful,
> but we'll need to worry about portability of that.

The only portable way to get the size of a block device is to open() it,
then do lseek(fd,0,SEEK_END).  Other more efficient methods, like an
ioctl, may exist for some platforms, but then it could become a
maintenance nightmare to figure out where the shortcuts are available.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 14 years and 359 days ago.

Previous Next


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