[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RFS: truncate



On Wed, Apr 18, 2007 at 03:27:09PM +0100, Neil Williams wrote:
> On Wed, 18 Apr 2007 16:53:38 +0300
> Peter Pentchev <roam@ringlet.net> wrote:
> 
> > truncate   - FreeBSD utility to truncate or extend the size of files
> >
> >  The truncate utility adjusts the length of each regular file given
> > on the command-line.  This package is simply a redistribution of the
> > utility as found in the FreeBSD base system.
> 
> That description doesn't help explain why a file would need to be
> truncated (or extended without allocating space). Why truncate a file
> (and lose data) rather than split the file? Why extend a file
> without allocating space? Most (all?) file->open routines will support
> complete truncation to zero length, what is the advantage of retaining
> only a portion of the old data in the file and risk losing data
> integrity (because not all regular files use linear storage).
> XML/HTML/SGML are just three common regular file types that will react
> badly to arbitrary truncation and ignore extended file sizes without
> adding data.
> 
> Don't assume that users will know anything about the FreeBSD version -
> you need to explain the what, why and when of using such a program
> without reference to assumptions based on *BSD.

Argh.  Yep, come to think of it, this brief description could be kinda
misread this way :)  Actually, the reference to FreeBSD was more of a
recognition of the truncate original authors, not a usage reference or
anything - but you're right, in the absence of any usage references at
all...

Actually, the reason that pushed me to port truncate(1) to Debian was
the need to create a large empty file while tracking down a problem with
a webserver's large file support.  Other than that, I've used it to
initialize loopback-mount filesystems, maim lastlog files and news spool
indices by only leaving the headers, and "sudo truncate -s0 file" as an
easier-on-the-fingers alias for "sudo sh -c ': > file'" :)

So... what do you think about the following description?  Or should I
file a wishlist bug against bsdmainutils to get truncate(1) included
there?

 The truncate utility adjusts the length of each regular file given on
 the command-line.  It may be used to create sparse files (zero-filled
 files that do not take up any space on disk) for virtual filesystems,
 empty data files, or simply large files for testing.  It may also empty
 a file by setting its size to 0 bytes, or remove all but a portion of
 the data, most useful when the file has a well-known record-based
 structure like e.g. filesystem images, news spools, utmp or sa(8)
 accounting files, graphics images, etc.
 .
 This package is simply a redistribution of the truncate utility as found
 in the FreeBSD base system.
 .
  Homepage: http://devel.ringlet.net/sysutils/truncate/

Thank you and the others for the prompt replies and comments!

G'luck,
Peter

-- 
Peter Pentchev	roam@ringlet.net    roam@cnsys.bg    roam@FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
because I didn't think of a good beginning of it.

Attachment: pgp7NUPMplzIM.pgp
Description: PGP signature


Reply to: