On 02/17/2012 06:58 AM, Jim Meyering wrote: >>> 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".
Oh right. But not the end of the world - in the eval, use $fd<>x to avoid the truncation. > 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? Alas, $fd>>x opens x with O_APPEND, so seeking to position 0 then calling write() will still append, which is not what we want. And hopefully no one is running this on the buggy version of dash, since it was only about 18 months ago where dash had a bug fix to quit using O_TRUNCATE for $fd<>x (bash and ksh have always followed that part of POSIX). Hmm, if we can't rely on $fd<>x, maybe we _can_ use $fd>>x coupled with fcntl() on fd to reset the O_APPEND before doing any write()s, but that starts to feel complicated. I'd rather go with $fd<>x and tell users to upgrade to a fixed version of dash. -- Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
