From 200501052edde61747a16cd0af60fa925ef87bfb Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Fri, 28 May 2010 19:25:23 +0100 Subject: truncate: improve handling of non regular files Previously we copied `dd` and suppressed error messages when truncating neither regular files or shared mem objects. This was valid for `dd`, as truncation is ancillary to copying it may also do, but for `truncate` we should display all errors. Also we used the st_size from non regular files which is undefined, so we display an error when the user tries this. * src/truncate (do_truncate): Error when referencing the size of non regular files or non shared memory objects. Display all errors returned by ftruncate(). (main): Error when referencing the size of non regular files or non shared memory objects. Don't suppress error messages for any file types that can't be opened for writing. * tests/misc/truncate-dir-fail: Check that referencing the size of a directory is not supported. * tests/misc/truncate-fifo: Ensure the test doesn't hang by using the `timeout` command. Don't test the return from running ftruncate on the fifo as it's system dependent as to whether this fails or not. NEWS: Mention the change in behavior. Reported by Jim Meyering. --- NEWS | 2 ++ 1 file changed, 2 insertions(+) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 7a294f4a2..7d3343ba6 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ GNU coreutils NEWS -*- outline -*- sort -g now uses long doubles for greater range and precision. truncate now supports setting file sizes relative to a reference file. + Also errors are no longer suppressed for unsupported file types, and + relative sizes are restricted to supported file types. * Noteworthy changes in release 8.5 (2010-04-23) [stable] -- cgit v1.2.3-70-g09d2