<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Dec 8, 2017 at 5:23 PM Max Reitz <<a href="mailto:mreitz@redhat.com">mreitz@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2017-12-07 21:33, Nir Soffer wrote:<br>
<br>
[...]<br>
<br>
><br>
> Trying harder...<br>
> <br>
><br>
> The term "file size" is ambiguous in this context...<br>
><br>
><br>
> It is not. file size is what you get from stat:<br>
><br>
> $ truncate -s 1g empty<br>
><br>
> $ stat empty <br>
> File: 'empty'<br>
> Size: 1073741824Blocks: 0 IO Block: 4096 regular file<br>
> ...<br>
><br>
> $ qemu-img info empty<br>
> image: empty<br>
> file format: raw<br>
> virtual size: 1.0G (1073741824 bytes)<br>
> disk size: 0<br>
><br>
> The value "disk size" used by qemu-img is confusing and not useful<br>
> when you want to transfer the file to another host.<br>
><br>
> I don't know why qemu-img display this value instead of the actual<br>
> file size, adding qemu-block mailing list in case someone can explain<br>
> this.<br>
<br>
Because I still think it's ambiguous.<br>
<br>
$ qemu-img create -f raw empty 1G<br>
Formatting 'empty', fmt=raw size=1073741824<br>
$ qemu-img info empty<br>
image: empty<br>
file format: raw<br>
virtual size: 1.0G (1073741824 bytes)<br>
disk size: 0<br>
$ LANG=C stat empty<br>
File: empty<br>
Size: 1073741824 Blocks: 0 IO Block: 4096 regular file<br>
[...]<br>
$ ls -s empty<br>
0 empty<br>
$ du -h empty<br>
0 empty<br>
$ ls -l empty<br>
-rw-r--r--. 1 maxx maxx 1073741824 8. Dez 16:20 empty<br>
<br>
What "stat" reports as "size" I'd call the length (what qemu-img info<br>
calls "virtual size" for raw images). </blockquote><div><br></div><div>raw images are not an issue since the virtual size is the file size.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">What I (and qemu-img info) call<br>
"size" is how much disk space is actually used. And both ls -s and du<br>
agree that it's 0 bytes in this case.<br>
<br>
By the way, yes, "stat" has a different definition of "size", so that<br>
seems wrong. But I argue that the "ls" option is called "--size", so<br>
there's a conflict already and qemu-img info is not the first tool to<br>
disagree with stat on this.<br></blockquote><div><br></div><div>I think if you ask most users what is a file size they will tell you what</div><div>stat is returning. If we use the term in the way most people expect</div><div>we can make tools easier to use.</div><div><br></div><div>Users of qemu-img have no way to tell what is disk-size, the value is</div><div>not documented, at least not in the manual or online help.</div><div><br></div><div>I think the easy way to improve this is to show both the "allocated size"</div><div>(st_size * block_size), and the "file size" (st_size).</div><div><br></div><div>Nir</div><div> <br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Max<br>
<br>
</blockquote></div></div>