<p>When syscalls use <em>AT_FDCWD</em> (e.g. <code>openat()</code>), it's not always obvious to determine the current directory, one need to search back for any <code>chdir()</code> syscall, in the process or some parent.</p>
<p>This patch prints the path when <code>-y</code> (<code>--decode-fd=path</code>) flag is used, e.g.:</p>
<div class="snippet-clipboard-content position-relative" data-snippet-clipboard-copy-content="openat(AT_FDCWD</home/rmetrich/GIT/strace>, "/lib64/libselinux.so.1" ...)
"><pre><code>openat(AT_FDCWD</home/rmetrich/GIT/strace>, "/lib64/libselinux.so.1" ...)
</code></pre></div>
<p>Note the initial commit only printed when <code>-y</code> was specified, but it appears that apparently the path decoding for FDs is always performed, even when <code>--decode-fd=dev</code> only is specified for example, hence the final code proposes to keep this behaviour:<br>
as soon as <code>--decode-fd</code> is used, <em>AT_FDCWD</em> gets decoded.</p>
<p>Because decoding makes use of <code>realpath()</code> which is known to be slow, the decoded path is cached.</p>
<p>This explains the many commits, all this can be merged if necessary later.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/strace/strace/pull/194'>https://github.com/strace/strace/pull/194</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Print cwd path to AT_FDCWD when -y (--decode-fd=path) flag is used</li>
  <li>Implement a cache for current working directory</li>
  <li>Print path for AT_FDCWD whenever decode_fd is used</li>
  <li>tests: adjusted tests for AT_FDCWD decoding</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-9de5dbb5a5b5f48190a9d6d52252c2501f6fd7636f4deb723a8429c1188483c9">src/chdir.c</a>
    (16)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-a83e82bcd9bb280ba67314984968186eab6dbaa4029a396ae0e41c8aa1d2e7ab">src/defs.h</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-d801c216bf5f499c76e5486ef7ca707ce2cf2e1724a90a1e1c4f752463bd6126">src/open.c</a>
    (22)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-96254e7c668273f0fa2069e9493e1ccc5613d7cb93a31eefb3c3d3e5639eda53">src/strace.c</a>
    (5)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-0c8b4b1487118cb347785c8707447392741100f028775646a6ee27acbcecc891">src/syscall_dummy.h</a>
    (16)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-b87666d981325abb33abd1a76b15e5a6793e4839a3981518643f42863b09b549">src/umount.c</a>
    (7)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-cddf5b0cce855d4822a6cf98bb4eeb2fe5ce18987195dd2ea6cfd2c28c852334">tests/dev-yy.c</a>
    (5)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-5c9406b93f3d9b87e10d083a7cff95f19c8467f8daceb59f4302c54b36312084">tests/faccessat.c</a>
    (21)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-7a09c1dd6ca998af7680febf0bec17847e832723d77398ada5929d036e3fda5a">tests/faccessat2.c</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-0db943fb84e6511fa7940d5478df346a883a166114d84301d92c96dbe699b63d">tests/fsconfig.c</a>
    (10)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-2d746cc1987907f2ff574c57a34b1279ff47d52b967758f0f013e8479a2eea3a">tests/fspick.c</a>
    (7)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-805b7a67e6fcd0fe113d824b24829fec603155ea6576ae041c9b9fe0806fe020">tests/mount_setattr.c</a>
    (7)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-29f3a276e6e47f9a730b5df12c980389e457c69d26baa741bbe98f6d1b27e536">tests/move_mount.c</a>
    (29)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-216fffc15f04f8a8e74aac6b7916c0fedc151760f11214bc24064b856e08f23a">tests/open_tree.c</a>
    (7)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/strace/strace/pull/194/files#diff-7b09904d7c5b701dd77055a02fb84bc2678c2367d201fa0dcae547ce3b798b5d">tests/openat2.c</a>
    (22)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/strace/strace/pull/194.patch'>https://github.com/strace/strace/pull/194.patch</a></li>
  <li><a href='https://github.com/strace/strace/pull/194.diff'>https://github.com/strace/strace/pull/194.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/strace/strace/pull/194">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AOVBTR75KNFUMSCXP3N4XHTUC4CJLANCNFSM5ELTOMZA">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/AOVBTR24OMQ54ZYWQYZRKADUC4CJLA5CNFSM5ELTOMZKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4O5G37YA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/strace/strace/pull/194",
"url": "https://github.com/strace/strace/pull/194",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>