<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/scripts/file-size.sh, branch v6.19.11</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2018-03-25T17:01:24+00:00</updated>
<entry>
<title>kbuild: Use ls(1) instead of stat(1) to obtain file size</title>
<updated>2018-03-25T17:01:24+00:00</updated>
<author>
<name>Michael Forney</name>
<email>forney@google.com</email>
</author>
<published>2018-03-19T00:54:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a670b0b4aed129dc11b465c1c330bfe9202023e5'/>
<id>urn:sha1:a670b0b4aed129dc11b465c1c330bfe9202023e5</id>
<content type='text'>
stat(1) is not standardized and different implementations have their own
(conflicting) flags for querying the size of a file.

ls(1) provides the same information (value of st.st_size) in the 5th
column, except when the file is a character or block device. This output
is standardized[0]. The -n option turns on -l, which writes lines
formatted like

  "%s %u %s %s %u %s %s\n", &lt;file mode&gt;, &lt;number of links&gt;,
      &lt;owner name&gt;, &lt;group name&gt;, &lt;size&gt;, &lt;date and time&gt;,
      &lt;pathname&gt;

but instead of writing the &lt;owner name&gt; and &lt;group name&gt;, it writes the
numeric owner and group IDs (this avoids /etc/passwd and /etc/group
lookups as well as potential field splitting issues).

The &lt;size&gt; field is specified as "the value that would be returned for
the file in the st_size field of struct stat".

To avoid duplicating logic in several locations in the tree, create
scripts/file-size.sh and update callers to use that instead of stat(1).

[0] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html#tag_20_73_10

Signed-off-by: Michael Forney &lt;forney@google.com&gt;
Signed-off-by: Masahiro Yamada &lt;yamada.masahiro@socionext.com&gt;
</content>
</entry>
</feed>
