Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001303 [1003.1(2016)/Issue7+TC2] System Interfaces Comment Enhancement Request 2019-11-27 05:11 2020-01-06 16:46
Reporter dannyniu View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Closed  
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 Note: 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.
Attached Files

- Relationships

-  Notes
(0004667)
shware_systems (reporter)
2019-11-27 06:11

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.
(0004668)
joerg (reporter)
2019-11-27 10:13

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()?
(0004705)
Don Cragun (manager)
2020-01-06 16:44

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.

- Issue History
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 Note: 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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker