View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001303 | 1003.1(2016/18)/Issue7+TC2 | System Interfaces | public | 2019-11-27 05:11 | 2020-01-06 16:46 |
| Reporter | dannyniu | Assigned To | |||
| Priority | normal | Severity | Comment | Type | Enhancement Request |
| Status | Closed | Resolution | Accepted As Marked | ||
| Name | DannyNiu/NJF | ||||
| Organization | individual | ||||
| User Reference | |||||
| Section | alphasort, scandir, seekdir, telldir | ||||
| Page Number | 597,1843,2141 | ||||
| Line Number | 20774-20778,59725,68610 | ||||
| Interp Status | --- | ||||
| Final Accepted Text | See 0001303:0004705. | ||||
| Summary | 0001303: Artificial limit on the number of files in a directory. | ||||
| Description | The scandir function returns the number of selected files in type ``int'', which is can be as short as 32 bits, The seekdir and telldir functions works with directory position of type ``long'', which can be as short as 32 bits in some systems, and 64 bits in I32LP64 environments. These facts creates artificial limits on the number of files that can be uniquely identified in these functions, although doesn't limit the actual number of file entries that can be stored and enumerated in a directory. Although, in reality, actual filesystems may have more strict limits on the number of entries in a directory. | ||||
| Desired Action | None, but future revisions of the standard may wish to introduce improved interfaces that possibly works with the ``off_t'' type. | ||||
| Tags | No tags attached. | ||||
|
|
Since the scandir interface returns its result array via malloc's, size_t is a more appropriate type than off_t to ensure the result range is adequate. Similar applies with telldir() and seekdir() when the implementation uses record counts rather than a byte oriented file position to track entries. In looking over the interface descriptions there is an issue with scandir(), in that it is not explicit for any error, especially that occurs after sel returns a match, that it is the responsibility of the interface to free any successfully allocated result strings and the memory for the array of string pointers, before returning -1 to indicate the traverse could not be completed. In low free memory conditions ENOMEM due to trying to allocate one of these is likely to occur. |
|
|
scandir() is an interface from the past that had more issues in the past already. Original implementations have e.g. been written with the directory entry size of UFS in mind and failed with filesystems that do not follow these "rules". How about scandiro() like ftello()? |
|
|
This issue was discussed during our 2020-01-06 conference call. The Description provides a series of interesting facts, but we have no existing practice to standardize. Furthermore, we do not expect that people will actually place more files in a directory than can fit into an int. And, if we ever do get to tha point, we expect that the size of an int will also have increased by then. Since the Desired Action is "None...", we are accepting this bug as marked rather than rejecting it. Note to the editor: No changes are required in the standard. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2019-11-27 05:11 | dannyniu | New Issue | |
| 2019-11-27 05:11 | dannyniu | Name | => DannyNiu/NJF |
| 2019-11-27 05:11 | dannyniu | Organization | => individual |
| 2019-11-27 05:11 | dannyniu | Section | => alphasort, scandir, seekdir, telldir |
| 2019-11-27 05:11 | dannyniu | Page Number | => 597,1843,2141 |
| 2019-11-27 05:11 | dannyniu | Line Number | => 20774-20778,59725,68610 |
| 2019-11-27 06:11 | shware_systems | Note Added: 0004667 | |
| 2019-11-27 10:13 | joerg | Note Added: 0004668 | |
| 2020-01-06 16:44 | Don Cragun | Note Added: 0004705 | |
| 2020-01-06 16:45 | Don Cragun | Interp Status | => --- |
| 2020-01-06 16:45 | Don Cragun | Final Accepted Text | => See 0001303:0004705. |
| 2020-01-06 16:45 | Don Cragun | Status | New => Resolved |
| 2020-01-06 16:45 | Don Cragun | Resolution | Open => Accepted As Marked |
| 2020-01-06 16:46 | Don Cragun | Status | Resolved => Closed |