Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat guarantees does pathconf(..., _PC_NAME_MAX) provide?
    primarykey
    data
    text
    <p><strong>Context:</strong></p> <p>The <a href="http://linux.die.net/man/3/readdir_r" rel="nofollow"><code>readdir_r</code></a> function is used to read the next entry from a <code>DIR*</code> (there's also <code>readdir</code>, but that's not thread-safe). <code>readdir_r</code> takes a pointer to a user-allocated buffer to hold the output <code>dirent</code>. The manpage indicates that the size required for this buffer may be different on different systems, and provides an example of how to find a safe length at runtime:</p> <pre><code>len = offsetof(struct dirent, d_name) + pathconf(dirpath, _PC_NAME_MAX) + 1; </code></pre> <p>(warning: there is a race condition in the above, which can be avoided by using <code>dirfd</code> to get the file descriptor for the opened <code>DIR*</code> and using <code>fpathconf</code> instead of <code>pathconf</code>)</p> <p><strong>Question:</strong></p> <p>Looking at the manpage for <a href="http://linux.die.net/man/3/pathconf" rel="nofollow"><code>pathconf</code></a>, it states:</p> <blockquote> <p><strong>_PC_NAME_MAX</strong> returns the maximum length of a filename in the directory path or fd that the process is allowed to create. The corresponding macro is _POSIX_NAME_MAX.</p> </blockquote> <p>However, in the notes section, it states:</p> <blockquote> <p>Files with name lengths longer than the value returned for name equal to _PC_NAME_MAX may exist in the given directory.</p> </blockquote> <p>Is this note true? If so, is the example code in the <code>readdir_r</code> man-page incorrect?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload