[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#6268: Suggestion: truncate should allow -r and -s options together
From: |
Pádraig Brady |
Subject: |
bug#6268: Suggestion: truncate should allow -r and -s options together |
Date: |
Sat, 29 May 2010 01:03:08 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 |
On 28/05/10 14:17, Pádraig Brady wrote:
>> what about --ref=non-regular-file ?
>>
>> Perhaps truncate should refuse to use st_size info from
>> a non-regular file.
>>
>> Here's a pathological example:
>>
>> $ echo abcdefgh > bar
>> $ strace -e ftruncate ./truncate --ref=/dev/tty bar
>> ftruncate(3, 0) = 0
>> $ wc -c bar
>> 0 bar
>>
>> It's obvious that such an example is not likely in practice, but since
>> currently truncate's --ref uses stat, it would follow a symlink, too.
>>
>> For a directory you'd get unportable and probably surprising results.
>> Using such a reference size deserves at least a warning.
>
> Yes that's safer. st_size is only defined for regular files
> (or shared mem), so I'll only allow regular files.
> I'll push a separate patch soon.
>
> Since we're only referencing the size, there is the argument
> that we should be trying harder to get the size of block devices
> for example. There are portability issues with that though,
> and doing outside of truncate is easy enough, so I'll leave that for now.
I actually removed all ignoring of errors for
non regular files, as well as not allowing
one to reference st_size for non regular files.
I'll push the attached tomorrow sometime.
cheers,
Pádraig.
truncate-non-files.diff
Description: Text Data
- bug#6268: Suggestion: truncate should allow -r and -s options together, Richard W.M. Jones, 2010/05/25
- bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/25
- bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/26
- bug#6268: Suggestion: truncate should allow -r and -s options together, Richard W.M. Jones, 2010/05/26
- bug#6268: Suggestion: truncate should allow -r and -s options together, Jim Meyering, 2010/05/28
- bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/28
- bug#6268: Suggestion: truncate should allow -r and -s options together,
Pádraig Brady <=
- bug#6268: Suggestion: truncate should allow -r and -s options together, Jim Meyering, 2010/05/29
- bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/29
- bug#6268: Suggestion: truncate should allow -r and -s options together, Voelker, Bernhard, 2010/05/31
- bug#6268: Suggestion: truncate should allow -r and -s options together, Pádraig Brady, 2010/05/31
bug#6268: Suggestion: truncate should allow -r and -s options together, Richard W.M. Jones, 2010/05/26