You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Windows build number: Microsoft Windows [Version 10.0.19041.508]
Your Distribution version: Ubuntu 20.04
Whether the issue is on WSL 2 and/or WSL 1: WSL2, Linux version 4.19.128-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Tue Jun 23 12:58:10 UTC 2020
Steps to reproduce
When an application reads the contents of a p9-drvfs directory the driver does not obey a seek: it will not move its pointer.
I found this when looking deeper into a PHP/composer issue and noticed a difference in the implementation of PHP's scandir and PHP's DirectoryIterator class. Using strace I noticed the system calls for getting the directory index were different. PHP's scandir would open a directory and multiple getdents64 calls would follow (32kb of buffers in Ubuntu, 2k in Alpine). While PHP's DirectoryIterator would open, do one getdents64 call, lseek to 0, and then do subsequent getdents64 calls. It seems the seek to 0 did not alter the output of the following getdents64 calls. The PHP implementation was expecting to start at the top of the structure, resulting in missing files in the directory listing as result of the PHP implementation. Although, when the buffer was looped (complete structure was read using one getdents64 call, a seek to 0 was done (this may not have done anything)) getdents64 would read the structure from offset 0.
PHP's scandir or /bin/ls of a directory using Alpine would result in the following strace:
Analyzing the given behavior I suspect the seeking in the directory structure was not implemented. This does not happen on the ext4 filesystem.
I'm not sure if seeking in a directory file pointer is logical or needed, but there are software implementations using this that will break if not implemented.
Hi! We've identified this issue as a duplicate of another one that already exists in this repository. This specific instance is being closed in favor of tracking the concern over on the referenced thread.
Environment
Steps to reproduce
When an application reads the contents of a p9-drvfs directory the driver does not obey a seek: it will not move its pointer.
I found this when looking deeper into a PHP/composer issue and noticed a difference in the implementation of PHP's scandir and PHP's
DirectoryIterator
class. Usingstrace
I noticed the system calls for getting the directory index were different. PHP'sscandir
would open a directory and multiplegetdents64
calls would follow (32kb of buffers in Ubuntu, 2k in Alpine). While PHP'sDirectoryIterator
would open, do onegetdents64
call,lseek
to 0, and then do subsequentgetdents64
calls. It seems the seek to 0 did not alter the output of the followinggetdents64
calls. The PHP implementation was expecting to start at the top of the structure, resulting in missing files in the directory listing as result of the PHP implementation. Although, when the buffer was looped (complete structure was read using onegetdents64
call, a seek to 0 was done (this may not have done anything))getdents64
would read the structure from offset 0.PHP's
scandir
or/bin/ls
of a directory using Alpine would result in the followingstrace
:PHP's DirectoryIterator class using Alpine would result in the following
strace
:PHP's
DirectoryIterator
class using Ubuntu has a way larger buffer (32k): it does not happen hereGiven a directory with large filenames, PHP's
DirectoryIterator
on Ubuntu will result in the same: missing 118 files.Analyzing the given behavior I suspect the seeking in the directory structure was not implemented. This does not happen on the ext4 filesystem.
I'm not sure if seeking in a directory file pointer is logical or needed, but there are software implementations using this that will break if not implemented.
Referencing a PHP ticket with the same symptoms: https://bugs.php.net/bug.php?id=80056
Expected behavior
Actual behavior
The text was updated successfully, but these errors were encountered: