bug-coreutils
[Top][All Lists]
Advanced

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

bug#7649: sparse files and commands


From: Eric Blake
Subject: bug#7649: sparse files and commands
Date: Wed, 15 Dec 2010 14:16:04 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 12/15/2010 02:01 PM, address@hidden wrote:
> Hi, 
>   Just an idea:
> Am working with sparse text (ascii) files and need command line options.
> For instance, cat could have --sparse=text
> meaning 2 things:
> 1) it is a sparse file and so skip sparse recs.
> 2) it is text and so if(byte==0) skip it, it is sure to work.
> maybe do this for all commands.

Rather than modify lots of commands to add a new option, why not use
existing features of existing commands to do what you need?

tr -d '\0'

is a great way to remove NUL bytes (including sparse blocks) from a
file.  Then, for everywhere you want to use a sparse file but ignore the
NUL bytes, you instead just pass a pipe with tr doing the work for you.

cmp <(tr -d '\0' < file) otherfile

Meanwhile, I can certainly see a case for teaching tr(1) to optimize
deletion of just the NUL byte in order to be more efficient on sparse
files.  In fact, we are already in the middle of optimizing cp based on
sparseness, and have plans to optimize other tools like cmp and tar to
reuse the framework developed for cp to detect sparse blocks where the
system supports such information, so tr is an easy tool to add to that
list of potential beneficiaries.

That way, what you want to do works now (albeit not with optimal speed)
and might improve in the future (if we teach tr to special case NUL
elision); and we don't have to spend time retrofitting a new option onto
scores of programs (where you would have to wait for the new coreutils
to propagate to the machines you use).

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]