On 05/31/2010 02:50 AM, Pádraig Brady wrote: >> So the user could use: >> truncate --ref=- -s +5G myfile < /dev/sda5 >> >> Just a thought ... > > Well we never supported referencing stdin as > we stat() the name. Also one needs to use a separate > operation to get the size of a block device, > so before the patch we just returned 0 which was invalid. > > I wrote a comment in the code to say referencing > the size of a block device is probably useful, > but we'll need to worry about portability of that. The only portable way to get the size of a block device is to open() it, then do lseek(fd,0,SEEK_END). Other more efficient methods, like an ioctl, may exist for some platforms, but then it could become a maintenance nightmare to figure out where the shortcuts are available. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org