Anonymous | Login | 2024-12-03 18:07 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||
ID | Category | Severity | Type | Date Submitted | Last Update | ||
0000831 | [1003.1(2013)/Issue7+TC1] System Interfaces | Editorial | Clarification Requested | 2014-03-29 23:16 | 2014-04-03 15:35 | ||
Reporter | sstewartgallus | View Status | public | ||||
Assigned To | |||||||
Priority | normal | Resolution | Duplicate | ||||
Status | Closed | ||||||
Name | Steven Stewart-Gallus | ||||||
Organization | |||||||
User Reference | |||||||
Section | readdir_r | ||||||
Page Number | |||||||
Line Number | |||||||
Interp Status | --- | ||||||
Final Accepted Text | |||||||
Summary | 0000831: How to allocate memory for readdir_r is unclear. | ||||||
Description |
The Linux man-pages project suggests that one allocates memory for the entry structure passed to readdir_r as follows: len = offsetof(struct dirent, d_name) + pathconf(dirpath, _PC_NAME_MAX) + 1 entryp = malloc(len); This seems wrong, the Linux man-pages say that _PC_NAME_MAX returns the maximum length of a filename that a process is allowed to create and not the maximum length of a filename allowed in a directory. The POSIX standard does not give a clear explanation of how to allocate memory for the directory entries. I hypothesize that what is intended is that one allocates space for an entry with a name containing at least {NAME_MAX}+1 elements and that one reallocates the entry length (perhaps doubling or tripling it) when an EOVERFLOW error occurs. POSIX seems to suggest this interpretation in it's explanation for fpathconf, and pathconf: Note that implementations are allowed to accept pathnames longer than {PATH_MAX} bytes long, but are not allowed to return pathnames longer than this unless the user specifies a larger buffer using a function that provides a buffer size argument. This suggest that one would not get an entry from readdir_r if the entry was too small but only possibly an EOVERFLOW error. Given that there are misunderstandings of how to use the readdir_r function out in the wild and that POSIX does not give a clear explanation I would like to request an example in the standard clarifying how one should use the readdir_r function. |
||||||
Desired Action | Please add a clarifying example to the documentation for readdir_r. | ||||||
Tags | No tags attached. | ||||||
Attached Files | |||||||
|
Relationships | ||||||
|
Notes | |
(0002208) eblake (manager) 2014-03-29 23:33 |
We are proposing marking readdir_r as obsolete in the next version of the standard, because its interface is inherently unusable by design. See more details in 0000696 |
(0002209) sstewartgallus (reporter) 2014-03-29 23:56 edited on: 2014-03-30 00:17 |
Thank you, my apologies for opening a duplicate issue. I will eagerly follow the status in http://austingroupbugs.net/view.php?id=696 [^] |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |