Cygwin: fhandler_base::fstat_fs: accomodate the O_PATH flag

Treat a special file opened with O_PATH the same as a regular file,
i.e., use its handle to get the stat information.

Before this change, fstat_fs opened the file a second time, with the
wrong flags and without closing the existing handle.  A side effect
was to change the openflags of the file, possibly causing further
system calls to fail.

Currently this change only affects FIFOs, but it will affect
AF_LOCAL/AF_UNIX sockets too once they support O_PATH.
This commit is contained in:
Ken Brown 2020-01-24 14:54:47 -05:00
parent 4bfa93f1a0
commit 74e6e88143
1 changed files with 1 additions and 1 deletions

View File

@ -359,7 +359,7 @@ fhandler_base::fstat_fs (struct stat *buf)
if (get_stat_handle ()) if (get_stat_handle ())
{ {
if (!nohandle () && !is_fs_special ()) if (!nohandle () && (!is_fs_special () || get_flags () & O_PATH))
res = pc.fs_is_nfs () ? fstat_by_nfs_ea (buf) : fstat_by_handle (buf); res = pc.fs_is_nfs () ? fstat_by_nfs_ea (buf) : fstat_by_handle (buf);
if (res) if (res)
res = fstat_by_name (buf); res = fstat_by_name (buf);