Can't understand mount point directories on Windows
Description
The following code:
<?php
var_dump(getcwd());
print_r(scandir("."));
Resulted in this output:
string(16) "R:\dreamflame.in"
PHP Warning: scandir(.): The system cannot find the path specifi (code: 3) in Command line code on line 2
Warning: scandir(.): The system cannot find the path specifi (code: 3) in Command line code on line 2
PHP Warning: scandir(.): Failed to open directory: No such file or directory in Command line code on line 2
Warning: scandir(.): Failed to open directory: No such file or directory in Command line code on line 2
PHP Warning: scandir(): (errno 2): No such file or directory in Command line code on line 2
Warning: scandir(): (errno 2): No such file or directory in Command line code on line 2
But I expected directory listing instead

PHP Version
PHP 8.0.12
Operating System
Windows 11 build 22000
Please post the output of fsutil reparsePoint query R: and fsutil reparsePoint query R:\dreamflame.in.
R: is just a regular DOS Device mount point, mounted via registry like so:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices]
"R:"="\\??\\C:\\bin\\mapdrive"
From what I tested it is not the culprit of the problem as the reparsePoint behaved similarly in a regular folder.
I should mention that R:\dreamflame.in is a rclone mount.
Output of fsutil reparsePoint query R:\dreamflame.in:
Reparse Tag Value : 0xa0000003
Tag value: Microsoft
Tag value: Name Surrogate
Tag value: Mount Point
Substitue Name offset: 0
Substitue Name length: 106
Print Name offset: 108
Print Name Length: 106
Substitute Name: \Device\Volume{a9035697-be97-11ec-8a2b-4851c5094231}\
Print Name: \Device\Volume{a9035697-be97-11ec-8a2b-4851c5094231}\
Reparse Data Length: 0xe0
Reparse Data:
0000: 00 00 6a 00 6c 00 6a 00 5c 00 44 00 65 00 76 00 ..j.l.j.\.D.e.v.
0010: 69 00 63 00 65 00 5c 00 56 00 6f 00 6c 00 75 00 i.c.e.\.V.o.l.u.
0020: 6d 00 65 00 7b 00 61 00 39 00 30 00 33 00 35 00 m.e.{.a.9.0.3.5.
0030: 36 00 39 00 37 00 2d 00 62 00 65 00 39 00 37 00 6.9.7.-.b.e.9.7.
0040: 2d 00 31 00 31 00 65 00 63 00 2d 00 38 00 61 00 -.1.1.e.c.-.8.a.
0050: 32 00 62 00 2d 00 34 00 38 00 35 00 31 00 63 00 2.b.-.4.8.5.1.c.
0060: 35 00 30 00 39 00 34 00 32 00 33 00 31 00 7d 00 5.0.9.4.2.3.1.}.
0070: 5c 00 00 00 5c 00 44 00 65 00 76 00 69 00 63 00 \...\.D.e.v.i.c.
0080: 65 00 5c 00 56 00 6f 00 6c 00 75 00 6d 00 65 00 e.\.V.o.l.u.m.e.
0090: 7b 00 61 00 39 00 30 00 33 00 35 00 36 00 39 00 {.a.9.0.3.5.6.9.
00a0: 37 00 2d 00 62 00 65 00 39 00 37 00 2d 00 31 00 7.-.b.e.9.7.-.1.
00b0: 31 00 65 00 63 00 2d 00 38 00 61 00 32 00 62 00 1.e.c.-.8.a.2.b.
00c0: 2d 00 34 00 38 00 35 00 31 00 63 00 35 00 30 00 -.4.8.5.1.c.5.0.
00d0: 39 00 34 00 32 00 33 00 31 00 7d 00 5c 00 00 00 9.4.2.3.1.}.\...
Thanks for the info! Interestingly, fsutil reports the substitute name as \Device\Volume{a9035697-be97-11ec-8a2b-4851c5094231}\ while explorer reports the mountpoint target as \\evice\…. There is apparently something wrong there, and that doesn't look to be a PHP issue in the first place.
Can you scandir('\Device\Volume{a9035697-be97-11ec-8a2b-4851c5094231}\'), or rather scandir('\\Device\Volume{a9035697-be97-11ec-8a2b-4851c5094231}\')?
That missing 'D' might just be the shell extension talking nonsense. Anyway, I ran:
<?php
echo getcwd();
echo scandir('.');
echo scandir('\\evice\\Volume{2e81696e-bfe4-11ec-8a2d-4851c5094231}\\');
echo scandir('\\\\evice\\Volume{2e81696e-bfe4-11ec-8a2d-4851c5094231}\\');
echo scandir('\\Device\\Volume{a9035697-be97-11ec-8a2b-4851c5094231}\\');
echo scandir('\\\\Device\\Volume{a9035697-be97-11ec-8a2b-4851c5094231}\\');
and it output:
R:\dreamflame.in
Warning: scandir(.): The system cannot find the path specifi (code: 3) in Standard input code on line 3
Warning: scandir(.): Failed to open directory: No such file or directory in Standard input code on line 3
Warning: scandir(): (errno 2): No such file or directory in Standard input code on line 3
Warning: scandir(\evice\Volume{2e81696e-bfe4-11ec-8a2d-4851c5094231}\): The system cannot find the path specifi (code: 3) in Standard input code on line 4
Warning: scandir(\evice\Volume{2e81696e-bfe4-11ec-8a2d-4851c5094231}\): Failed to open directory: No such file or directory in Standard input code on line 4
Warning: scandir(): (errno 2): No such file or directory in Standard input code on line 4
Warning: scandir(\\evice\Volume{2e81696e-bfe4-11ec-8a2d-4851c5094231}\): The network name cannot be fou (code: 67) in Standard input code on line 5
Warning: scandir(\\evice\Volume{2e81696e-bfe4-11ec-8a2d-4851c5094231}\): Failed to open directory: No such file or directory in Standard input code on line 5
Warning: scandir(): (errno 2): No such file or directory in Standard input code on line 5
Warning: scandir(\Device\Volume{a9035697-be97-11ec-8a2b-4851c5094231}\): The system cannot find the path specifi (code: 3) in Standard input code on line 6
Warning: scandir(\Device\Volume{a9035697-be97-11ec-8a2b-4851c5094231}\): Failed to open directory: No such file or directory in Standard input code on line 6
Warning: scandir(): (errno 2): No such file or directory in Standard input code on line 6
Warning: scandir(\\Device\Volume{a9035697-be97-11ec-8a2b-4851c5094231}\): The network name cannot be fou (code: 67) in Standard input code on line 7
Warning: scandir(\\Device\Volume{a9035697-be97-11ec-8a2b-4851c5094231}\): Failed to open directory: No such file or directory in Standard input code on line 7
Warning: scandir(): (errno 2): No such file or directory in Standard input code on line 7
Thank you! I think I'll need to setup a suitable environment for debugging.
Anything I can help with, I'll be glad to. My test setup is using latest rclone with a sftp mount if that's of any help.
I think I'll need to setup a suitable environment for debugging.
Sorry, I won't have time for this, especially since this appears to be a low priority issue, and I still think this is an issue with rclone.
Anything I can help with, I'll be glad to.
Consider to set up a development environment, and do some debugging. I suggest to start by setting a breakpoint at https://github.com/php/php-src/blob/52a18a6620649c6c9382701aaf803e1a6346cddd/Zend/zend_virtual_cwd.c#L670