On Tuesday 18 February 2025 23:32:54 Lasse Collin wrote:
> On 2025-02-18 Pali Rohár wrote:
> > Just one test case, can you check that your new readdir() function is
> > working correctly on these two paths?
> > 
> > \\?\GLOBALROOT\Device\Harddisk0\Partition1\
> > \\?\GLOBALROOT\Device\HardiskVolume1\
> > 
> > If you are not familiar with NT paths encoded in WinAPI paths, both
> > should refer to WinAPI C:\ (or whatever is the first partition of the
> > first disk in the system).
> 
> Yes, they work.
> 
> With one partition, opendir fails with EIO, and GetLastError returns
> ERROR_UNRECOGNIZED_VOLUME (1005). That seems to mean that there's no
> recognized file system. I don't know if that error code should become
> something else than EIO. I guess it doesn't really matter.

Hard to guess. I think that EIO is enough. POSIX errno codes are not
prepared for all these Windows stuffs.

> Trying //./PHYSICALDRIVE0 results in EIO and ERROR_GEN_FAILURE (31).

WinAPI path //./PHYSICALDRIVE0 is NT path \??\PhysicalDrive0 which
is symlink to \Device\Harddisk0\DR0. And this DR0 should represent the
equivalent of the block device.

For complete information, the \Device\Harddisk0\Partition0 also symlink
to \Device\Harddisk0\DR0

> In this case ENOTDIR would be better, but I have no idea if that error is
> possible in some very different situation too. May the exact errno
> doesn't matter too much with paths like this, and EIO is OK enough.

ERROR_GEN_FAILURE is generic error code which can happen for lot of
other cases. So EIO is the best translation.

For having better error code, it would be needed to get the NT status
code from the syscall, but I'm not sure if it is possible to easily get
it for FindFirstFileW() function.

> These paths don't work with the old dirent. opendir fails with ENOENT.

Perfect, this is then nice improvement, that in new version it is
working.

> Now I noticed that "con" results in EIO and ERROR_NOT_FOUND (1168). I
> will add it to the list of errors that become ENOTDIR. The old dirent
> correctly uses ENOTDIR with "con".

Ok, that seems find.

This is interesting error. Different from ERROR_FILE_NOT_FOUND (2) and
ERROR_PATH_NOT_FOUND (3).

> > I do not have any other comments for this. Looks good for me.
> 
> Thanks! May I add you to the commit message with Reviewed-by? Would you
> like to be included in the credits in dirent.c? Your feedback made
> get_d_type() better and helped me spot the need for get_code_page().

You can, that is fine.

> > I was just surprised that FILENAME_MAX is in C99, I did not know about
> > it. I thought that it is MS invention, together with that value 260.
> > Now I checked and this macro is available since C89. So it is really
> > old.
> 
> I didn't know either until I looked. It surprised me too. :-)
> 
> -- 
> Lasse Collin


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to