GNOME Bugzilla – Bug 795153
W32: g_stat() and GIO fileinfo fail on root directories
Last modified: 2018-05-12 16:15:04 UTC
g_stat() returns -1 when called on paths such as "C:/".
Created attachment 370784 [details] [review] W32 gstdio: Don't try to get reparse tag unconditionally We do not need to use FindFirstFileW() to get a reparse tag if the file that is being examined is not a reparse point. This is a quick and relatively painless fix for the fact that FindFirstFileW() fails on root directories. Since root directories are unlikely to be reparse points (is it even possible?), not using this function on non-reparse-points just sidesteps the issue.
It might be possible to get reparse point tags for root directories without using FindFirstFileW() (see _g_win32_readlink_utf16_raw()), but we'd need to find a root directory that is also a reparse point, for testing purposes. Otherwise it's impossible to tell whether this method will work or not. If someone feels adventurous, try calling DeviceIoControl (<handle>, FSCTL_SET_REPARSE_POINT, ...) on a root directory of some mounted filesystem you have. But i cannot guarantee that it will continue to function after that. Nor can i say whether the result will actually work as a reparse point (a symlink or a junction).
Review of attachment 370784 [details] [review]: Fine for me
Attachment 370784 [details] pushed as 5741f20 - W32 gstdio: Don't try to get reparse tag unconditionally
Should i backport this?
I'd say yes
Backported to glib-2-56 as commit 96904149e20a04066290bc1592469930c2f57ed0. Doesn't apply to glib-2-54, as new stat code didn't exist back then.