<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2728: status(p).permissions() and symlink_status(p).permissions() are not specified</title>
<meta property="og:title" content="Issue 2728: status(p).permissions() and symlink_status(p).permissions() are not specified">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2728.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++17">C++17</a> status.</em></p>
<h3 id="2728"><a href="lwg-defects.html#2728">2728</a>. <code>status(p).permissions()</code> and <code>symlink_status(p).permissions()</code> are not specified</h3>
<p><b>Section:</b> 31.12.13.36 <a href="https://wg21.link/fs.op.status">[fs.op.status]</a>, 31.12.13.38 <a href="https://wg21.link/fs.op.symlink.status">[fs.op.symlink.status]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Eric Fiselier <b>Opened:</b> 2016-06-19 <b>Last modified:</b> 2023-02-07</p>
<p><b>Priority: </b>0
</p>
<p><b>View all other</b> <a href="lwg-index.html#fs.op.status">issues</a> in [fs.op.status].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The current specification for  <code>status(p)</code> and <code>symlink_status(p)</code>
omits any mention on setting <code>permissions()</code> on the returned <code>file_status</code>.
Obviously they should be set, but as currently specified the 
<code>permissions()</code> will always be <code>perms::unknown</code>.
</p>

<p><i>[2016-06, Oulu]</i></p>

<p>
<a href="lwg-defects.html#2720" title="permissions function incorrectly specified for symlinks (Status: C++17)">2720</a><sup><a href="https://cplusplus.github.io/LWG/issue2720" title="Latest snapshot">(i)</a></sup> is a related issue.
</p>

<p><i>[2016-06 Oulu]</i></p>

<p>Moved to P0/Ready during issues prioritization.</p>
<p>Friday: status to Immediate</p>


<p id="res-2728"><b>Proposed resolution:</b></p>
<p>
This wording is relative to N4594.
</p>

<ol>
<li><p>Change 31.12.13.36 <a href="https://wg21.link/fs.op.status">[fs.op.status]</a> as indicated:</p>
<blockquote>
<pre>
file_status status(const path&amp; p, error_code&amp; ec) noexcept;
</pre>
<blockquote>
<p>
-4- <i>Effects:</i> If possible, determines the attributes of the file <code>p</code>
    resolves to, as if by <del> POSIX <code>stat()</code>.</del><ins>using POSIX <code>stat()</code>
    to obtain a POSIX <code>struct stat</code>.</ins>. [&hellip;]
<p/>
<ins>-?- Let <code>prms</code> denote the result of <code>(m &amp; perms::mask)</code>, where
<code>m</code> is determined as if by converting the <code>st_mode</code> member of the
obtained <code>struct stat</code> to the type <code>perms</code>.</ins>
<p/>
-5- <i>Returns:</i> 
    <p/>
<ul>
    <li><p>If <code>ec != error_code()</code>: <p/>
        <ul><li><p>[&hellip;]</p></li></ul>
    </p>
    </li>
    <li><p>Otherwise<p/>
        <ul>
            <li><p>
                If the attributes indicate a regular file, as if by POSIX <code>S_ISREG</code>, returns
                <code>file_status(file_type::regular<ins>, prms</ins>)</code>. [&hellip;]
            </p></li>
            <li><p>
                Otherwise, if the attributes indicate a directory, as if by POSIX <code>S_ISDIR</code>, returns
                <code>file_status(file_type::directory<ins>, prms</ins>)</code>. [&hellip;]
            </p></li>
            <li><p>
                Otherwise, if the attributes indicate a block special file, as if by POSIX <code>S_ISBLK</code>, returns
                <code>file_status(file_type::block<ins>, prms</ins>)</code>.
            </p></li>
            <li><p>
                Otherwise, if the attributes indicate a character special file, as if by POSIX <code>S_ISCHR</code>, returns
                <code>file_status(file_type::character<ins>, prms</ins>)</code>.
            </p></li>
            <li><p>
                Otherwise, if the attributes indicate a fifo or pipe file, as if by POSIX <code>S_ISFIFO</code>, returns
                <code>file_status(file_type::fifo<ins>, prms</ins>)</code>.
            </p></li>
            <li><p>
                Otherwise, if the attributes indicate a socket, as if by POSIX <code>S_ISSOCK</code>, returns
                <code>file_status(file_type::socket<ins>, prms</ins>)</code>.
            </p></li>
             <li><p>
                Otherwise, returns <code>file_status(file_type::unknown<ins>, prms</ins>)</code>.
            </p></li>
        </ul>
    </p></li>
</ul>
</p>
</blockquote>
</blockquote>
</li>

<li><p>Change  [fs.op.symlink_status] as indicated:</p>
<blockquote>
<pre>
file_status symlink_status(const path&amp; p);
file_status symlink_status(const path&amp; p, error_code&amp; ec) noexcept;
</pre>
<blockquote>
<p>
-1- <i>Effects:</i> Same as <code>status()</code>, above, except that the attributes
of <code>p</code> are determined as if by <del>POSIX <code>lstat()</code></del>
<ins>using POSIX <code>lstat()</code> to obtain a POSIX <code>struct stat</code></ins>.
<p/>
<ins>-?- Let <code>prms</code> denote the result of <code>(m &amp; perms::mask)</code>, where
<code>m</code> is determined as if by converting the <code>st_mode</code> member of the
obtained <code>struct stat</code> to the type <code>perms</code>.</ins>
<p/>
-2- <i>Returns:</i> Same as <code>status()</code>, above, except that if the
attributes indicate a symbolic link, as if by POSIX <code>S_ISLNK</code>,
returns <code>file_status(file_type::symlink<ins>, prms</ins>)</code>. The signature
with argument <code>ec</code> returns <code>file_status(file_type::none)</code> if an error occurs.

</p>
</blockquote>
</blockquote>
</li>

</ol>





</body>
</html>
