coreutils
[Top][All Lists]
Advanced

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

Re: "ls -l": Avoid unnecessary getxattr() overhead


From: Jim Meyering
Subject: Re: "ls -l": Avoid unnecessary getxattr() overhead
Date: Fri, 17 Feb 2012 14:58:54 +0100

Eric Blake wrote:

> On 02/17/2012 03:35 AM, Jim Meyering wrote:
>
>> Instead, I've realized that I can eliminate the need for the wc post-
>> processing by using the fact that our contrived output file is seekable:
>> rather than simply writing to fd, first seek to position 0 each time,
>> and write the count:
>
>>
>>   # Finally, to test it, do this:
>>   eval "LD_PRELOAD=$PWD/k.so ls --color=always -l . $fd>x" || exit 1
>>
>> Hmm... that means the case of no getxattr calls would still
>> require a little special handling to map "empty file" to "0".
>
> No.  Just add 'echo 0 >x' prior to the actual test, so that x is never
> empty.

But the eval'd code will then truncate "x".
On some systems there will be no intercepted *getxattr call,
and hence x will still be empty.

Ahh... or maybe you meant to suggest that the eval'd code append to x?
That would work.

On a related note, I've just run "make distcheck", which exposed a bug
in this code:

  eval "LD_PRELOAD=$PWD/k.so ls --color=always -l . $fd>x" || exit 1

That fails when $PWD contains a space.  coreutils' make distcheck test
does actually build with such a working directory, to test for precisely
this type of bug.

The fix is trivial:

  -eval "LD_PRELOAD=$PWD/k.so ls --color=always -l . $fd>x" || exit 1
  +eval "LD_PRELOAD=./k.so ls --color=always -l . $fd>x" || exit 1



reply via email to

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