Austin Group Defect Tracker

Aardvark Mark III


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 2019-11-27 10:13
Reporter dannyniu View Status public  
Assigned To
Priority normal Resolution Open  
Status New  
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
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()?

- 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


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